diff options
author | lloyd <[email protected]> | 2011-06-16 15:00:21 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-06-16 15:00:21 +0000 |
commit | 8511c97586bf70394e0144d6edbf6fa56778ffde (patch) | |
tree | 178b2a45d4a801057f6893b0ff2f988815c53fa1 | |
parent | 36ca4c962bf963ad9f76fb2c26202c0679cbd7ae (diff) |
Detect (though not using) the CPUID bit for the RDRAND instruction
-rw-r--r-- | doc/examples/cpuid.cpp | 1 | ||||
-rw-r--r-- | src/utils/cpuid.h | 9 |
2 files changed, 9 insertions, 1 deletions
diff --git a/doc/examples/cpuid.cpp b/doc/examples/cpuid.cpp index 6d4cc7593..bd81e417b 100644 --- a/doc/examples/cpuid.cpp +++ b/doc/examples/cpuid.cpp @@ -42,5 +42,6 @@ int main() print_if_feature("RDTSC", CPUID::has_rdtsc()); print_if_feature("PCMUL", CPUID::has_pcmuludq()); print_if_feature("AES-NI", CPUID::has_aes_ni()); + print_if_feature("RDRND", CPUID::has_rdrand()); print_if_feature("MOVBE", CPUID::has_movbe()); } diff --git a/src/utils/cpuid.h b/src/utils/cpuid.h index 863ba5b63..ad85ac4fe 100644 --- a/src/utils/cpuid.h +++ b/src/utils/cpuid.h @@ -83,6 +83,12 @@ class BOTAN_DLL CPUID { return x86_processor_flags_has(CPUID_MOVBE_BIT); } /** + * Check if the processor supports RDRAND + */ + static bool has_rdrand() + { return x86_processor_flags_has(CPUID_RDRAND_BIT); } + + /** * Check if the processor supports AltiVec/VMX */ static bool has_altivec() { return altivec_capable; } @@ -96,7 +102,8 @@ class BOTAN_DLL CPUID CPUID_SSE42_BIT = 52, CPUID_MOVBE_BIT = 54, CPUID_AESNI_BIT = 57, - CPUID_AVX_BIT = 60 + CPUID_AVX_BIT = 60, + CPUID_RDRAND_BIT = 61 }; static bool x86_processor_flags_has(u64bit bit) |