diff options
author | lloyd <[email protected]> | 2012-05-07 18:31:30 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-05-07 18:31:30 +0000 |
commit | de405c6e32b62d1c88afa9cd9e374780d0821ccb (patch) | |
tree | 77104c3baa1e3c3114f9e8b0a149455033ff4608 /src | |
parent | 4d45c02af30e2f920954997c5786d748803d2f5a (diff) |
Markus Wanner pointed out on the mailing list that using rdrand opcode
didn't work on older GCC/binutils. Instead hardcode the expression for
rdrand %eax, which should work everywhere. Also, avoid including immintrin.h
unless we're going to use it, to avoid problems with older compilers that
lack that header (this caused build failures under GCC 3.4.6).
Diffstat (limited to 'src')
-rw-r--r-- | src/entropy/rdrand/rdrand.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/entropy/rdrand/rdrand.cpp b/src/entropy/rdrand/rdrand.cpp index 72abd6166..51b2bd5f6 100644 --- a/src/entropy/rdrand/rdrand.cpp +++ b/src/entropy/rdrand/rdrand.cpp @@ -7,7 +7,10 @@ #include <botan/internal/rdrand.h> #include <botan/cpuid.h> -#include <immintrin.h> + +#if !defined(BOTAN_USE_GCC_INLINE_ASM) + #include <immintrin.h> +#endif namespace Botan { @@ -41,8 +44,10 @@ void Intel_Rdrand::poll(Entropy_Accumulator& accum) #if BOTAN_USE_GCC_INLINE_ASM int cf = 0; - asm("rdrand %0; adcl $0,%1" : - "=r" (r), "=r" (cf) : "0" (r), "1" (cf) : "cc"); + + // Encoding of rdrand %eax + asm(".byte 0x0F, 0xC7, 0xF0; adcl $0,%1" : + "=a" (r), "=r" (cf) : "0" (r), "1" (cf) : "cc"); #else int cf = _rdrand32_step(&r); #endif |