diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-08-21 00:06:00 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-08-21 00:11:45 -0700 |
commit | 39fee209942ab7c35b4789f0010264cd6a52197b (patch) | |
tree | 96f1858c890436713ba0da0fca93d1f33d7dd33a /src/floatfns.c | |
parent | 3881542edeac3e94291c2ce574edf0b0e52764a8 (diff) | |
download | emacs-39fee209942ab7c35b4789f0010264cd6a52197b.tar.gz |
Be more careful about pointers to bignum vals
This uses ‘const’ to be better at catching bugs that
mistakenly attempt to modify a bignum value.
Lisp bignums are supposed to be immutable.
* src/alloc.c (make_pure_bignum):
* src/fns.c (sxhash_bignum):
Accept Lisp_Object instead of struct Lisp_Bignum *, as that’s
simpler now. Caller changed.
* src/bignum.h (bignum_val, xbignum_val): New inline functions.
Prefer them to &i->value and XBIGNUM (i)->value, since they
apply ‘const’ to the result.
* src/timefns.c (lisp_to_timespec): Use mpz_t const *
to point to a bignum value.
Diffstat (limited to 'src/floatfns.c')
-rw-r--r-- | src/floatfns.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/floatfns.c b/src/floatfns.c index a913aad5aac..0a85df47dec 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -268,9 +268,9 @@ DEFUN ("abs", Fabs, Sabs, 1, 1, 0, } else { - if (mpz_sgn (XBIGNUM (arg)->value) < 0) + if (mpz_sgn (*xbignum_val (arg)) < 0) { - mpz_neg (mpz[0], XBIGNUM (arg)->value); + mpz_neg (mpz[0], *xbignum_val (arg)); arg = make_integer_mpz (); } } @@ -315,7 +315,7 @@ This is the same as the exponent of a float. */) value = ivalue - 1; } else if (!FIXNUMP (arg)) - value = mpz_sizeinbase (XBIGNUM (arg)->value, 2) - 1; + value = mpz_sizeinbase (*xbignum_val (arg), 2) - 1; else { EMACS_INT i = XFIXNUM (arg); |