User: james
Date: 06/05/10 17:03:41
Modified: xemacs/src number.c number.h ChangeLog
Log:
Fix bignum arithmetic on 64-bit platforms. See xemacs-patches message with ID
<m364kg9nnq.fsf(a)jerrypc.cs.usu.edu>.
Revision Changes Path
1.17 +2 -2 XEmacs/xemacs/src/number.c
Index: number.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/number.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -p -r1.16 -r1.17
--- number.c 2005/10/25 11:16:26 1.16
+++ number.c 2006/05/10 15:03:35 1.17
@@ -408,9 +408,9 @@ Return the canonical form of NUMBER.
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);
}
1.5 +10 -0 XEmacs/xemacs/src/number.h
Index: number.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/number.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -p -r1.4 -r1.5
--- number.h 2004/05/21 20:56:32 1.4
+++ number.h 2006/05/10 15:03:35 1.5
@@ -100,6 +100,16 @@ DECLARE_LRECORD (bignum, Lisp_Bignum);
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;
1.959 +7 -0 XEmacs/xemacs/src/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.958
retrieving revision 1.959
diff -u -p -r1.958 -r1.959
--- ChangeLog 2006/05/09 10:40:07 1.958
+++ ChangeLog 2006/05/10 15:03:35 1.959
@@ -1,3 +1,10 @@
+2006-05-08 Jerry James <james(a)xemacs.org>
+
+ * 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 <stephen(a)xemacs.org>
* objects-x.c (x_initialize_font_instance):
Show replies by date