emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 0e0ea30: Move INTEGER_TO_CONS body out of .h file


From: Paul Eggert
Subject: [Emacs-diffs] master 0e0ea30: Move INTEGER_TO_CONS body out of .h file
Date: Tue, 10 Nov 2015 20:52:30 +0000

branch: master
commit 0e0ea300ff926d3e2f6f4d514d9115f1eecc8ddb
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 src/data.c |   27 +++++++++++++++++++++++++++
 src/lisp.h |   14 +++-----------
 2 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/src/data.c b/src/data.c
index ccec15f..5154604 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 784ab18..c782f0d 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]