From 2930925c838176d7eba42c94a061b44b76e6a60e Mon Sep 17 00:00:00 2001 From: vlefevre Date: Mon, 17 Sep 2018 09:04:58 +0000 Subject: [src/mpfr-impl.h] Improved MPFR_LIMB_* macros for mp_limb_t < int (e.g. 16-bit or 8-bit limb), as in such a case, integer promotion transforms mp_limb_t to int. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13203 280ebfd0-de03-0410-8827-d642c229c3f4 --- src/mpfr-impl.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h index a6493848a..bd3ab22a6 100644 --- a/src/mpfr-impl.h +++ b/src/mpfr-impl.h @@ -1164,18 +1164,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 @@ -1199,6 +1187,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 ********************** ******************************************************/ -- cgit v1.2.1