diff --git a/include/polarssl/bignum.h b/include/polarssl/bignum.h index 9cf61a3fc3..b4a6c06379 100644 --- a/include/polarssl/bignum.h +++ b/include/polarssl/bignum.h @@ -109,25 +109,41 @@ typedef UINT64 uint64_t; typedef signed char t_sint; typedef unsigned char t_uint; typedef uint16_t t_udbl; +#define POLARSSL_HAVE_UDBL #else #if defined(POLARSSL_HAVE_INT16) typedef int16_t t_sint; typedef uint16_t t_uint; typedef uint32_t t_udbl; +#define POLARSSL_HAVE_UDBL #else - typedef int32_t t_sint; - typedef uint32_t t_uint; - #if ( defined(_MSC_VER) && defined(_M_IX86) ) || \ - ( defined(__GNUC__) && ( \ - defined(__amd64__) || defined(__x86_64__) || \ - defined(__ppc64__) || defined(__powerpc64__) || \ - defined(__ia64__) || defined(__alpha__) || \ - (defined(__sparc__) && defined(__arch64__)) || \ - defined(__s390x__) ) ) - #define POLARSSL_HAVE_INT64 - #endif - #if defined(POLARSSL_HAVE_INT64) - typedef uint64_t t_udbl; + #if ( defined(__MSC_VER) && defined(_M_AMD64) ) + typedef int64_t t_sint; + typedef uint64_t t_uint; + #else + #if ( defined(__GNUC__) && ( \ + defined(__amd64__) || defined(__x86_64__) || \ + defined(__ppc64__) || defined(__powerpc64__) || \ + defined(__ia64__) || defined(__alpha__) || \ + (defined(__sparc__) && defined(__arch64__)) || \ + defined(__s390x__) ) ) + typedef int64_t t_sint; + typedef uint64_t t_uint; + typedef unsigned int t_udbl __attribute__((mode(TI))); + #define POLARSSL_HAVE_UDBL + #else + typedef int32_t t_sint; + typedef uint32_t t_uint; + #if ( defined(_MSC_VER) && defined(_M_IX86) ) + typedef uint64_t t_udbl; + #define POLARSSL_HAVE_UDBL + #else + #if defined( POLARSSL_HAVE_LONGLONG ) + typedef unsigned long long t_udbl; + #define POLARSSL_HAVE_UDBL + #endif + #endif + #endif #endif #endif /* POLARSSL_HAVE_INT16 */ #endif /* POLARSSL_HAVE_INT8 */ diff --git a/include/polarssl/config.h b/include/polarssl/config.h index 4781d2c9df..c251eab705 100644 --- a/include/polarssl/config.h +++ b/include/polarssl/config.h @@ -61,14 +61,12 @@ */ /** - * \def POLARSSL_HAVE_INT64 + * \def POLARSSL_HAVE_LONGLONG * - * The compiler supports the use of 64-bit types. - * Code automatically enables on known working systems. - * - * Uncomment if the compiler supports 64-bit data types. -#define POLARSSL_HAVE_INT64 + * The compiler supports the 'long long' type. + * (Only used on 32-bit platforms) */ +#define POLARSSL_HAVE_LONGLONG /** * \def POLARSSL_HAVE_ASM diff --git a/library/bignum.c b/library/bignum.c index 60a8df42ec..0008748881 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -1102,7 +1102,7 @@ int mpi_div_mpi( mpi *Q, mpi *R, const mpi *A, const mpi *B ) Z.p[i - t - 1] = ~0; else { -#if defined(POLARSSL_HAVE_INT64) +#if defined(POLARSSL_HAVE_UDBL) t_udbl r; r = (t_udbl) X.p[i] << biL;