aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorTom Tromey2018-07-07 14:52:09 -0600
committerTom Tromey2018-07-12 22:12:27 -0600
commita0f2adbfc9cb1b69415f551a5e529f7e1162b9c7 (patch)
treeb6bf597a851b4ce521097802071361b7c78c4931 /src/data.c
parent7cb45cd25e510cf3c20adeb9ac11c0c3ea1dd340 (diff)
downloademacs-a0f2adbfc9cb1b69415f551a5e529f7e1162b9c7.tar.gz
emacs-a0f2adbfc9cb1b69415f551a5e529f7e1162b9c7.zip
Introduce the bignum type
* src/alloc.c (mark_object): Handle Lisp_Misc_Bignum. (sweep_misc): Call mpz_clear for Lisp_Misc_Bignum. * src/data.c (Ftype_of): Handle Lisp_Misc_Bignum. (Fintegerp, Finteger_or_marker_p, Fnatnump, Fnumberp) (Fnumber_or_marker_p): Update for bignum. (Ffixnump, Fbignump): New defuns. (syms_of_data): Update. * src/emacs.c (xrealloc_for_gmp, xfree_for_gmp): New functions. (main): Call mp_set_memory_functions. * src/lisp.h (enum Lisp_Misc_Type) <Lisp_Misc_Bignum>: New constant. (struct Lisp_Bignum): New. (union Lisp_Misc): Add u_bignum. (BIGNUMP, XBIGNUM, INTEGERP, NATNUMP, NUMBERP, CHECK_NUMBER) (CHECK_INTEGER, CHECK_NUMBER_COERCE_MARKER): New functions. * src/print.c (print_object): Handle Lisp_Misc_Bignum.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/data.c b/src/data.c
index aad57084647..efcffbbf6ab 100644
--- a/src/data.c
+++ b/src/data.c
@@ -234,6 +234,8 @@ for example, (type-of 1) returns `integer'. */)
234 case Lisp_Misc_User_Ptr: 234 case Lisp_Misc_User_Ptr:
235 return Quser_ptr; 235 return Quser_ptr;
236#endif 236#endif
237 case Lisp_Misc_Bignum:
238 return Qinteger;
237 default: 239 default:
238 emacs_abort (); 240 emacs_abort ();
239 } 241 }
@@ -515,6 +517,16 @@ DEFUN ("integerp", Fintegerp, Sintegerp, 1, 1, 0,
515 attributes: const) 517 attributes: const)
516 (Lisp_Object object) 518 (Lisp_Object object)
517{ 519{
520 if (INTEGERP (object))
521 return Qt;
522 return Qnil;
523}
524
525DEFUN ("fixnump", Ffixnump, Sfixnump, 1, 1, 0,
526 doc: /* Return t if OBJECT is an fixnum. */
527 attributes: const)
528 (Lisp_Object object)
529{
518 if (FIXNUMP (object)) 530 if (FIXNUMP (object))
519 return Qt; 531 return Qt;
520 return Qnil; 532 return Qnil;
@@ -524,7 +536,7 @@ DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1,
524 doc: /* Return t if OBJECT is an integer or a marker (editor pointer). */) 536 doc: /* Return t if OBJECT is an integer or a marker (editor pointer). */)
525 (register Lisp_Object object) 537 (register Lisp_Object object)
526{ 538{
527 if (MARKERP (object) || FIXNUMP (object)) 539 if (MARKERP (object) || INTEGERP (object))
528 return Qt; 540 return Qt;
529 return Qnil; 541 return Qnil;
530} 542}
@@ -534,7 +546,7 @@ DEFUN ("natnump", Fnatnump, Snatnump, 1, 1, 0,
534 attributes: const) 546 attributes: const)
535 (Lisp_Object object) 547 (Lisp_Object object)
536{ 548{
537 if (FIXNATP (object)) 549 if (NATNUMP (object))
538 return Qt; 550 return Qt;
539 return Qnil; 551 return Qnil;
540} 552}
@@ -544,7 +556,7 @@ DEFUN ("numberp", Fnumberp, Snumberp, 1, 1, 0,
544 attributes: const) 556 attributes: const)
545 (Lisp_Object object) 557 (Lisp_Object object)
546{ 558{
547 if (FIXED_OR_FLOATP (object)) 559 if (NUMBERP (object))
548 return Qt; 560 return Qt;
549 else 561 else
550 return Qnil; 562 return Qnil;
@@ -555,7 +567,7 @@ DEFUN ("number-or-marker-p", Fnumber_or_marker_p,
555 doc: /* Return t if OBJECT is a number or a marker. */) 567 doc: /* Return t if OBJECT is a number or a marker. */)
556 (Lisp_Object object) 568 (Lisp_Object object)
557{ 569{
558 if (FIXED_OR_FLOATP (object) || MARKERP (object)) 570 if (NUMBERP (object) || MARKERP (object))
559 return Qt; 571 return Qt;
560 return Qnil; 572 return Qnil;
561} 573}
@@ -597,6 +609,15 @@ DEFUN ("condition-variable-p", Fcondition_variable_p, Scondition_variable_p,
597 return Qt; 609 return Qt;
598 return Qnil; 610 return Qnil;
599} 611}
612
613DEFUN ("bignump", Fbignump, Sbignump, 1, 1, 0,
614 doc: /* Return t if OBJECT is a bignum. */)
615 (Lisp_Object object)
616{
617 if (BIGNUMP (object))
618 return Qt;
619 return Qnil;
620}
600 621
601/* Extract and set components of lists. */ 622/* Extract and set components of lists. */
602 623
@@ -3745,6 +3766,7 @@ syms_of_data (void)
3745 defsubr (&Sconsp); 3766 defsubr (&Sconsp);
3746 defsubr (&Satom); 3767 defsubr (&Satom);
3747 defsubr (&Sintegerp); 3768 defsubr (&Sintegerp);
3769 defsubr (&Sfixnump);
3748 defsubr (&Sinteger_or_marker_p); 3770 defsubr (&Sinteger_or_marker_p);
3749 defsubr (&Snumberp); 3771 defsubr (&Snumberp);
3750 defsubr (&Snumber_or_marker_p); 3772 defsubr (&Snumber_or_marker_p);
@@ -3770,6 +3792,7 @@ syms_of_data (void)
3770 defsubr (&Sthreadp); 3792 defsubr (&Sthreadp);
3771 defsubr (&Smutexp); 3793 defsubr (&Smutexp);
3772 defsubr (&Scondition_variable_p); 3794 defsubr (&Scondition_variable_p);
3795 defsubr (&Sbignump);
3773 defsubr (&Scar); 3796 defsubr (&Scar);
3774 defsubr (&Scdr); 3797 defsubr (&Scdr);
3775 defsubr (&Scar_safe); 3798 defsubr (&Scar_safe);