diff options
| author | Paul Eggert | 2019-08-21 00:06:00 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-08-21 00:11:45 -0700 |
| commit | 39fee209942ab7c35b4789f0010264cd6a52197b (patch) | |
| tree | 96f1858c890436713ba0da0fca93d1f33d7dd33a /src/floatfns.c | |
| parent | 3881542edeac3e94291c2ce574edf0b0e52764a8 (diff) | |
| download | emacs-39fee209942ab7c35b4789f0010264cd6a52197b.tar.gz emacs-39fee209942ab7c35b4789f0010264cd6a52197b.zip | |
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, | |||
| 268 | } | 268 | } |
| 269 | else | 269 | else |
| 270 | { | 270 | { |
| 271 | if (mpz_sgn (XBIGNUM (arg)->value) < 0) | 271 | if (mpz_sgn (*xbignum_val (arg)) < 0) |
| 272 | { | 272 | { |
| 273 | mpz_neg (mpz[0], XBIGNUM (arg)->value); | 273 | mpz_neg (mpz[0], *xbignum_val (arg)); |
| 274 | arg = make_integer_mpz (); | 274 | arg = make_integer_mpz (); |
| 275 | } | 275 | } |
| 276 | } | 276 | } |
| @@ -315,7 +315,7 @@ This is the same as the exponent of a float. */) | |||
| 315 | value = ivalue - 1; | 315 | value = ivalue - 1; |
| 316 | } | 316 | } |
| 317 | else if (!FIXNUMP (arg)) | 317 | else if (!FIXNUMP (arg)) |
| 318 | value = mpz_sizeinbase (XBIGNUM (arg)->value, 2) - 1; | 318 | value = mpz_sizeinbase (*xbignum_val (arg), 2) - 1; |
| 319 | else | 319 | else |
| 320 | { | 320 | { |
| 321 | EMACS_INT i = XFIXNUM (arg); | 321 | EMACS_INT i = XFIXNUM (arg); |