From 4e7a1d52b1a0c04d0c64bcc199dba3ce8921a8c7 Mon Sep 17 00:00:00 2001 From: Marco Bodrato Date: Tue, 11 Dec 2018 01:46:32 +0100 Subject: bootstrap.c (mpz_invert_ui_2exp): support exotic limb size in mini- --- bootstrap.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'bootstrap.c') 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); + } + } -- cgit v1.2.1