aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-05-13 20:13:00 +0000
committerlloyd <[email protected]>2010-05-13 20:13:00 +0000
commit4cace3ee04ae9a20a57b1fa11447a1917f0f155d (patch)
tree4a4d5a7e1fdbc548c8eca57c109d3cabaec49640
parentd1f7b117a81982373f4aaa3260b5017b5bf10450 (diff)
Add a build.h macro BOTAN_GCC_VERSION which is set to major*100+minor*10+patch
if we are compiling under GCC, or 0 otherwise. Use it in cpuid.cpp for use of GCC's cpuid.h header file. If we don't have a method of calling cpuid, print a warning.
-rw-r--r--src/build-data/buildh.in7
-rw-r--r--src/utils/cpuid.cpp5
2 files changed, 10 insertions, 2 deletions
diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in
index 724801040..90d274d58 100644
--- a/src/build-data/buildh.in
+++ b/src/build-data/buildh.in
@@ -35,6 +35,13 @@
#define BOTAN_USE_GCC_INLINE_ASM 0
#endif
+#ifdef __GNUC__
+ #define BOTAN_GCC_VERSION \
+ (__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCH__)
+#else
+ #define BOTAN_GCC_VERSION 0
+#endif
+
/* Target identification and feature test macros */
%{target_os_defines}
diff --git a/src/utils/cpuid.cpp b/src/utils/cpuid.cpp
index e4f5a1318..19a2db788 100644
--- a/src/utils/cpuid.cpp
+++ b/src/utils/cpuid.cpp
@@ -26,14 +26,15 @@
#include <ia32intrin.h>
#define CALL_CPUID(type, out) do { __cpuid(out, type); } while(0);
-#elif defined(BOTAN_BUILD_COMPILER_IS_GCC) && \
- ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+#elif BOTAN_GCC_VERSION >= 430
// Only available starting in GCC 4.3
#include <cpuid.h>
#define CALL_CPUID(type, out) \
do { __get_cpuid(type, out, out+1, out+2, out+3); } while(0);
+#else
+ #warning "No method of calling CPUID for this compiler"
#endif
#endif