diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2018-12-11 01:46:32 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2018-12-11 01:46:32 +0100 |
commit | 4e7a1d52b1a0c04d0c64bcc199dba3ce8921a8c7 (patch) | |
tree | 5df00d640604d5a6ca094f80523ca1ce11d2a8ad /bootstrap.c | |
parent | e3d5d2c0417970a72d401e5f96244f915f2f6f50 (diff) | |
download | gmp-4e7a1d52b1a0c04d0c64bcc199dba3ce8921a8c7.tar.gz |
bootstrap.c (mpz_invert_ui_2exp): support exotic limb size in mini-
Diffstat (limited to 'bootstrap.c')
-rw-r--r-- | bootstrap.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/bootstrap.c b/bootstrap.c index 2dd6dc06c..ab349c70c 100644 --- a/bootstrap.c +++ b/bootstrap.c @@ -136,8 +136,17 @@ mpz_invert_2exp (mpz_t r, const mpz_t a, unsigned long n) /* Calculate inv satisfying r*a == 1 mod 2^n. */ void -mpz_invert_ui_2exp (mpz_t r, mp_limb_t a, unsigned long n) +mpz_invert_ui_2exp (mpz_t r, unsigned long a, unsigned long n) { mpz_t az; - mpz_invert_2exp (r, mpz_roinit_n (az, &a, 1), n); + + if (sizeof (mp_limb_t) == sizeof (unsigned long)) + mpz_invert_2exp (r, mpz_roinit_n (az, (mp_srcptr) &a, 1), n); + else + { + mpz_init_set_ui (az, a); + mpz_invert_2exp (r, az, n); + mpz_clear (az); + } + } |