Mercurial > hg > xemacs-beta
comparison src/number.c @ 2551:9f70af3ac939
[xemacs-hg @ 2005-02-03 16:14:02 by james]
Commit Olivier Galibert's dumper updates for bignums and use them.
See xemacs-patches message with ID <ps8y685c6p.fsf@diannao.ittc.ku.edu>.
author | james |
---|---|
date | Thu, 03 Feb 2005 16:14:08 +0000 |
parents | 3d8143fc88e1 |
children | ae5285944c74 |
comparison
equal
deleted
inserted
replaced
2550:317f30471f4e | 2551:9f70af3ac939 |
---|---|
62 bignum_hash (Lisp_Object obj, int UNUSED (depth)) | 62 bignum_hash (Lisp_Object obj, int UNUSED (depth)) |
63 { | 63 { |
64 return bignum_hashcode (XBIGNUM_DATA (obj)); | 64 return bignum_hashcode (XBIGNUM_DATA (obj)); |
65 } | 65 } |
66 | 66 |
67 static void | |
68 bignum_convert (const void *object, void **data, Bytecount *size) | |
69 { | |
70 CIbyte *bstr = bignum_to_string (*(bignum *)object, 10); | |
71 *data = bstr; | |
72 *size = strlen(bstr)+1; | |
73 } | |
74 | |
75 static void | |
76 bignum_convfree (const void * UNUSED (object), void *data, | |
77 Bytecount UNUSED (size)) | |
78 { | |
79 xfree (data, void *); | |
80 } | |
81 | |
82 static void * | |
83 bignum_deconvert (void *object, void *data, Bytecount UNUSED (size)) | |
84 { | |
85 bignum *b = (bignum *) object; | |
86 bignum_init(*b); | |
87 bignum_set_string(*b, (const char *) data, 10); | |
88 return object; | |
89 } | |
90 | |
91 static const struct opaque_convert_functions bignum_opc = { | |
92 bignum_convert, | |
93 bignum_convfree, | |
94 bignum_deconvert | |
95 }; | |
96 | |
67 static const struct memory_description bignum_description[] = { | 97 static const struct memory_description bignum_description[] = { |
68 { XD_OPAQUE_PTR, offsetof (Lisp_Bignum, data) }, | 98 { XD_OPAQUE_DATA_CONVERTIBLE, offsetof (Lisp_Bignum, data), |
99 0, { &bignum_opc }, XD_FLAG_NO_KKCC }, | |
69 { XD_END } | 100 { XD_END } |
70 }; | 101 }; |
71 | 102 |
72 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("bignum", bignum, 0, 0, bignum_print, | 103 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("bignum", bignum, 1, 0, bignum_print, |
73 0, bignum_equal, bignum_hash, | 104 0, bignum_equal, bignum_hash, |
74 bignum_description, Lisp_Bignum); | 105 bignum_description, Lisp_Bignum); |
75 | 106 |
76 #endif /* HAVE_BIGNUM */ | 107 #endif /* HAVE_BIGNUM */ |
77 | 108 |
768 This is determined by the underlying library used to implement bigfloats. | 799 This is determined by the underlying library used to implement bigfloats. |
769 */); | 800 */); |
770 | 801 |
771 #ifdef HAVE_BIGFLOAT | 802 #ifdef HAVE_BIGFLOAT |
772 #ifdef HAVE_BIGNUM | 803 #ifdef HAVE_BIGNUM |
773 /* Uncomment the next two lines and remove the line below them when dumping | |
774 bignums becomes possible. */ | |
775 /* | |
776 Vbigfloat_max_prec = make_bignum (0L); | 804 Vbigfloat_max_prec = make_bignum (0L); |
777 bignum_set_ulong (XBIGNUM_DATA (Vbigfloat_max_prec), ULONG_MAX); | 805 bignum_set_ulong (XBIGNUM_DATA (Vbigfloat_max_prec), ULONG_MAX); |
778 */ | |
779 Vbigfloat_max_prec = make_int (EMACS_INT_MAX); | |
780 #else | 806 #else |
781 Vbigfloat_max_prec = make_int (EMACS_INT_MAX); | 807 Vbigfloat_max_prec = make_int (EMACS_INT_MAX); |
782 #endif | 808 #endif |
783 #else | 809 #else |
784 Vbigfloat_max_prec = make_int (0); | 810 Vbigfloat_max_prec = make_int (0); |