mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-23 01:49:53 +03:00
Mayaqua: use "cpu_features" to check whether AES-NI is supported
This commit is contained in:
parent
2a37d6aa7b
commit
d3af4d6f26
@ -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})
|
||||||
|
@ -147,9 +147,20 @@
|
|||||||
|
|
||||||
#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"
|
||||||
|
#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
|
||||||
|
#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;
|
||||||
|
#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
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
return supported;
|
return supported;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user