diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | gmp-impl.h | 30 | ||||
-rw-r--r-- | mpz/export.c | 13 |
3 files changed, 15 insertions, 32 deletions
@@ -5,6 +5,10 @@ * mpz/oddfac_1.c: Use the ASSERT_CODE macro. * gen-trialdivtab.c (mpz_log2): Use mpz_sizeinbase (., 2). + * gmp-impl.h (MPN_SIZEINBASE_16): Replace with MPN_SIZEINBASE_2EXP + from mpz/export.c . + * mpz/export.c (MPN_SIZEINBASE_2EXP): Removed. + 2012-06-23 Marc Glisse <marc.glisse@inria.fr> * gmpxx.h (numeric_limits): Make content public. diff --git a/gmp-impl.h b/gmp-impl.h index ce86c3b69..2f5e4ff68 100644 --- a/gmp-impl.h +++ b/gmp-impl.h @@ -2810,7 +2810,7 @@ __GMP_DECLSPEC extern const struct bases mp_bases[257]; #define MPN_SIZEINBASE(result, ptr, size, base) \ do { \ - int __lb_base, __cnt; \ + int __lb_base, __cnt; \ size_t __totbits; \ \ ASSERT ((size) >= 0); \ @@ -2838,26 +2838,18 @@ __GMP_DECLSPEC extern const struct bases mp_bases[257]; } \ } while (0) -/* eliminate mp_bases lookups for base==16 */ -#define MPN_SIZEINBASE_16(result, ptr, size) \ - do { \ - int __cnt; \ - mp_size_t __totbits; \ - \ - ASSERT ((size) >= 0); \ - \ - /* Special case for X == 0. */ \ - if ((size) == 0) \ - (result) = 1; \ - else \ - { \ - /* Calculate the total number of significant bits of X. */ \ - count_leading_zeros (__cnt, (ptr)[(size)-1]); \ - __totbits = (size_t) (size) * GMP_NUMB_BITS - (__cnt - GMP_NAIL_BITS);\ - (result) = (__totbits + 4 - 1) / 4; \ - } \ +#define MPN_SIZEINBASE_2EXP(result, ptr, size, base2exp) \ + do { \ + int __cnt; \ + mp_bitcnt_t __totbits; \ + ASSERT ((size) > 0); \ + ASSERT ((ptr)[(size)-1] != 0); \ + count_leading_zeros (__cnt, (ptr)[(size)-1]); \ + __totbits = (mp_bitcnt_t) (size) * GMP_NUMB_BITS - (__cnt - GMP_NAIL_BITS); \ + (result) = (__totbits + (base2exp)-1) / (base2exp); \ } while (0) + /* bit count to limb count, rounding up */ #define BITS_TO_LIMBS(n) (((n) + (GMP_NUMB_BITS - 1)) / GMP_NUMB_BITS) diff --git a/mpz/export.c b/mpz/export.c index 674ab7fda..d7903e385 100644 --- a/mpz/export.c +++ b/mpz/export.c @@ -34,19 +34,6 @@ static const mp_limb_t endian_test = (CNST_LIMB(1) << (GMP_LIMB_BITS-7)) - 1; #define HOST_ENDIAN (* (signed char *) &endian_test) #endif - -#define MPN_SIZEINBASE_2EXP(result, ptr, size, base2exp) \ - do { \ - int __cnt; \ - unsigned long __totbits; \ - ASSERT ((size) > 0); \ - ASSERT ((ptr)[(size)-1] != 0); \ - count_leading_zeros (__cnt, (ptr)[(size)-1]); \ - __totbits = (size) * GMP_NUMB_BITS - (__cnt - GMP_NAIL_BITS); \ - (result) = (__totbits + (base2exp)-1) / (base2exp); \ - } while (0) - - void * mpz_export (void *data, size_t *countp, int order, size_t size, int endian, size_t nail, mpz_srcptr z) |