summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-08-28 20:26:21 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-08-28 20:26:21 +0000
commitaeb267c49e659d1b9308b744930cf4726877eeb9 (patch)
treed7b216918e8e76ba1004a426447fc65001b43b12
parent1b20fa13ea26f6da22860ceb51ca0473d268737e (diff)
downloadmpfr-aeb267c49e659d1b9308b744930cf4726877eeb9.tar.gz
[src/div.c] Avoid an infinite recursion when MPFR_LONG_WITHIN_LIMB
is not defined (mpfr_div calls mpfr_div_ui, which calls mpfr_div). [src/div_ui.c] Made the preprocessor test on MPFR_LONG_WITHIN_LIMB consistent with the ones in the other .c files. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13067 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--src/div.c7
-rw-r--r--src/div_ui.c2
2 files changed, 6 insertions, 3 deletions
diff --git a/src/div.c b/src/div.c
index ed95101ac..4c751c3b1 100644
--- a/src/div.c
+++ b/src/div.c
@@ -864,12 +864,14 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mpfr_rnd_t rnd_mode)
* *
**************************************************************************/
- /* when the divisor has one limb, we can use mpfr_div_ui, which should be
- faster, assuming there is no intermediate overflow or underflow.
+ /* When the divisor has one limb and MPFR_LONG_WITHIN_LIMB is defined,
+ we can use mpfr_div_ui, which should be faster, assuming there is no
+ intermediate overflow or underflow.
The divisor interpreted as an integer satisfies
2^(GMP_NUMB_BITS-1) <= vm < 2^GMP_NUMB_BITS, thus the quotient
satisfies 2^(EXP(u)-1-GMP_NUMB_BITS) < u/vm < 2^(EXP(u)-GMP_NUMB_BITS+1)
and its exponent is either EXP(u)-GMP_NUMB_BITS or one more. */
+#ifdef MPFR_LONG_WITHIN_LIMB
if (vsize <= 1 && __gmpfr_emin <= MPFR_EXP(u) - GMP_NUMB_BITS
&& MPFR_EXP(u) - GMP_NUMB_BITS + 1 <= __gmpfr_emax
&& vp[0] <= ULONG_MAX)
@@ -892,6 +894,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mpfr_rnd_t rnd_mode)
MPFR_EXP(q) += GMP_NUMB_BITS;
return mpfr_check_range (q, inex, rnd_mode);
}
+#endif
MPFR_TMP_MARK(marker);
diff --git a/src/div_ui.c b/src/div_ui.c
index e486e09e9..bde1ead96 100644
--- a/src/div_ui.c
+++ b/src/div_ui.c
@@ -33,7 +33,7 @@ MPFR_HOT_FUNCTION_ATTR int
mpfr_div_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u,
mpfr_rnd_t rnd_mode)
{
-#if MPFR_LONG_WITHIN_LIMB
+#ifdef MPFR_LONG_WITHIN_LIMB
int sh;
mp_size_t i, xn, yn, dif;
mp_limb_t *xp, *yp, *tmp, c, d;