aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-11-10 12:46:22 -0800
committerPaul Eggert2015-11-10 12:52:26 -0800
commit0e0ea300ff926d3e2f6f4d514d9115f1eecc8ddb (patch)
tree3f7b95a5cf1d1c1fefe0d48b606bf2fcdf2a8a7b /src
parent6c16c9a649ab5a5ea4bec12345fd369752da5dc0 (diff)
downloademacs-0e0ea300ff926d3e2f6f4d514d9115f1eecc8ddb.tar.gz
emacs-0e0ea300ff926d3e2f6f4d514d9115f1eecc8ddb.zip
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.
Diffstat (limited to 'src')
-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,
2409 return arithcompare (num1, num2, ARITH_NOTEQUAL); 2409 return arithcompare (num1, num2, ARITH_NOTEQUAL);
2410} 2410}
2411 2411
2412/* Convert the integer I to a cons-of-integers, where I is not in
2413 fixnum range. */
2414
2415#define INTBIG_TO_LISP(i, extremum) \
2416 (eassert (FIXNUM_OVERFLOW_P (i)), \
2417 (! (FIXNUM_OVERFLOW_P ((extremum) >> 16) \
2418 && FIXNUM_OVERFLOW_P ((i) >> 16)) \
2419 ? Fcons (make_number ((i) >> 16), make_number ((i) & 0xffff)) \
2420 : ! (FIXNUM_OVERFLOW_P ((extremum) >> 16 >> 24) \
2421 && FIXNUM_OVERFLOW_P ((i) >> 16 >> 24)) \
2422 ? Fcons (make_number ((i) >> 16 >> 24), \
2423 Fcons (make_number ((i) >> 16 & 0xffffff), \
2424 make_number ((i) & 0xffff))) \
2425 : make_float (i)))
2426
2427Lisp_Object
2428intbig_to_lisp (intmax_t i)
2429{
2430 return INTBIG_TO_LISP (i, INTMAX_MIN);
2431}
2432
2433Lisp_Object
2434uintbig_to_lisp (uintmax_t i)
2435{
2436 return INTBIG_TO_LISP (i, UINTMAX_MAX);
2437}
2438
2412/* Convert the cons-of-integers, integer, or float value C to an 2439/* Convert the cons-of-integers, integer, or float value C to an
2413 unsigned value with maximum value MAX. Signal an error if C does not 2440 unsigned value with maximum value MAX. Signal an error if C does not
2414 have a valid format or is out of range. */ 2441 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,
3345#define INTEGER_TO_CONS(i) \ 3345#define INTEGER_TO_CONS(i) \
3346 (! FIXNUM_OVERFLOW_P (i) \ 3346 (! FIXNUM_OVERFLOW_P (i) \
3347 ? make_number (i) \ 3347 ? make_number (i) \
3348 : ! ((FIXNUM_OVERFLOW_P (INTMAX_MIN >> 16) \ 3348 : EXPR_SIGNED (i) ? intbig_to_lisp (i) : uintbig_to_lisp (i))
3349 || FIXNUM_OVERFLOW_P (UINTMAX_MAX >> 16)) \ 3349extern Lisp_Object intbig_to_lisp (intmax_t);
3350 && FIXNUM_OVERFLOW_P ((i) >> 16)) \ 3350extern Lisp_Object uintbig_to_lisp (uintmax_t);
3351 ? Fcons (make_number ((i) >> 16), make_number ((i) & 0xffff)) \
3352 : ! ((FIXNUM_OVERFLOW_P (INTMAX_MIN >> 16 >> 24) \
3353 || FIXNUM_OVERFLOW_P (UINTMAX_MAX >> 16 >> 24)) \
3354 && FIXNUM_OVERFLOW_P ((i) >> 16 >> 24)) \
3355 ? Fcons (make_number ((i) >> 16 >> 24), \
3356 Fcons (make_number ((i) >> 16 & 0xffffff), \
3357 make_number ((i) & 0xffff))) \
3358 : make_float (i))
3359 3351
3360/* Convert the Emacs representation CONS back to an integer of type 3352/* Convert the Emacs representation CONS back to an integer of type
3361 TYPE, storing the result the variable VAR. Signal an error if CONS 3353 TYPE, storing the result the variable VAR. Signal an error if CONS