mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-22 17:39:53 +03:00
Merge PR #605: Mayaqua: use "cpu_features" to check whether AES-NI is supported
This commit is contained in:
commit
73371087ef
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "src/Mayaqua/cpu_features"]
|
||||||
|
path = src/Mayaqua/cpu_features
|
||||||
|
url = https://github.com/google/cpu_features.git
|
@ -19,7 +19,11 @@ find_package(ZLIB REQUIRED)
|
|||||||
# In some cases libiconv is not included in libc
|
# In some cases libiconv is not included in libc
|
||||||
find_library(LIB_ICONV iconv)
|
find_library(LIB_ICONV iconv)
|
||||||
|
|
||||||
target_link_libraries(mayaqua OpenSSL::SSL OpenSSL::Crypto Threads::Threads ZLIB::ZLIB)
|
add_subdirectory(cpu_features)
|
||||||
|
|
||||||
|
target_include_directories(mayaqua PRIVATE cpu_features/include)
|
||||||
|
|
||||||
|
target_link_libraries(mayaqua cpu_features OpenSSL::SSL OpenSSL::Crypto Threads::Threads ZLIB::ZLIB)
|
||||||
|
|
||||||
if(LIB_ICONV)
|
if(LIB_ICONV)
|
||||||
target_link_libraries(mayaqua ${LIB_ICONV})
|
target_link_libraries(mayaqua ${LIB_ICONV})
|
||||||
|
@ -146,10 +146,21 @@
|
|||||||
#include <Mayaqua/Mayaqua.h>
|
#include <Mayaqua/Mayaqua.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <intrin.h> // For __cpuid()
|
#include <intrin.h> // For __cpuid()
|
||||||
#else
|
#else // _MSC_VER
|
||||||
#include <cpuid.h> // For __get_cpuid()
|
#include "cpu_features_macros.h"
|
||||||
#endif
|
#if defined(CPU_FEATURES_ARCH_X86)
|
||||||
|
#include "cpuinfo_x86.h"
|
||||||
|
#elif defined(CPU_FEATURES_ARCH_ARM)
|
||||||
|
#include "cpuinfo_arm.h"
|
||||||
|
#elif defined(CPU_FEATURES_ARCH_AARCH64)
|
||||||
|
#include "cpuinfo_aarch64.h"
|
||||||
|
#elif defined(CPU_FEATURES_ARCH_MIPS)
|
||||||
|
#include "cpuinfo_mips.h"
|
||||||
|
#elif defined(CPU_FEATURES_ARCH_PPC)
|
||||||
|
#include "cpuinfo_ppc.h"
|
||||||
|
#endif
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
LOCK *openssl_lock = NULL;
|
LOCK *openssl_lock = NULL;
|
||||||
|
|
||||||
@ -4222,11 +4233,24 @@ bool IsAesNiSupported()
|
|||||||
int regs[4]; // EAX, EBX, ECX, EDX
|
int regs[4]; // EAX, EBX, ECX, EDX
|
||||||
__cpuid(regs, 1);
|
__cpuid(regs, 1);
|
||||||
supported = (regs[2] >> 25) & 1;
|
supported = (regs[2] >> 25) & 1;
|
||||||
#else
|
#else // _MSC_VER
|
||||||
uint32_t eax, ebx, ecx, edx;
|
#if defined(CPU_FEATURES_ARCH_X86)
|
||||||
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
|
const X86Features features = GetX86Info().features;
|
||||||
supported = (ecx & bit_AES) > 0;
|
supported = features.aes;
|
||||||
#endif
|
#elif defined(CPU_FEATURES_ARCH_ARM)
|
||||||
|
const ArmFeatures features = GetArmInfo().features;
|
||||||
|
supported = features.aes;
|
||||||
|
#elif defined(CPU_FEATURES_ARCH_AARCH64)
|
||||||
|
const Aarch64Features features = GetAarch64Info().features;
|
||||||
|
supported = features.aes;
|
||||||
|
#elif defined(CPU_FEATURES_ARCH_MIPS)
|
||||||
|
const MipsFeatures features = GetMipsInfo().features;
|
||||||
|
supported = features.aes;
|
||||||
|
#elif defined(CPU_FEATURES_ARCH_PPC)
|
||||||
|
const PPCFeatures features = GetPPCInfo().features;
|
||||||
|
supported = features.aes;
|
||||||
|
#endif
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
return supported;
|
return supported;
|
||||||
}
|
}
|
||||||
|
1
src/Mayaqua/cpu_features
Submodule
1
src/Mayaqua/cpu_features
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 26133d3b620c2c27f31d571efd27371100f891e9
|
Loading…
Reference in New Issue
Block a user