[cpu] split AES detect for GNU C < 5

Signed-off-by: r4sas <r4sas@i2pmail.org>
This commit is contained in:
r4sas 2023-09-07 21:20:52 +00:00
parent 4a5e16b994
commit 4ed19c05f6
No known key found for this signature in database
GPG key ID: 66F6C87B98EBCFE2

View file

@ -30,29 +30,30 @@ namespace cpu
inline bool cpu_support_aes() inline bool cpu_support_aes()
{ {
#if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_IX86) || defined(__i386__)) #if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_IX86) || defined(__i386__))
# if (defined(__GNUC__) && __GNUC__ > 4) #if defined(__clang__)
# warning("CPU: IN GCC!!!") # if (__clang_major__ >= 6)
__builtin_cpu_init();
# endif
return __builtin_cpu_supports("aes");
#elif (defined(__GNUC__) && __GNUC__ >= 5)
__builtin_cpu_init(); __builtin_cpu_init();
return __builtin_cpu_supports("aes"); return __builtin_cpu_supports("aes");
# elif (defined(__clang__) && !defined(__GNUC__)) #elif (defined(__GNUC__) && __GNUC__ < 5)
# warning("CPU: IN CLANG!!!") int cpu_info[4];
# warning(__clang__) bool flag = false;
# if (__clang_major__ >= 6) __cpuid(0, cpu_info[0], cpu_info[1], cpu_info[2], cpu_info[3]);
__builtin_cpu_init(); if (cpu_info[0] >= 0x00000001) {
# endif __cpuid(0x00000001, cpu_info[0], cpu_info[1], cpu_info[2], cpu_info[3]);
return __builtin_cpu_supports("aes"); flag = ((cpu_info[2] & bit_AES) != 0);
# elif (defined(_MSC_VER) || (defined(__GNUC__) && __GNUC__ < 5)) }
# warning("CPU: IN MSVC!!!") return flag;
#elif defined(_MSC_VER)
int cpu_info[4]; int cpu_info[4];
__cpuid(cpu_info, 1); __cpuid(cpu_info, 1);
return ((cpu_info[2] & bit_AES) != 0); return ((cpu_info[2] & bit_AES) != 0);
# else
# warning("CPU: FALSE")
return false;
# endif
#else
return false;
#endif #endif
#endif
return false;
} }
void Detect(bool AesSwitch, bool force) void Detect(bool AesSwitch, bool force)