diff options
author | lloyd <[email protected]> | 2008-09-29 22:05:58 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-29 22:05:58 +0000 |
commit | a9f685f7694792a15ba68d6dfe08aa10f9102606 (patch) | |
tree | d8673829fd9b39df284323cc864fbfe75b8cb977 | |
parent | efc4ec9b46cf774daffc08e279014a0761547b35 (diff) |
Set a preprocessor flag if we think the compiler supports GCC-style
inline asm (currently, if __GNUG__ is defined, which works with both
GNU C++ and Intel C++, which are the only two compilers I know of that
accept GCC's inline asm syntax). Use that in bswap.h - previously we
would try to use inline asm even with VC++ or other compilers not supporting
inline asm.
-rw-r--r-- | src/build-data/buildh.in | 8 | ||||
-rw-r--r-- | src/utils/bswap.h | 6 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in index b0ffc87a1..3f56ab6f3 100644 --- a/src/build-data/buildh.in +++ b/src/build-data/buildh.in @@ -34,6 +34,14 @@ Modules #define BOTAN_KARAT_MUL_THRESHOLD 32 #define BOTAN_KARAT_SQR_THRESHOLD 32 +#ifdef __GNUG__ + #define BOTAN_COMPILER_HAS_GCC_INLINE_ASM 1 +#endif + +#ifndef BOTAN_COMPILER_HAS_GCC_INLINE_ASM + #define BOTAN_COMPILER_HAS_GCC_INLINE_ASM 0 +#endif + #ifndef BOTAN_DLL #define BOTAN_DLL @{var:dll_export_flags} #endif diff --git a/src/utils/bswap.h b/src/utils/bswap.h index 3a2b32f3c..cee9a1e84 100644 --- a/src/utils/bswap.h +++ b/src/utils/bswap.h @@ -21,7 +21,9 @@ inline u16bit reverse_bytes(u16bit input) inline u32bit reverse_bytes(u32bit input) { -#if defined(BOTAN_TARGET_ARCH_IS_IA32) || defined(BOTAN_TARGET_ARCH_IS_AMD64) +#if BOTAN_COMPILER_HAS_GCC_INLINE_ASM && + (defined(BOTAN_TARGET_ARCH_IS_IA32) || defined(BOTAN_TARGET_ARCH_IS_AMD64)) + asm("bswapl %0" : "=r" (input) : "0" (input)); return input; #else @@ -32,7 +34,7 @@ inline u32bit reverse_bytes(u32bit input) inline u64bit reverse_bytes(u64bit input) { -#if defined(BOTAN_TARGET_ARCH_IS_AMD64) +#if BOTAN_COMPILER_HAS_GCC_INLINE_ASM && defined(BOTAN_TARGET_ARCH_IS_AMD64) asm("bswapq %0" : "=r" (input) : "0" (input)); return input; #else |