aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 6a938211599..0cd3f0c0c3b 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3793,28 +3793,17 @@ mpz_set_intmax_slow (mpz_t result, intmax_t v)
3793 /* If long is larger then a faster path is taken. */ 3793 /* If long is larger then a faster path is taken. */
3794 eassert (sizeof (intmax_t) > sizeof (long)); 3794 eassert (sizeof (intmax_t) > sizeof (long));
3795 3795
3796 bool negate = false; 3796 bool complement = v < 0;
3797 if (v < 0) 3797 if (complement)
3798 { 3798 v = -1 - v;
3799 v = -v;
3800 negate = true;
3801 }
3802 mpz_set_uintmax_slow (result, (uintmax_t) v);
3803 if (negate)
3804 mpz_neg (result, result);
3805}
3806
3807void
3808mpz_set_uintmax_slow (mpz_t result, uintmax_t v)
3809{
3810 /* If long is larger then a faster path is taken. */
3811 eassert (sizeof (uintmax_t) > sizeof (unsigned long));
3812 3799
3813 /* COUNT = 1 means just a single word of the given size. ORDER = -1 3800 /* COUNT = 1 means just a single word of the given size. ORDER = -1
3814 is arbitrary since there's only a single word. ENDIAN = 0 means 3801 is arbitrary since there's only a single word. ENDIAN = 0 means
3815 use the native endian-ness. NAILS = 0 means use the whole 3802 use the native endian-ness. NAILS = 0 means use the whole
3816 word. */ 3803 word. */
3817 mpz_import (result, 1, -1, sizeof (uintmax_t), 0, 0, &v); 3804 mpz_import (result, 1, -1, sizeof v, 0, 0, &v);
3805 if (complement)
3806 mpz_com (result, result);
3818} 3807}
3819 3808
3820 3809