mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-12-25 17:49:52 +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
|
||||
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)
|
||||
target_link_libraries(mayaqua ${LIB_ICONV})
|
||||
|
@ -146,10 +146,21 @@
|
||||
#include <Mayaqua/Mayaqua.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h> // For __cpuid()
|
||||
#else
|
||||
#include <cpuid.h> // For __get_cpuid()
|
||||
#endif
|
||||
#include <intrin.h> // For __cpuid()
|
||||
#else // _MSC_VER
|
||||
#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 // _MSC_VER
|
||||
|
||||
LOCK *openssl_lock = NULL;
|
||||
|
||||
@ -4222,11 +4233,24 @@ bool IsAesNiSupported()
|
||||
int regs[4]; // EAX, EBX, ECX, EDX
|
||||
__cpuid(regs, 1);
|
||||
supported = (regs[2] >> 25) & 1;
|
||||
#else
|
||||
uint32_t eax, ebx, ecx, edx;
|
||||
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
|
||||
supported = (ecx & bit_AES) > 0;
|
||||
#endif
|
||||
#else // _MSC_VER
|
||||
#if defined(CPU_FEATURES_ARCH_X86)
|
||||
const X86Features features = GetX86Info().features;
|
||||
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 // _MSC_VER
|
||||
|
||||
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