diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2012-06-24 19:59:49 +0200 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2012-06-24 19:59:49 +0200 |
commit | d9089b155846f2cad27f9aa990a4a67901305112 (patch) | |
tree | 918df3dd67f7b122011047907f18a98b9c81923d /gmp-impl.h | |
parent | ef34640f9edc108eb48d5cebe7ad08c7cd2ed945 (diff) | |
download | gmp-d9089b155846f2cad27f9aa990a4a67901305112.tar.gz |
Replace MPN_SIZEINBASE_16 in gmp-impl.h with MPN_SIZEINBASE_2EXP from mpz/export.c
Diffstat (limited to 'gmp-impl.h')
-rw-r--r-- | gmp-impl.h | 30 |
1 files changed, 11 insertions, 19 deletions
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) |