diff options
author | lloyd <[email protected]> | 2013-12-31 19:07:52 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2013-12-31 19:07:52 +0000 |
commit | 7947d9787fe1cf448a418e2252edededdf887032 (patch) | |
tree | c00f6c2c366c467079cd5e513df4d12b63fd71e5 /src/utils/cpuid.cpp | |
parent | c0ce45696f6d00e7496634c233410d264d0e9d42 (diff) |
On x86-64, prefer calling cpuid directly vs using cpuid.h
Diffstat (limited to 'src/utils/cpuid.cpp')
-rw-r--r-- | src/utils/cpuid.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/utils/cpuid.cpp b/src/utils/cpuid.cpp index 75a88c6b8..6da5673c1 100644 --- a/src/utils/cpuid.cpp +++ b/src/utils/cpuid.cpp @@ -32,7 +32,6 @@ #include <intrin.h> #define X86_CPUID(type, out) do { __cpuid((int*)out, type); } while(0) - #define X86_CPUID_SUBLEVEL(type, level, out) do { __cpuidex((int*)out, type, level); } while(0) #elif defined(BOTAN_BUILD_COMPILER_IS_INTEL) @@ -40,15 +39,7 @@ #include <ia32intrin.h> #define X86_CPUID(type, out) do { __cpuid(out, type); } while(0) - -#elif defined(BOTAN_BUILD_COMPILER_IS_GCC) - -#include <cpuid.h> - -#define X86_CPUID(type, out) do { __get_cpuid(type, out, out+1, out+2, out+3); } while(0) - -#define X86_CPUID_SUBLEVEL(type, level, out) \ - do { __cpuid_count(type, level, out[0], out[1], out[2], out[3]); } while(0) +#define X86_CPUID_SUBLEVEL(type, level, out) do { __cpuidex((int*)out, type, level); } while(0) #elif defined(BOTAN_TARGET_ARCH_IS_X86_64) && BOTAN_USE_GCC_INLINE_ASM @@ -60,9 +51,18 @@ asm("cpuid\n\t" : "=a" (out[0]), "=b" (out[1]), "=c" (out[2]), "=d" (out[3]) \ : "0" (type), "2" (level)) +#elif defined(BOTAN_BUILD_COMPILER_IS_GCC) + +#include <cpuid.h> + +#define X86_CPUID(type, out) do { __get_cpuid(type, out, out+1, out+2, out+3); } while(0) + +#define X86_CPUID_SUBLEVEL(type, level, out) \ + do { __cpuid_count(type, level, out[0], out[1], out[2], out[3]); } while(0) + #else -#warning "No way of doing cpuid with this compiler" +#warning "No way of calling cpuid for this compiler" #define X86_CPUID(type, out) do { clear_mem(out, 4); } while(0) #define X86_CPUID_SUBLEVEL(type, level, out) do { clear_mem(out, 4); } while(0) |