diff options
author | lloyd <[email protected]> | 2011-03-14 18:51:34 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-03-14 18:51:34 +0000 |
commit | 252c78549f5e887b3136facb49a64b932efcd59a (patch) | |
tree | 7320b0702c255af692011279302ba5f39bde3330 | |
parent | ca8f8c06efc9ac95d2e4b2fc68988486aa2b2e0a (diff) |
Prefer GCC builtin except on ARM, add comment as to why
-rw-r--r-- | src/utils/bswap.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/utils/bswap.h b/src/utils/bswap.h index 389adc0b8..66a230d46 100644 --- a/src/utils/bswap.h +++ b/src/utils/bswap.h @@ -31,7 +31,17 @@ inline u16bit reverse_bytes(u16bit val) */ inline u32bit reverse_bytes(u32bit val) { -#if BOTAN_USE_GCC_INLINE_ASM && defined(BOTAN_TARGET_CPU_IS_X86_FAMILY) +#if BOTAN_GCC_VERSION >= 430 && !defined(BOTAN_TARGET_CPU_IS_ARM_FAMILY) + /* + GCC intrinsic added in 4.3, works for a number of CPUs + + However avoid under ARM, as it branches to a function in libgcc + instead of generating inline asm, so slower even than the generic + rotate version below. + */ + return __builtin_bswap32(val); + +#elif BOTAN_USE_GCC_INLINE_ASM && defined(BOTAN_TARGET_CPU_IS_X86_FAMILY) // GCC-style inline assembly for x86 or x86-64 asm("bswapl %0" : "=r" (val) : "0" (val)); @@ -49,11 +59,6 @@ inline u32bit reverse_bytes(u32bit val) return val; -#elif BOTAN_GCC_VERSION >= 430 - - // GCC intrinsic added in 4.3, works for a number of CPUs - return __builtin_bswap32(val); - #elif defined(_MSC_VER) && defined(BOTAN_TARGET_ARCH_IS_IA32) // Visual C++ inline asm for 32-bit x86, by Yves Jerschow |