summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-09-17 09:04:58 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-09-17 09:04:58 +0000
commit2930925c838176d7eba42c94a061b44b76e6a60e (patch)
tree587b76c83b56b245415c04355a4b187af77d988d
parent6d3b2f146c06f4feee390da67efb4cbecf359797 (diff)
downloadmpfr-2930925c838176d7eba42c94a061b44b76e6a60e.tar.gz
[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
-rw-r--r--src/mpfr-impl.h25
1 files 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 **********************
******************************************************/