1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-31 09:04:14 +00:00

[cpu] tests with preprocessor

Signed-off-by: r4sas <r4sas@i2pmail.org>
This commit is contained in:
R4SAS 2023-09-07 16:56:53 +00:00
parent c53ad2012c
commit 4a5e16b994
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2

View File

@ -30,21 +30,26 @@ 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(__GNUC__) && __GNUC__ > 4)
# warning("CPU: IN GCC!!!")
__builtin_cpu_init(); __builtin_cpu_init();
return __builtin_cpu_supports("aes"); return __builtin_cpu_supports("aes");
#elif defined(__clang__) # elif (defined(__clang__) && !defined(__GNUC__))
#if __clang_major__ >= 6 # warning("CPU: IN CLANG!!!")
# warning(__clang__)
# if (__clang_major__ >= 6)
__builtin_cpu_init(); __builtin_cpu_init();
#endif # endif
return __builtin_cpu_supports("aes"); return __builtin_cpu_supports("aes");
#elif (defined(_MSC_VER) || (defined(__GNUC__) && __GNUC__ < 5)) # elif (defined(_MSC_VER) || (defined(__GNUC__) && __GNUC__ < 5))
# warning("CPU: IN MSVC!!!")
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 # else
# warning("CPU: FALSE")
return false; return false;
#endif # endif
#else #else
return false; return false;
#endif #endif