py: Allow MPZ_DIG_SIZE to be optionally configured by a port.

This commit is contained in:
Damien George 2015-03-28 21:45:57 +00:00
parent 567184e21e
commit 3f327cc4c6

View File

@ -39,22 +39,37 @@
// unsigned versions. // unsigned versions.
// //
// MPZ_DIG_SIZE can be between 4 and 8*sizeof(mpz_dig_t), but it makes most // MPZ_DIG_SIZE can be between 4 and 8*sizeof(mpz_dig_t), but it makes most
// sense to have it as large as possible. Below, the type is auto-detected // sense to have it as large as possible. If MPZ_DIG_SIZE is not already
// depending on the machine, but it (and MPZ_DIG_SIZE) can be freely changed so // defined then it is auto-detected below, depending on the machine. The types
// long as the constraints mentioned above are met. // are then set based on the value of MPZ_DIG_SIZE (although they can be freely
// changed so long as the constraints mentioned above are met).
#if defined(__x86_64__) || defined(_WIN64) #ifndef MPZ_DIG_SIZE
// 64-bit machine, using 32-bit storage for digits #if defined(__x86_64__) || defined(_WIN64)
// 64-bit machine, using 32-bit storage for digits
#define MPZ_DIG_SIZE (32)
#else
// default: 32-bit machine, using 16-bit storage for digits
#define MPZ_DIG_SIZE (16)
#endif
#endif
#if MPZ_DIG_SIZE > 16
typedef uint32_t mpz_dig_t; typedef uint32_t mpz_dig_t;
typedef uint64_t mpz_dbl_dig_t; typedef uint64_t mpz_dbl_dig_t;
typedef int64_t mpz_dbl_dig_signed_t; typedef int64_t mpz_dbl_dig_signed_t;
#define MPZ_DIG_SIZE (32) #elif MPZ_DIG_SIZE > 8
#else
// 32-bit machine, using 16-bit storage for digits
typedef uint16_t mpz_dig_t; typedef uint16_t mpz_dig_t;
typedef uint32_t mpz_dbl_dig_t; typedef uint32_t mpz_dbl_dig_t;
typedef int32_t mpz_dbl_dig_signed_t; typedef int32_t mpz_dbl_dig_signed_t;
#define MPZ_DIG_SIZE (16) #elif MPZ_DIG_SIZE > 4
typedef uint8_t mpz_dig_t;
typedef uint16_t mpz_dbl_dig_t;
typedef int16_t mpz_dbl_dig_signed_t;
#else
typedef uint8_t mpz_dig_t;
typedef uint8_t mpz_dbl_dig_t;
typedef int8_t mpz_dbl_dig_signed_t;
#endif #endif
#ifdef _WIN64 #ifdef _WIN64