[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bignum branch
From: |
Tom Tromey |
Subject: |
Re: bignum branch |
Date: |
Mon, 06 Aug 2018 18:36:45 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux) |
>>>>> "Andy" == Andy Moreton <address@hidden> writes:
Andy> purecopy also needs updating tosupport bignums
Did you have a use for this? It seems like there must not be any
bignums being dumped currently, since if there were, surely something
would fail.
Anyway, if you do have a use, could you try the appended?
Andy> and also the macros in .gdbinit.
This doesn't seem like a must-have to me; but if it is, I think it would
be best to start by writing pretty-printers to submit to GMP.
Tom
diff --git a/src/alloc.c b/src/alloc.c
index 367bb73fc1..dba90e7eb2 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5535,6 +5535,28 @@ make_pure_float (double num)
return new;
}
+/* Value is a bignum object with value VALUE allocated from pure
+ space. */
+
+static Lisp_Object
+make_pure_bignum (struct Lisp_Bignum *value)
+{
+ Lisp_Object new;
+ size_t nbytes = value->value[0]._mp_alloc * sizeof (mp_limb_t);
+
+ struct Lisp_Bignum *b = pure_alloc (sizeof (struct Lisp_Bignum), Lisp_Misc);
+ b->type = Lisp_Misc_Bignum;
+
+ /* An mpz_t is an array of one element, so this is the correct way
+ to copy the contents. */
+ b->value[0] = value->value[0];
+
+ b->value[0]._mp_d = pure_alloc (nbytes, -1);
+ memcpy (b->value[0]._mp_d, value->value[0]._mp_d, nbytes);
+
+ XSETMISC (new, b);
+ return new;
+}
/* Return a vector with room for LEN Lisp_Objects allocated from
pure space. */
@@ -5676,6 +5698,8 @@ purecopy (Lisp_Object obj)
/* Don't hash-cons it. */
return obj;
}
+ else if (BIGNUMP (obj))
+ obj = make_pure_bignum (XBIGNUM (obj));
else
{
AUTO_STRING (fmt, "Don't know how to purify: %S");
- Re: bignum branch, (continued)
- Re: bignum branch, Achim Gratz, 2018/08/04
- Re: bignum branch, Tom Tromey, 2018/08/04
- Re: bignum branch, Achim Gratz, 2018/08/04
- Re: bignum branch, Eli Zaretskii, 2018/08/04
- Re: bignum branch, Andy Moreton, 2018/08/04
- Re: bignum branch, Tom Tromey, 2018/08/04
- Re: bignum branch, Robert Pluim, 2018/08/06
- Re: bignum branch,
Tom Tromey <=
- Re: bignum branch, Andy Moreton, 2018/08/07
- Re: bignum branch, Tom Tromey, 2018/08/07
- Re: bignum branch, Tom Tromey, 2018/08/04
Re: bignum branch, Tom Tromey, 2018/08/03
- Re: bignum branch, Andy Moreton, 2018/08/03
- Re: bignum branch, Eli Zaretskii, 2018/08/04
- Re: bignum branch, Andy Moreton, 2018/08/05
- Re: bignum branch, Eli Zaretskii, 2018/08/05
- Re: bignum branch, Andy Moreton, 2018/08/06
- Re: bignum branch, Tom Tromey, 2018/08/06