diff options
author | lloyd <[email protected]> | 2010-07-26 19:44:50 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-07-26 19:44:50 +0000 |
commit | c8a27139fe6b559bca2fbb64bd180c8fd2c2fa32 (patch) | |
tree | c52cf62828a8b4a5f876d3125818202a9a22b0e0 /src/utils/cpuid.h | |
parent | e51e9aa6a6033710920f0934178ef770fd25498f (diff) |
Modify CPUID so all the check functions are purely inline. Add a new
initialize() call which must be called prior to use of any other
functions.
Diffstat (limited to 'src/utils/cpuid.h')
-rw-r--r-- | src/utils/cpuid.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/utils/cpuid.h b/src/utils/cpuid.h index a6a278a6e..6339a0117 100644 --- a/src/utils/cpuid.h +++ b/src/utils/cpuid.h @@ -1,6 +1,6 @@ /* * Runtime CPU detection -* (C) 2009 Jack Lloyd +* (C) 2009-2010 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -19,9 +19,14 @@ class BOTAN_DLL CPUID { public: /** + * Probe the CPU and see what extensions are supported + */ + static void initialize(); + + /** * Return a best guess of the cache line size */ - static u32bit cache_line_size(); + static u32bit cache_line_size() { return cache_line; } /** * Check if the processor supports RDTSC @@ -68,13 +73,8 @@ class BOTAN_DLL CPUID /** * Check if the processor supports AltiVec/VMX */ - static bool has_altivec(); + static bool has_altivec() { return altivec_capable; } private: - static bool x86_processor_flags_has(u64bit bit) - { - return ((x86_processor_flags() >> bit) & 1); - } - enum CPUID_bits { CPUID_RDTSC_BIT = 4, CPUID_SSE2_BIT = 26, @@ -85,7 +85,14 @@ class BOTAN_DLL CPUID CPUID_AVX_BIT = 60 }; - static u64bit x86_processor_flags(); + static bool x86_processor_flags_has(u64bit bit) + { + return ((x86_processor_flags >> bit) & 1); + } + + static u64bit x86_processor_flags; + static u32bit cache_line; + static bool altivec_capable; }; } |