diff lisp/cl-macs.el @ 5379:a32a108ae815

#'cl-non-fixnum-number-p: return t for integers > #x3fffffff and < -#x40000000 2011-03-21 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (cl-non-fixnum-number-p): This should return t under 64-bit builds for fixnums that would be bignums on a 32-bit machine; make it so.
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 21 Mar 2011 12:19:25 +0000
parents 4b529b940e2e
children 919c77c567bb
line wrap: on
line diff
--- a/lisp/cl-macs.el	Sat Mar 19 22:13:14 2011 +0900
+++ b/lisp/cl-macs.el	Mon Mar 21 12:19:25 2011 +0000
@@ -3230,14 +3230,26 @@
 			argns argvs)))
       (if lets (list 'let lets body) body))))
 
+;; When a 64-bit build is byte-compiling code, some of its native fixnums
+;; will not be represented as fixnums if the byte-compiled code is read by
+;; the Lisp reader in a 32-bit build. So in that case we need to check the
+;; range of fixnums as well as their types. XEmacs doesn't support machines
+;; with word size less than 32, so it's OK to have that as the minimum.
+(macrolet
+    ((most-negative-fixnum-on-32-bit-machines () (lognot (1- (lsh 1 30))))
+     (most-positive-fixnum-on-32-bit-machines () (lsh 1 30)))
+  (defun cl-non-fixnum-number-p (object)
+    "Return t if OBJECT is a number not guaranteed to be immediate."
+    (and (numberp object)
+	 (or (not (fixnump object))
+	     (not (<= (most-negative-fixnum-on-32-bit-machines)
+		      object
+		      (most-positive-fixnum-on-32-bit-machines)))))))
 
 ;;; Compile-time optimizations for some functions defined in this package.
 ;;; Note that cl.el arranges to force cl-macs to be loaded at compile-time,
 ;;; mainly to make sure these macros will be present.
 
-(defun cl-non-fixnum-number-p (object)
-  (and (numberp object) (not (fixnump object))))
-
 (define-compiler-macro eql (&whole form a b)
   (cond ((eq (cl-const-expr-p a) t)
 	 (let ((val (cl-const-expr-val a)))