summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-11-10 12:46:22 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2015-11-10 12:52:26 -0800
commit0e0ea300ff926d3e2f6f4d514d9115f1eecc8ddb (patch)
tree3f7b95a5cf1d1c1fefe0d48b606bf2fcdf2a8a7b
parent6c16c9a649ab5a5ea4bec12345fd369752da5dc0 (diff)
downloademacs-0e0ea300ff926d3e2f6f4d514d9115f1eecc8ddb.tar.gz
Move INTEGER_TO_CONS body out of .h file
* src/data.c (INTBIG_TO_LISP): New macro, with most of the contents of the old INTEGER_TO_CONS. (intbig_to_lisp, uintbig_to_lisp): New functions. * src/lisp.h (INTEGER_TO_CONS): Simplify by using EXPR_SIGNED and the new functions. This shrinks code size a bit, and makes it easier to put a breakpoint on handling of large integers.
-rw-r--r--src/data.c27
-rw-r--r--src/lisp.h14
2 files changed, 30 insertions, 11 deletions
diff --git a/src/data.c b/src/data.c
index ccec15f430a..51546044c68 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2409,6 +2409,33 @@ DEFUN ("/=", Fneq, Sneq, 2, 2, 0,
return arithcompare (num1, num2, ARITH_NOTEQUAL);
}
+/* Convert the integer I to a cons-of-integers, where I is not in
+ fixnum range. */
+
+#define INTBIG_TO_LISP(i, extremum) \
+ (eassert (FIXNUM_OVERFLOW_P (i)), \
+ (! (FIXNUM_OVERFLOW_P ((extremum) >> 16) \
+ && FIXNUM_OVERFLOW_P ((i) >> 16)) \
+ ? Fcons (make_number ((i) >> 16), make_number ((i) & 0xffff)) \
+ : ! (FIXNUM_OVERFLOW_P ((extremum) >> 16 >> 24) \
+ && FIXNUM_OVERFLOW_P ((i) >> 16 >> 24)) \
+ ? Fcons (make_number ((i) >> 16 >> 24), \
+ Fcons (make_number ((i) >> 16 & 0xffffff), \
+ make_number ((i) & 0xffff))) \
+ : make_float (i)))
+
+Lisp_Object
+intbig_to_lisp (intmax_t i)
+{
+ return INTBIG_TO_LISP (i, INTMAX_MIN);
+}
+
+Lisp_Object
+uintbig_to_lisp (uintmax_t i)
+{
+ return INTBIG_TO_LISP (i, UINTMAX_MAX);
+}
+
/* Convert the cons-of-integers, integer, or float value C to an
unsigned value with maximum value MAX. Signal an error if C does not
have a valid format or is out of range. */
diff --git a/src/lisp.h b/src/lisp.h
index 784ab18c0ee..c782f0dd003 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3345,17 +3345,9 @@ extern Lisp_Object arithcompare (Lisp_Object num1, Lisp_Object num2,
#define INTEGER_TO_CONS(i) \
(! FIXNUM_OVERFLOW_P (i) \
? make_number (i) \
- : ! ((FIXNUM_OVERFLOW_P (INTMAX_MIN >> 16) \
- || FIXNUM_OVERFLOW_P (UINTMAX_MAX >> 16)) \
- && FIXNUM_OVERFLOW_P ((i) >> 16)) \
- ? Fcons (make_number ((i) >> 16), make_number ((i) & 0xffff)) \
- : ! ((FIXNUM_OVERFLOW_P (INTMAX_MIN >> 16 >> 24) \
- || FIXNUM_OVERFLOW_P (UINTMAX_MAX >> 16 >> 24)) \
- && FIXNUM_OVERFLOW_P ((i) >> 16 >> 24)) \
- ? Fcons (make_number ((i) >> 16 >> 24), \
- Fcons (make_number ((i) >> 16 & 0xffffff), \
- make_number ((i) & 0xffff))) \
- : make_float (i))
+ : EXPR_SIGNED (i) ? intbig_to_lisp (i) : uintbig_to_lisp (i))
+extern Lisp_Object intbig_to_lisp (intmax_t);
+extern Lisp_Object uintbig_to_lisp (uintmax_t);
/* Convert the Emacs representation CONS back to an integer of type
TYPE, storing the result the variable VAR. Signal an error if CONS