summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2012-06-24 19:59:49 +0200
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2012-06-24 19:59:49 +0200
commitd9089b155846f2cad27f9aa990a4a67901305112 (patch)
tree918df3dd67f7b122011047907f18a98b9c81923d
parentef34640f9edc108eb48d5cebe7ad08c7cd2ed945 (diff)
downloadgmp-d9089b155846f2cad27f9aa990a4a67901305112.tar.gz
Replace MPN_SIZEINBASE_16 in gmp-impl.h with MPN_SIZEINBASE_2EXP from mpz/export.c
-rw-r--r--ChangeLog4
-rw-r--r--gmp-impl.h30
-rw-r--r--mpz/export.c13
3 files changed, 15 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 821767dc3..ed41f7f08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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)