aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 60850f73d51..ddc0696ba91 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3785,18 +3785,21 @@ make_number (mpz_t value)
3785void 3785void
3786mpz_set_intmax_slow (mpz_t result, intmax_t v) 3786mpz_set_intmax_slow (mpz_t result, intmax_t v)
3787{ 3787{
3788 /* If long is larger then a faster path is taken. */ 3788 /* If V fits in long, a faster path is taken. */
3789 eassert (sizeof (intmax_t) > sizeof (long)); 3789 eassert (! (LONG_MIN <= v && v <= LONG_MAX));
3790 3790
3791 bool complement = v < 0; 3791 bool complement = v < 0;
3792 if (complement) 3792 if (complement)
3793 v = -1 - v; 3793 v = -1 - v;
3794 3794
3795 /* COUNT = 1 means just a single word of the given size. ORDER = -1 3795 enum { nails = sizeof v * CHAR_BIT - INTMAX_WIDTH };
3796 is arbitrary since there's only a single word. ENDIAN = 0 means 3796# ifndef HAVE_GMP
3797 use the native endian-ness. NAILS = 0 means use the whole 3797 /* mini-gmp requires NAILS to be zero, which is true for all
3798 word. */ 3798 likely Emacs platforms. Sanity-check this. */
3799 mpz_import (result, 1, -1, sizeof v, 0, 0, &v); 3799 verify (nails == 0);
3800# endif
3801
3802 mpz_import (result, 1, -1, sizeof v, 0, nails, &v);
3800 if (complement) 3803 if (complement)
3801 mpz_com (result, result); 3804 mpz_com (result, result);
3802} 3805}