diff options
author | Jack Lloyd <[email protected]> | 2019-01-01 08:50:58 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-01-01 08:50:58 -0500 |
commit | 1c04648f9b226e34e7a8c29e4466e7baf6fe3100 (patch) | |
tree | 3b609808b1f70c210d769db978487f0b4067930c /src/lib | |
parent | 08169bf624ec46658654dab4a31dd2d295d739b9 (diff) | |
parent | 3f1ed406b1f54326891663008139b0889662225e (diff) |
Merge GH #1803 XLC fixes
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/math/mp/mp_madd.h | 2 | ||||
-rw-r--r-- | src/lib/utils/bswap.h | 16 | ||||
-rw-r--r-- | src/lib/utils/compiler.h | 8 | ||||
-rw-r--r-- | src/lib/utils/mul128.h | 2 | ||||
-rw-r--r-- | src/lib/utils/rotate.h | 2 |
5 files changed, 19 insertions, 11 deletions
diff --git a/src/lib/math/mp/mp_madd.h b/src/lib/math/mp/mp_madd.h index 43c769c7c..630b75488 100644 --- a/src/lib/math/mp/mp_madd.h +++ b/src/lib/math/mp/mp_madd.h @@ -38,7 +38,7 @@ namespace Botan { #define BOTAN_MP_USE_X86_32_MSVC_ASM #endif -#elif defined(BOTAN_TARGET_ARCH_IS_X86_64) && (BOTAN_MP_WORD_BITS == 64) && (BOTAN_USE_GCC_INLINE_ASM) +#elif defined(BOTAN_TARGET_ARCH_IS_X86_64) && (BOTAN_MP_WORD_BITS == 64) && defined(BOTAN_USE_GCC_INLINE_ASM) #define BOTAN_MP_USE_X86_64_ASM #endif diff --git a/src/lib/utils/bswap.h b/src/lib/utils/bswap.h index 03bebfefa..02f63c64e 100644 --- a/src/lib/utils/bswap.h +++ b/src/lib/utils/bswap.h @@ -1,6 +1,6 @@ /* * Byte Swapping Operations -* (C) 1999-2011 Jack Lloyd +* (C) 1999-2011,2018 Jack Lloyd * (C) 2007 Yves Jerschow * * Botan is released under the Simplified BSD License (see license.txt) @@ -22,7 +22,7 @@ namespace Botan { */ inline uint16_t reverse_bytes(uint16_t val) { -#if defined(BOTAN_BUILD_COMPILER_IS_GCC) || defined(BOTAN_BUILD_COMPILER_IS_CLANG) +#if defined(BOTAN_BUILD_COMPILER_IS_GCC) || defined(BOTAN_BUILD_COMPILER_IS_CLANG) || defined(BOTAN_BUILD_COMPILER_IS_XLC) return __builtin_bswap16(val); #else return static_cast<uint16_t>((val << 8) | (val >> 8)); @@ -34,7 +34,7 @@ inline uint16_t reverse_bytes(uint16_t val) */ inline uint32_t reverse_bytes(uint32_t val) { -#if defined(BOTAN_BUILD_COMPILER_IS_GCC) || defined(BOTAN_BUILD_COMPILER_IS_CLANG) +#if defined(BOTAN_BUILD_COMPILER_IS_GCC) || defined(BOTAN_BUILD_COMPILER_IS_CLANG) || defined(BOTAN_BUILD_COMPILER_IS_XLC) return __builtin_bswap32(val); #elif defined(BOTAN_BUILD_COMPILER_IS_MSVC) @@ -47,10 +47,14 @@ inline uint32_t reverse_bytes(uint32_t val) return val; #else - // Generic implementation - return (rotr<8>(val) & 0xFF00FF00) | (rotl<8>(val) & 0x00FF00FF); + uint16_t hi = static_cast<uint16_t>(val >> 16); + uint16_t lo = static_cast<uint16_t>(val); + + hi = reverse_bytes(hi); + lo = reverse_bytes(lo); + return (static_cast<uint32_t>(lo) << 16) | hi; #endif } @@ -59,7 +63,7 @@ inline uint32_t reverse_bytes(uint32_t val) */ inline uint64_t reverse_bytes(uint64_t val) { -#if defined(BOTAN_BUILD_COMPILER_IS_GCC) || defined(BOTAN_BUILD_COMPILER_IS_CLANG) +#if defined(BOTAN_BUILD_COMPILER_IS_GCC) || defined(BOTAN_BUILD_COMPILER_IS_CLANG) || defined(BOTAN_BUILD_COMPILER_IS_XLC) return __builtin_bswap64(val); #elif defined(BOTAN_BUILD_COMPILER_IS_MSVC) diff --git a/src/lib/utils/compiler.h b/src/lib/utils/compiler.h index 0a2503513..4f736ae6c 100644 --- a/src/lib/utils/compiler.h +++ b/src/lib/utils/compiler.h @@ -13,8 +13,12 @@ #define BOTAN_UTIL_COMPILER_FLAGS_H_ /* Should we use GCC-style inline assembler? */ -#if !defined(BOTAN_USE_GCC_INLINE_ASM) && (defined(__GNUC__) || defined(__xlc__) || defined(__SUNPRO_CC)) - #define BOTAN_USE_GCC_INLINE_ASM 1 +#if defined(BOTAN_BUILD_COMPILER_IS_GCC) || \ + defined(BOTAN_BUILD_COMPILER_IS_CLANG) || \ + defined(BOTAN_BUILD_COMPILER_IS_XLC) || \ + defined(BOTAN_BUILD_COMPILER_IS_SUN_STUDIO) + + #define BOTAN_USE_GCC_INLINE_ASM #endif /** diff --git a/src/lib/utils/mul128.h b/src/lib/utils/mul128.h index 1e2808254..ce1ef693b 100644 --- a/src/lib/utils/mul128.h +++ b/src/lib/utils/mul128.h @@ -12,7 +12,7 @@ namespace Botan { -#if defined(__SIZEOF_INT128__) && defined(BOTAN_TARGET_CPU_HAS_NATIVE_64BIT) && !defined(__xlc__) +#if defined(__SIZEOF_INT128__) && defined(BOTAN_TARGET_CPU_HAS_NATIVE_64BIT) #define BOTAN_TARGET_HAS_NATIVE_UINT128 // Prefer TI mode over __int128 as GCC rejects the latter in pendantic mode diff --git a/src/lib/utils/rotate.h b/src/lib/utils/rotate.h index d927b93b7..16a44c71e 100644 --- a/src/lib/utils/rotate.h +++ b/src/lib/utils/rotate.h @@ -60,7 +60,7 @@ inline T rotr_var(T input, size_t rot) return rot ? static_cast<T>((input >> rot) | (input << (sizeof(T)*8 - rot))) : input; } -#if BOTAN_USE_GCC_INLINE_ASM +#if defined(BOTAN_USE_GCC_INLINE_ASM) #if defined(BOTAN_TARGET_ARCH_IS_X86_64) || defined(BOTAN_TARGET_ARCH_IS_X86_32) |