diff options
author | Kevin Ryde <user42@zip.com.au> | 2002-09-12 00:32:37 +0200 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2002-09-12 00:32:37 +0200 |
commit | 7569ac948c4f5cf9e2257cdcaced619586a220b1 (patch) | |
tree | 577017701f3e7c3bd70a6699547ff43129d75fbd /mpz/aorsmul_i.c | |
parent | c1950b80ae754477efdb95baca48296dc08fff76 (diff) | |
download | gmp-7569ac948c4f5cf9e2257cdcaced619586a220b1.tar.gz |
* mpz/aorsmul_i.c: Fix w==x overlap with nails. Test
BITS_PER_ULONG >= GMP_NUMB_BITS rather than GMP_NAIL_BITS != 0.
Diffstat (limited to 'mpz/aorsmul_i.c')
-rw-r--r-- | mpz/aorsmul_i.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/mpz/aorsmul_i.c b/mpz/aorsmul_i.c index 13a50181d..17b85113f 100644 --- a/mpz/aorsmul_i.c +++ b/mpz/aorsmul_i.c @@ -194,9 +194,8 @@ mpz_aorsmul_1 (mpz_ptr w, mpz_srcptr x, mp_limb_t y, mp_size_t sub) void mpz_addmul_ui (mpz_ptr w, mpz_srcptr x, unsigned long y) { - mpz_aorsmul_1 (w, x, (mp_limb_t) y & GMP_NUMB_MASK, (mp_size_t) 0); -#if GMP_NAIL_BITS != 0 - if (y > GMP_NUMB_MAX && SIZ(x) != 0) +#if BITS_PER_ULONG > GMP_NUMB_BITS + if (UNLIKELY (y > GMP_NUMB_MAX && SIZ(x) != 0)) { mpz_t t; mp_ptr tp; @@ -210,16 +209,20 @@ mpz_addmul_ui (mpz_ptr w, mpz_srcptr x, unsigned long y) MPN_COPY (tp + 1, PTR(x), ABS (xn)); SIZ(t) = xn >= 0 ? xn + 1 : xn - 1; mpz_aorsmul_1 (w, t, (mp_limb_t) y >> GMP_NUMB_BITS, (mp_size_t) 0); + PTR(t) = tp + 1; + SIZ(t) = xn; + mpz_aorsmul_1 (w, t, (mp_limb_t) y & GMP_NUMB_MASK, (mp_size_t) 0); TMP_FREE (mark); + return; } #endif + mpz_aorsmul_1 (w, x, (mp_limb_t) y, (mp_size_t) 0); } void mpz_submul_ui (mpz_ptr w, mpz_srcptr x, unsigned long y) { - mpz_aorsmul_1 (w, x, (mp_limb_t) y & GMP_NUMB_MASK, (mp_size_t) -1); -#if GMP_NAIL_BITS != 0 +#if BITS_PER_ULONG > GMP_NUMB_BITS if (y > GMP_NUMB_MAX && SIZ(x) != 0) { mpz_t t; @@ -234,7 +237,12 @@ mpz_submul_ui (mpz_ptr w, mpz_srcptr x, unsigned long y) MPN_COPY (tp + 1, PTR(x), ABS (xn)); SIZ(t) = xn >= 0 ? xn + 1 : xn - 1; mpz_aorsmul_1 (w, t, (mp_limb_t) y >> GMP_NUMB_BITS, (mp_size_t) -1); + PTR(t) = tp + 1; + SIZ(t) = xn; + mpz_aorsmul_1 (w, t, (mp_limb_t) y & GMP_NUMB_MASK, (mp_size_t) -1); TMP_FREE (mark); + return; } #endif + mpz_aorsmul_1 (w, x, (mp_limb_t) y & GMP_NUMB_MASK, (mp_size_t) -1); } |