diff options
-rw-r--r-- | src/mpfr-impl.h | 25 | ||||
-rw-r--r-- | tests/random2.c | 5 | ||||
-rw-r--r-- | tests/tests.c | 1 |
3 files changed, 15 insertions, 16 deletions
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h index 1237198dc..5d337297e 100644 --- a/src/mpfr-impl.h +++ b/src/mpfr-impl.h @@ -1168,18 +1168,6 @@ typedef uintmax_t mpfr_ueexp_t; ****************** Limb macros ********************* ******************************************************/ -/* Definition of simple mp_limb_t constants */ -#define MPFR_LIMB_ZERO ((mp_limb_t) 0) -#define MPFR_LIMB_ONE ((mp_limb_t) 1) -#define MPFR_LIMB_HIGHBIT (MPFR_LIMB_ONE << (GMP_NUMB_BITS - 1)) -#define MPFR_LIMB_MAX ((mp_limb_t) -1) - -/* Mask to get the Most Significant Bit of a limb */ -#define MPFR_LIMB_MSB(l) ((l) & MPFR_LIMB_HIGHBIT) - -/* Mask for the low 's' bits of a limb */ -#define MPFR_LIMB_MASK(s) ((MPFR_LIMB_ONE << (s)) - MPFR_LIMB_ONE) - /* MPFR_LIMB: Cast to mp_limb_t, assuming that x is based on mp_limb_t variables (needed when mp_limb_t is defined as an integer type shorter than int, due to the integer promotion rules, which is possible only @@ -1203,6 +1191,19 @@ typedef uintmax_t mpfr_ueexp_t; #define MPFR_LIMB_LSHIFT(x,c) MPFR_LIMB((unsigned long) (x) << (c)) #endif +/* Definition of simple mp_limb_t constants */ +#define MPFR_LIMB_ZERO ((mp_limb_t) 0) +#define MPFR_LIMB_ONE ((mp_limb_t) 1) +#define MPFR_LIMB_HIGHBIT MPFR_LIMB_LSHIFT (MPFR_LIMB_ONE, GMP_NUMB_BITS - 1) +#define MPFR_LIMB_MAX ((mp_limb_t) -1) + +/* Mask to get the Most Significant Bit of a limb */ +#define MPFR_LIMB_MSB(l) ((mp_limb_t) ((l) & MPFR_LIMB_HIGHBIT)) + +/* Mask for the low 's' bits of a limb */ +#define MPFR_LIMB_MASK(s) \ + ((mp_limb_t) (MPFR_LIMB_LSHIFT (MPFR_LIMB_ONE, s) - MPFR_LIMB_ONE)) + /****************************************************** ********************** Memory ********************** ******************************************************/ diff --git a/tests/random2.c b/tests/random2.c index f7f423291..df4b743ac 100644 --- a/tests/random2.c +++ b/tests/random2.c @@ -95,8 +95,7 @@ mpfr_random2 (mpfr_ptr x, mp_size_t size, mpfr_exp_t exp, /* Generate a string of nb ones. */ if (nb > bit_pos) { - xp[ri--] = acc | - (MPFR_LIMB_LSHIFT (MPFR_LIMB_ONE, bit_pos + 1) - 1); + xp[ri--] = acc | MPFR_LIMB_MASK (bit_pos + 1); bit_pos += GMP_NUMB_BITS; bit_pos -= nb; acc = MPFR_LIMB_LSHIFT (MPFR_LIMB_MAX, bit_pos + 1); @@ -104,7 +103,7 @@ mpfr_random2 (mpfr_ptr x, mp_size_t size, mpfr_exp_t exp, else { bit_pos -= nb; - acc |= (((mp_limb_t) 2 << nb) - 2) << bit_pos; + acc |= MPFR_LIMB_LSHIFT (MPFR_LIMB_MASK (nb), bit_pos + 1); } } else diff --git a/tests/tests.c b/tests/tests.c index c9259d54f..82b08109e 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -191,7 +191,6 @@ test_version (void) version = mpfr_get_version (); if (strcmp (MPFR_VERSION_STRING, version) == 0) { - char buffer[16]; int i; sprintf (buffer, "%d.%d.%d", MPFR_VERSION_MAJOR, MPFR_VERSION_MINOR, |