summaryrefslogtreecommitdiff
path: root/Build/source/libs/mpfr/mpfr-src/src/add_ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/add_ui.c')
-rw-r--r--Build/source/libs/mpfr/mpfr-src/src/add_ui.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/add_ui.c b/Build/source/libs/mpfr/mpfr-src/src/add_ui.c
index f7c487ef609..df774950efd 100644
--- a/Build/source/libs/mpfr/mpfr-src/src/add_ui.c
+++ b/Build/source/libs/mpfr/mpfr-src/src/add_ui.c
@@ -1,6 +1,6 @@
/* mpfr_add_ui -- add a floating-point number with a machine integer
-Copyright 2000-2004, 2006-2019 Free Software Foundation, Inc.
+Copyright 2000-2004, 2006-2020 Free Software Foundation, Inc.
Contributed by the AriC and Caramba projects, INRIA.
This file is part of the GNU MPFR Library.
@@ -56,24 +56,38 @@ mpfr_add_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mpfr_rnd_t rnd_mode
/* Main code */
{
- 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_STAT_STATIC_ASSERT (MPFR_LIMB_MAX >= ULONG_MAX);
- /* So, u fits in a mp_limb_t, which justifies the casts below. */
- MPFR_ASSERTD (u != 0);
- 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_add works even when uu is out-of-range. */
MPFR_SAVE_EXPO_MARK (expo);
- MPFR_SET_EXP (uu, GMP_NUMB_BITS - cnt);
- inex = mpfr_add (y, x, uu, rnd_mode);
+
+#ifdef MPFR_LONG_WITHIN_LIMB
+ {
+ mpfr_t uu;
+ mp_limb_t up[1];
+ int cnt;
+
+ MPFR_TMP_INIT1 (up, uu, GMP_NUMB_BITS);
+ /* So, u fits in a mp_limb_t, which justifies the casts below. */
+ MPFR_ASSERTD (u != 0);
+ 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_add (y, x, uu, rnd_mode);
+ }
+#else
+ {
+ mpfr_t uu;
+
+ mpfr_init2 (uu, sizeof (unsigned long) * CHAR_BIT);
+ mpfr_set_ui (uu, u, MPFR_RNDZ);
+ inex = mpfr_add (y, x, uu, 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);