diff options
-rw-r--r-- | src/lib/math/mp/mp_generic/mp_madd.h | 21 | ||||
-rw-r--r-- | src/lib/math/mp/mp_types.h | 13 | ||||
-rw-r--r-- | src/lib/utils/mul128.h | 12 |
3 files changed, 27 insertions, 19 deletions
diff --git a/src/lib/math/mp/mp_generic/mp_madd.h b/src/lib/math/mp/mp_generic/mp_madd.h index 292c23e97..3b0487356 100644 --- a/src/lib/math/mp/mp_generic/mp_madd.h +++ b/src/lib/math/mp/mp_generic/mp_madd.h @@ -13,6 +13,27 @@ namespace Botan { +#if (BOTAN_MP_WORD_BITS == 8) + typedef u16bit dword; + #define BOTAN_HAS_MP_DWORD +#elif (BOTAN_MP_WORD_BITS == 16) + typedef u32bit dword; + #define BOTAN_HAS_MP_DWORD +#elif (BOTAN_MP_WORD_BITS == 32) + typedef u64bit dword; + #define BOTAN_HAS_MP_DWORD +#elif (BOTAN_MP_WORD_BITS == 64) + + #include <botan/mul128.h> + + #if defined(BOTAN_TARGET_HAS_NATIVE_UINT128) + typedef uint128_t dword; + #define BOTAN_HAS_MP_DWORD + #endif +#else + #error BOTAN_MP_WORD_BITS must be 8, 16, 32, or 64 +#endif + /* * Word Multiply/Add */ diff --git a/src/lib/math/mp/mp_types.h b/src/lib/math/mp/mp_types.h index eab0d0c6c..69dc911fd 100644 --- a/src/lib/math/mp/mp_types.h +++ b/src/lib/math/mp/mp_types.h @@ -9,30 +9,17 @@ #define BOTAN_MPI_TYPES_H__ #include <botan/types.h> -#include <botan/mul128.h> namespace Botan { #if (BOTAN_MP_WORD_BITS == 8) typedef byte word; - typedef u16bit dword; - #define BOTAN_HAS_MP_DWORD #elif (BOTAN_MP_WORD_BITS == 16) typedef u16bit word; - typedef u32bit dword; - #define BOTAN_HAS_MP_DWORD #elif (BOTAN_MP_WORD_BITS == 32) typedef u32bit word; - typedef u64bit dword; - #define BOTAN_HAS_MP_DWORD #elif (BOTAN_MP_WORD_BITS == 64) typedef u64bit word; - - #if defined(BOTAN_TARGET_HAS_NATIVE_UINT128) - typedef uint128_t dword; - #define BOTAN_HAS_MP_DWORD - #endif - #else #error BOTAN_MP_WORD_BITS must be 8, 16, 32, or 64 #endif diff --git a/src/lib/utils/mul128.h b/src/lib/utils/mul128.h index 3ad7dbcdb..bcf5fa7ef 100644 --- a/src/lib/utils/mul128.h +++ b/src/lib/utils/mul128.h @@ -1,6 +1,6 @@ /* * 64x64->128 bit multiply operation -* (C) 2013 Jack Lloyd +* (C) 2013,2015 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ @@ -12,13 +12,13 @@ namespace Botan { -#if defined(__SIZEOF_INT128__) - #define BOTAN_TARGET_HAS_NATIVE_UINT128 - typedef unsigned __int128 uint128_t; - -#elif (BOTAN_GCC_VERSION > 440) && defined(BOTAN_TARGET_CPU_HAS_NATIVE_64BIT) +// Prefer TI mode over __int128 as GCC rejects the latter in pendantic mode +#if (BOTAN_GCC_VERSION > 440) && defined(BOTAN_TARGET_CPU_HAS_NATIVE_64BIT) #define BOTAN_TARGET_HAS_NATIVE_UINT128 typedef unsigned int uint128_t __attribute__((mode(TI))); +#elif defined(__SIZEOF_INT128__) + #define BOTAN_TARGET_HAS_NATIVE_UINT128 + typedef unsigned __int128 uint128_t; #endif } |