summaryrefslogtreecommitdiff
path: root/Build/source/libs/mpfr/mpfr-src/src/ui_div.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/ui_div.c')
-rw-r--r--Build/source/libs/mpfr/mpfr-src/src/ui_div.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/ui_div.c b/Build/source/libs/mpfr/mpfr-src/src/ui_div.c
index 23b5cdf0d7b..03629555e19 100644
--- a/Build/source/libs/mpfr/mpfr-src/src/ui_div.c
+++ b/Build/source/libs/mpfr/mpfr-src/src/ui_div.c
@@ -1,6 +1,6 @@
/* mpfr_ui_div -- divide a machine integer by a floating-point number
-Copyright 2000-2019 Free Software Foundation, Inc.
+Copyright 2000-2020 Free Software Foundation, Inc.
Contributed by the AriC and Caramba projects, INRIA.
This file is part of the GNU MPFR Library.
@@ -66,23 +66,38 @@ mpfr_ui_div (mpfr_ptr y, unsigned long int u, mpfr_srcptr x, mpfr_rnd_t rnd_mode
}
else if (MPFR_LIKELY(u != 0))
{
- mpfr_t uu;
- mp_limb_t up[1];
- int cnt;
int inex;
-
MPFR_SAVE_EXPO_DECL (expo);
- MPFR_TMP_INIT1(up, uu, GMP_NUMB_BITS);
- MPFR_ASSERTN(u == (mp_limb_t) u);
- count_leading_zeros(cnt, (mp_limb_t) u);
- up[0] = (mp_limb_t) u << cnt;
-
/* Optimization note: Exponent save/restore operations may be
removed if mpfr_div works even when uu is out-of-range. */
MPFR_SAVE_EXPO_MARK (expo);
- MPFR_SET_EXP (uu, GMP_NUMB_BITS - cnt);
+
+#ifdef MPFR_LONG_WITHIN_LIMB
+ {
+ mpfr_t uu;
+ mp_limb_t up[1];
+ int cnt;
+
+ MPFR_TMP_INIT1(up, uu, GMP_NUMB_BITS);
+ MPFR_ASSERTN(u == (mp_limb_t) u);
+ count_leading_zeros(cnt, (mp_limb_t) u);
+ up[0] = (mp_limb_t) u << cnt;
+
+ MPFR_SET_EXP (uu, GMP_NUMB_BITS - cnt);
+ inex = mpfr_div (y, uu, x, rnd_mode);
+ }
+#else
+ {
+ mpfr_t uu;
+
+ mpfr_init2 (uu, sizeof (unsigned long) * CHAR_BIT);
+ mpfr_set_ui (uu, u, MPFR_RNDZ);
inex = mpfr_div (y, uu, x, rnd_mode);
+ mpfr_clear (uu);
+ }
+#endif
+
MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
MPFR_SAVE_EXPO_FREE (expo);
return mpfr_check_range (y, inex, rnd_mode);