aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-12-21 00:40:43 +0000
committerlloyd <[email protected]>2013-12-21 00:40:43 +0000
commit9d6c7524f5a6421530adee17d7843cb358180779 (patch)
tree642cfba1d4ed58291ef7c8fb8ba26d8291604ca2
parentbf0b0ed62095a3663b99155548a8f0eba231a723 (diff)
Fix gcc cpuid call
-rw-r--r--src/utils/cpuid.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/utils/cpuid.cpp b/src/utils/cpuid.cpp
index 7f920ede7..d903b7d41 100644
--- a/src/utils/cpuid.cpp
+++ b/src/utils/cpuid.cpp
@@ -40,25 +40,14 @@
#define X86_CPUID(type, out) do { __cpuid(out, type); } while(0)
-#elif defined(BOTAN_BUILD_COMPILER_IS_GCC) && 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)
-namespace {
-
-// avoids asm clobber errors in gcc 4.7.3
-void gcc_cpuid(unsigned int type, unsigned int level, unsigned int* eax, unsigned int* ebx,
- unsigned int* ecx, unsigned int* edx)
- {
- __cpuid_count(type, level, eax, ebx, ecx, edx);
- }
-
-}
-
#define X86_CPUID_SUBLEVEL(type, level, out) \
- do { gcc_cpuid(type, level, out, out+1, out+2, out+3); } while(0)
+ do { __cpuid_count(type, level, out[0], out[1], out[2], out[3]); } while(0)
#elif defined(BOTAN_TARGET_ARCH_IS_X86_64) && BOTAN_USE_GCC_INLINE_ASM
@@ -70,6 +59,13 @@ void gcc_cpuid(unsigned int type, unsigned int level, unsigned int* eax, unsigne
asm("cpuid\n\t" : "=a" (out[0]), "=b" (out[1]), "=c" (out[2]), "=d" (out[3]) \
: "0" (type), "2" (level))
+#else
+
+#warning "No way of doing cpuid with 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)
+
#endif
#endif