diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2015-12-11 07:59:50 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2015-12-11 07:59:50 +0100 |
commit | 9c6bc5e774d77a0746537e6f71aa2b371c62a001 (patch) | |
tree | 00e71d8125709c809040e80582470c6a48c5c5c9 /bootstrap.c | |
parent | f229a86407c317ca660eb1adf654668d94a4cfd8 (diff) | |
download | gmp-9c6bc5e774d77a0746537e6f71aa2b371c62a001.tar.gz |
bootstrap.c: Use clrbit and roinit.
Diffstat (limited to 'bootstrap.c')
-rw-r--r-- | bootstrap.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/bootstrap.c b/bootstrap.c index bff960ed8..11affac00 100644 --- a/bootstrap.c +++ b/bootstrap.c @@ -1,6 +1,6 @@ /* Functions needed for bootstrapping the gmp build, based on mini-gmp. -Copyright 2001, 2002, 2004, 2011, 2012 Free Software Foundation, Inc. +Copyright 2001, 2002, 2004, 2011, 2012, 2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -88,7 +88,7 @@ log2_ceil (int n) /* Set inv to the inverse of d, in the style of invert_limb, ie. for udiv_qrnnd_preinv. */ void -mpz_preinv_invert (mpz_t inv, mpz_t d, int numb_bits) +mpz_preinv_invert (mpz_t inv, const mpz_t d, int numb_bits) { mpz_t t; int norm; @@ -99,16 +99,14 @@ mpz_preinv_invert (mpz_t inv, mpz_t d, int numb_bits) mpz_init_set_ui (t, 1L); mpz_mul_2exp (t, t, 2*numb_bits - norm); mpz_tdiv_q (inv, t, d); - mpz_set_ui (t, 1L); - mpz_mul_2exp (t, t, numb_bits); - mpz_sub (inv, inv, t); + mpz_clrbit (inv, numb_bits); mpz_clear (t); } /* Calculate r satisfying r*d == 1 mod 2^n. */ void -mpz_invert_2exp (mpz_t r, mpz_t a, unsigned long n) +mpz_invert_2exp (mpz_t r, const mpz_t a, unsigned long n) { unsigned long i; mpz_t inv, prod; @@ -137,10 +135,8 @@ mpz_invert_2exp (mpz_t r, mpz_t a, unsigned long n) /* Calculate inv satisfying r*a == 1 mod 2^n. */ void -mpz_invert_ui_2exp (mpz_t r, unsigned long a, unsigned long n) +mpz_invert_ui_2exp (mpz_t r, mp_limb_t a, unsigned long n) { mpz_t az; - mpz_init_set_ui (az, a); - mpz_invert_2exp (r, az, n); - mpz_clear (az); + mpz_invert_2exp (r, mpz_roinit_n (az, &a, 1), n); } |