1. Set mp_size_t & mp_exp_t as signed 64-bit integers on Windows x64

This commit is contained in:
gladman 2010-01-05 20:21:32 +00:00
parent 6400809d87
commit 48edb06e9f
4 changed files with 24 additions and 4 deletions

View File

@ -224,6 +224,10 @@ typedef __gmp_const mp_limb_t * mp_srcptr;
#define __GMP_MP_SIZE_T_INT 1
typedef int mp_size_t;
typedef int mp_exp_t;
#elif defined( _MSC_VER )
#define __GMP_MP_SIZE_T_INT 2
typedef intptr_t mp_size_t;
typedef intptr_t mp_exp_t;
#else
#define __GMP_MP_SIZE_T_INT 0
typedef long int mp_size_t;

View File

@ -51,7 +51,7 @@ MA 02110-1301, USA. */
reference, int can be 46 or 64 bits, whereas uint is always 64 bits; and
short can be 24, 32, 46 or 64 bits, and different for ushort. */
#if defined _CRAY
#if defined _CRAY || defined _MSC_VER
#include <limits.h>
#endif
@ -551,7 +551,15 @@ void __gmp_tmp_debug_free _PROTO ((const char *, int, int,
#define SHRT_MAX ((short) (-(SHRT_MIN+1)))
#endif
#if __GMP_MP_SIZE_T_INT
#if __GMP_MP_SIZE_T_INT == 2
# ifdef _WIN64
# define MP_SIZE_T_MAX _I64_MAX
# define MP_SIZE_T_MIN _I64_MIN
# else
# define MP_SIZE_T_MAX LONG_MAX
# define MP_SIZE_T_MIN LONG_MIN
# endif
#elif __GMP_MP_SIZE_T_INT
#define MP_SIZE_T_MAX INT_MAX
#define MP_SIZE_T_MIN INT_MIN
#else

View File

@ -46,7 +46,11 @@ __gmp_default_allocate (size_t size)
ret = malloc (size);
if (ret == 0)
{
#if defined _MSC_VER && defined _WIN64
fprintf (stderr, "GNU MP: Cannot allocate memory (size=%llu)\n", size);
#else
fprintf (stderr, "GNU MP: Cannot allocate memory (size=%u)\n", size);
#endif
abort ();
}
@ -94,7 +98,11 @@ __gmp_default_reallocate (void *oldptr, size_t old_size, size_t new_size)
ret = realloc (oldptr, new_size);
if (ret == 0)
{
fprintf (stderr, "GNU MP: Cannot reallocate memory (old_size=%u new_size=%u)\n", old_size, new_size);
#if defined _MSC_VER && defined _WIN64
fprintf (stderr, "GNU MP: Cannot reallocate memory (old_size=%llu new_size=%llu)\n", old_size, new_size);
#else
fprintf (stderr, "GNU MP: Cannot reallocate memory (old_size=%u new_size=%u)\n", old_size, new_size);
#endif
abort ();
}

View File

@ -79,7 +79,7 @@ mpz_inp_raw (mpz_ptr x, FILE *fp)
Could write "csize -= ((csize & 0x80000000L) << 1)", but that tickles a
bug in gcc 3.0 for powerpc64 on AIX. */
if (sizeof (csize) > 4 && csize & 0x80000000L)
csize -= 0x80000000L << 1;
csize |= (mp_size_t)(-1) << 32;
abs_csize = ABS (csize);