diff options
author | stijn <stinos@zoho.com> | 2014-10-30 14:39:22 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-30 23:00:24 +0000 |
commit | 0e557facb93425e791a23a6695b202e467a60026 (patch) | |
tree | 676380dea63edff840b6f6345466394478171255 /py/mpz.h | |
parent | e62a0fe36776f039149e7fab77323aa380b97c2e (diff) | |
download | micropython-0e557facb93425e791a23a6695b202e467a60026.tar.gz micropython-0e557facb93425e791a23a6695b202e467a60026.zip |
mpz: Fix 64bit msvc build
msvc does not treat 1L a 64bit integer hence all occurences of shifting it left or right
result in undefined behaviour since the maximum allowed shift count for 32bit ints is 31.
Forcing the correct type explicitely, stored in MPZ_LONG_1, solves this.
Diffstat (limited to 'py/mpz.h')
-rw-r--r-- | py/mpz.h | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -36,7 +36,7 @@ // depending on the machine, but it (and MPZ_DIG_SIZE) can be freely changed so // long as the constraints mentioned above are met. -#if defined(__x86_64__) +#if defined(__x86_64__) || defined(_WIN64) // 64-bit machine, using 32-bit storage for digits typedef uint32_t mpz_dig_t; typedef uint64_t mpz_dbl_dig_t; @@ -50,6 +50,12 @@ typedef int32_t mpz_dbl_dig_signed_t; #define MPZ_DIG_SIZE (16) #endif +#ifdef _WIN64 + #define MPZ_LONG_1 1i64 +#else + #define MPZ_LONG_1 1L +#endif + #define MPZ_NUM_DIG_FOR_INT (sizeof(mp_int_t) * 8 / MPZ_DIG_SIZE + 1) #define MPZ_NUM_DIG_FOR_LL (sizeof(long long) * 8 / MPZ_DIG_SIZE + 1) |