summaryrefslogtreecommitdiff
path: root/Build/source/libs/mpfr/mpfr-src/src/mpfr-gmp.h
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/mpfr-gmp.h')
-rw-r--r--Build/source/libs/mpfr/mpfr-src/src/mpfr-gmp.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/mpfr-gmp.h b/Build/source/libs/mpfr/mpfr-src/src/mpfr-gmp.h
index 098fd956f44..4cae6254860 100644
--- a/Build/source/libs/mpfr/mpfr-src/src/mpfr-gmp.h
+++ b/Build/source/libs/mpfr/mpfr-src/src/mpfr-gmp.h
@@ -468,14 +468,22 @@ void *alloca (size_t);
and outputs may overlap.
*/
#ifndef udiv_qr_3by2
-#define udiv_qr_3by2(q, r1, r0, n2, n1, n0, d1, d0, dinv) \
+# ifdef MPFR_USE_MINI_GMP
+/* Avoid integer overflow on int in case of integer promotion
+ (when mp_limb_t is shorter than int). Note that unsigned long
+ may be longer than necessary, but GCC seems to optimize. */
+# define OP_CAST (unsigned long)
+# else
+# define OP_CAST
+# endif
+# define udiv_qr_3by2(q, r1, r0, n2, n1, n0, d1, d0, dinv) \
do { \
mp_limb_t _q0, _t1, _t0, _mask; \
umul_ppmm ((q), _q0, (n2), (dinv)); \
add_ssaaaa ((q), _q0, (q), _q0, (n2), (n1)); \
\
/* Compute the two most significant limbs of n - q'd */ \
- (r1) = (n1) - (d1) * (q); \
+ (r1) = (n1) - OP_CAST (d1) * (q); \
(r0) = (n0); \
sub_ddmmss ((r1), (r0), (r1), (r0), (d1), (d0)); \
umul_ppmm (_t1, _t0, (d0), (q)); \