# HG changeset patch # User james # Date 1147273415 0 # Node ID 639cdee384e471609f67ada2c3f42989895ed961 # Parent 1a44d3ebacc1531f954d28fefae6e7f4daf5d7e6 [xemacs-hg @ 2006-05-10 15:03:35 by james] Fix bignum arithmetic on 64-bit platforms. See xemacs-patches message with ID . diff -r 1a44d3ebacc1 -r 639cdee384e4 src/ChangeLog --- a/src/ChangeLog Tue May 09 21:51:20 2006 +0000 +++ b/src/ChangeLog Wed May 10 15:03:35 2006 +0000 @@ -1,3 +1,10 @@ +2006-05-08 Jerry James + + * number.c (Fcanonicalize_number): Use EMACS_INT instead of int, + which fixes bignum arithmetic on 64-bit platforms. + * number.h (bignum_fits_emacs_int_p): New macro. + * number.h (bignum_to_emacs_int): New macro. + 2006-03-30 Stephen J. Turnbull * objects-x.c (x_initialize_font_instance): diff -r 1a44d3ebacc1 -r 639cdee384e4 src/number.c --- a/src/number.c Tue May 09 21:51:20 2006 +0000 +++ b/src/number.c Wed May 10 15:03:35 2006 +0000 @@ -408,9 +408,9 @@ number = make_bignum_bg (XRATIO_NUMERATOR (number)); #endif #ifdef HAVE_BIGNUM - if (BIGNUMP (number) && bignum_fits_int_p (XBIGNUM_DATA (number))) + if (BIGNUMP (number) && bignum_fits_emacs_int_p (XBIGNUM_DATA (number))) { - int n = bignum_to_int (XBIGNUM_DATA (number)); + EMACS_INT n = bignum_to_emacs_int (XBIGNUM_DATA (number)); if (NUMBER_FITS_IN_AN_EMACS_INT (n)) number = make_int (n); } diff -r 1a44d3ebacc1 -r 639cdee384e4 src/number.h --- a/src/number.h Tue May 09 21:51:20 2006 +0000 +++ b/src/number.h Wed May 10 15:03:35 2006 +0000 @@ -100,6 +100,16 @@ return Fcanonicalize_number (retval); \ } while (0) +#if SIZEOF_EMACS_INT == SIZEOF_LONG +# define bignum_fits_emacs_int_p(b) bignum_fits_long_p(b) +# define bignum_to_emacs_int(b) bignum_to_long(b) +#elif SIZEOF_EMACS_INT == SIZEOF_INT +# define bignum_fits_emacs_int_p(b) bignum_fits_int_p(b) +# define bignum_to_emacs_int(b) bignum_to_int(b) +#else +# error Bignums currently do not work with long long Emacs integers. +#endif + extern Lisp_Object make_bignum (long); extern Lisp_Object make_bignum_bg (bignum); extern bignum scratch_bignum, scratch_bignum2;