summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2005-05-18 15:57:10 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2005-05-18 15:57:10 +0000
commitb88c50d268e5e11da7c3363d421246dbb14bc180 (patch)
tree205a24fbfc48e8d135ec15b617d85335a673ad58
parente1bd5aef35c4619b29cf017d8128525d23bbdb56 (diff)
downloadmpfr-b88c50d268e5e11da7c3363d421246dbb14bc180.tar.gz
Replace TMP_ALLOC by MPFR_TMP_ALLOC
Replace TMP_DECL by MPFR_TMP_DECL Replace TMP_MARK by MPFR_TMP_MARK Replace TMP_FREE by MPFR_TMP_FREE Add support for GMP's TMP_SALLOC. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3593 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--add1.c10
-rw-r--r--add1sp.c10
-rw-r--r--agm.c6
-rw-r--r--cos.c6
-rw-r--r--div-short.c16
-rw-r--r--div.c16
-rw-r--r--div_ui.c8
-rw-r--r--exp_2.c24
-rw-r--r--generic.c16
-rw-r--r--get_str.c32
-rw-r--r--init2.c2
-rw-r--r--log.c6
-rw-r--r--mpfr-impl.h33
-rw-r--r--mpn_exp.c10
-rw-r--r--mul.c22
-rw-r--r--mul_ui.c8
-rw-r--r--round_prec.c18
-rw-r--r--set_f.c8
-rw-r--r--sqr.c8
-rw-r--r--sqrt.c8
-rw-r--r--strtofr.c12
-rw-r--r--sub1.c18
-rw-r--r--sub1sp.c22
-rw-r--r--sum.c16
-rw-r--r--tests/tsum.c8
-rw-r--r--tuneup.c22
26 files changed, 189 insertions, 176 deletions
diff --git a/add1.c b/add1.c
index ddd861be7..6fdadf006 100644
--- a/add1.c
+++ b/add1.c
@@ -32,11 +32,11 @@ mpfr_add1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
mp_exp_t difw, exp;
int sh, rb, fb, inex;
mp_exp_unsigned_t diff_exp;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
MPFR_ASSERTD(MPFR_IS_PURE_FP(b) && MPFR_IS_PURE_FP(c));
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
aq = MPFR_PREC(a);
bq = MPFR_PREC(b);
@@ -55,14 +55,14 @@ mpfr_add1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
if (MPFR_UNLIKELY(ap == bp))
{
- bp = (mp_ptr) TMP_ALLOC (bn * BYTES_PER_MP_LIMB);
+ bp = (mp_ptr) MPFR_TMP_ALLOC (bn * BYTES_PER_MP_LIMB);
MPN_COPY (bp, ap, bn);
if (ap == cp)
{ cp = bp; }
}
else if (MPFR_UNLIKELY(ap == cp))
{
- cp = (mp_ptr) TMP_ALLOC (cn * BYTES_PER_MP_LIMB);
+ cp = (mp_ptr) MPFR_TMP_ALLOC (cn * BYTES_PER_MP_LIMB);
MPN_COPY(cp, ap, cn);
}
@@ -537,6 +537,6 @@ mpfr_add1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
MPFR_SET_EXP (a, exp);
end_of_add:
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return inex;
}
diff --git a/add1sp.c b/add1sp.c
index c772b87cd..e11b2bc84 100644
--- a/add1sp.c
+++ b/add1sp.c
@@ -52,9 +52,9 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
mp_exp_t bx;
mp_limb_t limb;
int inexact;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
MPFR_ASSERTD(MPFR_PREC(a) == MPFR_PREC(b) && MPFR_PREC(b) == MPFR_PREC(c));
MPFR_ASSERTD(MPFR_IS_PURE_FP(b) && MPFR_IS_PURE_FP(c));
@@ -162,7 +162,7 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
mp_limb_t bcp, bcp1; /* Cp and C'p+1 */
/* General case: 1 <= d < p */
- cp = (mp_limb_t*) TMP_ALLOC(n * BYTES_PER_MP_LIMB);
+ cp = (mp_limb_t*) MPFR_TMP_ALLOC(n * BYTES_PER_MP_LIMB);
/* Shift c in temporary allocated place */
{
@@ -326,13 +326,13 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
if (MPFR_UNLIKELY(bx > __gmpfr_emax)) /* Check for overflow */
{
DEBUG( printf("Overflow\n") );
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
MPFR_SET_SAME_SIGN(a,b);
return mpfr_overflow(a, rnd_mode, MPFR_SIGN(a));
}
MPFR_SET_EXP (a, bx);
MPFR_SET_SAME_SIGN(a,b);
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return inexact*MPFR_INT_SIGN(a);
}
diff --git a/agm.c b/agm.c
index be691354c..4abe0c629 100644
--- a/agm.c
+++ b/agm.c
@@ -31,7 +31,7 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode)
mp_limb_t *up, *vp, *tmpp;
mpfr_t u, v, tmp;
MPFR_ZIV_DECL (loop);
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
MPFR_LOG_FUNC (("op2[%#R]=%R op1[%#R]=%R rnd=%d", op2,op2,op1,op1,rnd_mode),
("r[%#R]=%R inexact=%d", r, r, inexact));
@@ -99,7 +99,7 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode)
}
/* Now b(=op2) >= a (=op1) */
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
/* Main loop */
MPFR_ZIV_INIT (loop, p);
@@ -159,7 +159,7 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode)
inexact = mpfr_set (r, v, rnd_mode);
/* Let's clean */
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return inexact; /* agm(u,v) can be exact for u, v rational only for u=v.
Proof (due to Nicolas Brisebarre): it suffices to consider
diff --git a/cos.c b/cos.c
index 151ff8bab..99d3ba5f9 100644
--- a/cos.c
+++ b/cos.c
@@ -77,7 +77,7 @@ mpfr_cos (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
mp_exp_t exps, cancel = 0;
MPFR_ZIV_DECL (loop);
MPFR_SAVE_EXPO_DECL (expo);
- TMP_DECL (marker);
+ MPFR_TMP_DECL (marker);
MPFR_LOG_FUNC (("x[%#R]=%R rnd=%d", x, x, rnd_mode),
("y[%#R]=%R inexact=%d", y, y, inexact));
@@ -115,7 +115,7 @@ mpfr_cos (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
else
m += -MPFR_GET_EXP (x);
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
sm = (m + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB;
MPFR_TMP_INIT (rp, r, m, sm);
MPFR_TMP_INIT (sp, s, m, sm);
@@ -177,7 +177,7 @@ mpfr_cos (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
MPFR_ZIV_FREE (loop);
inexact = mpfr_set (y, s, rnd_mode);
- TMP_FREE (marker);
+ MPFR_TMP_FREE (marker);
end:
MPFR_SAVE_EXPO_FREE (expo);
MPFR_RET (mpfr_check_range (y, inexact, rnd_mode));
diff --git a/div-short.c b/div-short.c
index 64479b695..8fcf73e39 100644
--- a/div-short.c
+++ b/div-short.c
@@ -17,17 +17,17 @@ mpn_dc_divrem_n_new (mp_ptr qp, mp_ptr np, mp_srcptr dp, mp_size_t n)
mp_size_t l, m;
mp_limb_t qh, cc, ql;
mp_ptr tmp;
- TMP_DECL (marker);
+ MPFR_TMP_DECL (marker);
l = n / 2;
m = n - l; /* m >= l */
- TMP_MARK (marker);
+ MPFR_TMP_MARK (marker);
qh = DIVREM (qp + l, np + 2 * l, dp + l, m);
/* partial remainder is in {np, 2l+m} = {np, n+l} */
/* subtract Q1 * D0, where Q1 = {qp + l, m}, D0 = {d, l} */
- tmp = TMP_ALLOC_LIMBS (n);
+ tmp = MPFR_TMP_ALLOC_LIMBS (n);
mpn_mul (tmp, qp + l, m, dp, l);
cc = mpn_sub_n (np + l, np + l, tmp, n);
if (qh) cc += mpn_sub_n (np + n, np + n, dp, l);
@@ -43,7 +43,7 @@ mpn_dc_divrem_n_new (mp_ptr qp, mp_ptr np, mp_srcptr dp, mp_size_t n)
/* subtract Q0 * D0', where Q0 = {qp, l}, D0' = {d, m} */
mpn_mul (tmp, dp, m, qp, l);
cc = mpn_sub_n (np, np, tmp, n);
- TMP_FREE (marker);
+ MPFR_TMP_FREE (marker);
if (ql) cc += mpn_sub_n (np + l, np + l, dp, m);
while (cc)
{
@@ -68,21 +68,21 @@ mpn_dc_divrem_n_high (mp_ptr qp, mp_ptr np, mp_srcptr dp, mp_size_t n)
mp_size_t l, m;
mp_limb_t qh, cc, ql;
mp_ptr tmp;
- TMP_DECL (marker);
+ MPFR_TMP_DECL (marker);
l = (n-1) / 2 ;
m = n - l; /* m >= l */
- TMP_MARK (marker);
+ MPFR_TMP_MARK (marker);
qh = DIVREM (qp + l, np + 2 * l, dp + l, m);
/* partial remainder is in {np, 2l+m} = {np, n+l} */
/* subtract Q1 * D0, where Q1 = {qp + l, m}, D0 = {d, l} */
- tmp = TMP_ALLOC_LIMBS (n);
+ tmp = MPFR_TMP_ALLOC_LIMBS (n);
mpn_mul (tmp, qp + l, m, dp, l); /* FIXME: use a short product */
/* mpfr_mulhigh_n (tmp+m+l-2*l, qp+l+m-l, dp, l); */
cc = mpn_sub_n (np + l, np + l, tmp, n);
- TMP_FREE (marker);
+ MPFR_TMP_FREE (marker);
if (qh) cc += mpn_sub_n (np + n, np + n, dp, l);
/* have to subtract cc at np[n+l] */
while (cc)
diff --git a/div.c b/div.c
index 87e3d25d7..9fca6d5e3 100644
--- a/div.c
+++ b/div.c
@@ -146,7 +146,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode)
int extra_bit;
int sh, sh2;
int inex;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
/**************************************************************************
* *
@@ -209,7 +209,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode)
* *
**************************************************************************/
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
/* set sign */
sign_quotient = MPFR_MULT_SIGN( MPFR_SIGN(u) , MPFR_SIGN(v) );
@@ -251,7 +251,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode)
sticky bits */
qsize = q0size + 1;
/* need to allocate memory for the quotient */
- qp = (mp_ptr) TMP_ALLOC (qsize*sizeof(mp_limb_t));
+ qp = (mp_ptr) MPFR_TMP_ALLOC (qsize*sizeof(mp_limb_t));
}
else
{
@@ -261,7 +261,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode)
qqsize = qsize + qsize;
/* prepare the dividend */
- ap = (mp_ptr) TMP_ALLOC (qqsize*sizeof(mp_limb_t));
+ ap = (mp_ptr) MPFR_TMP_ALLOC (qqsize*sizeof(mp_limb_t));
if (MPFR_LIKELY(qqsize > usize)) /* use the full dividend */
{
k = qqsize - usize; /* k > 0 */
@@ -294,7 +294,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode)
between quotient and divisor, necessarily k = 0
since quotient and divisor are the same mpfr variable */
{
- bp = (mp_ptr) TMP_ALLOC (qsize * sizeof(mp_limb_t));
+ bp = (mp_ptr) MPFR_TMP_ALLOC (qsize * sizeof(mp_limb_t));
MPN_COPY(bp, vp, vsize);
}
sticky_v = sticky_v || mpn_cmpzero (vp, k);
@@ -302,7 +302,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode)
else /* vsize < qsize */
{
k = qsize - vsize;
- bp = (mp_ptr) TMP_ALLOC (qsize * sizeof(mp_limb_t));
+ bp = (mp_ptr) MPFR_TMP_ALLOC (qsize * sizeof(mp_limb_t));
MPN_COPY(bp + k, vp, vsize);
MPN_ZERO(bp, k);
}
@@ -402,7 +402,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode)
mp_ptr sp;
int cmp_s_r;
- sp = (mp_ptr) TMP_ALLOC (vsize*sizeof(mp_limb_t));
+ sp = (mp_ptr) MPFR_TMP_ALLOC (vsize*sizeof(mp_limb_t));
k = vsize - qsize;
/* sp <- {qp, qsize} * {vp, vsize-qsize} */
qp[0] ^= sticky3orig; /* restore original quotient */
@@ -620,7 +620,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mp_rnd_t rnd_mode)
truncate: /* inex already set */
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
/* check for underflow/overflow */
if (MPFR_UNLIKELY(qexp > __gmpfr_emax))
diff --git a/div_ui.c b/div_ui.c
index 2dc69692d..7f2951a65 100644
--- a/div_ui.c
+++ b/div_ui.c
@@ -34,7 +34,7 @@ mpfr_div_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode)
mp_limb_t *xp, *yp, *tmp, c, d;
mp_exp_t exp;
int inexact, middle = 1;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x)))
{
@@ -76,7 +76,7 @@ mpfr_div_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode)
MPFR_SET_SAME_SIGN (y, x);
- TMP_MARK (marker);
+ MPFR_TMP_MARK (marker);
xn = MPFR_LIMB_SIZE (x);
yn = MPFR_LIMB_SIZE (y);
@@ -88,7 +88,7 @@ mpfr_div_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode)
/* we need to store yn+1 = xn + dif limbs of the quotient */
/* don't use tmp=yp since the mpn_lshift call below requires yp >= tmp+1 */
- tmp = (mp_limb_t*) TMP_ALLOC ((yn + 1) * BYTES_PER_MP_LIMB);
+ tmp = (mp_limb_t*) MPFR_TMP_ALLOC ((yn + 1) * BYTES_PER_MP_LIMB);
c = (mp_limb_t) u;
MPFR_ASSERTN (u == c);
@@ -176,7 +176,7 @@ mpfr_div_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode)
MPFR_SET_EXP (y, exp);
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
if (MPFR_UNLIKELY ((d == 0) && (inexact == 0)))
return 0; /* result is exact */
diff --git a/exp_2.c b/exp_2.c
index 9e725a5f3..5d29992cf 100644
--- a/exp_2.c
+++ b/exp_2.c
@@ -37,7 +37,7 @@ mpz_normalize2 (mpz_t, mpz_t, mp_exp_t, mp_exp_t);
#define MY_INIT_MPZ(x, s) { \
(x)->_mp_alloc = (s); \
- PTR(x) = (mp_ptr) TMP_ALLOC((s)*BYTES_PER_MP_LIMB); \
+ PTR(x) = (mp_ptr) MPFR_TMP_ALLOC((s)*BYTES_PER_MP_LIMB); \
(x)->_mp_size = 0; }
/* if k = the number of bits of z > q, divides z by 2^(k-q) and returns k-q.
@@ -92,7 +92,7 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
mpfr_t r, s, t;
mpz_t ss;
MPFR_ZIV_DECL (loop);
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
precy = MPFR_PREC(y);
@@ -160,7 +160,7 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
MPFR_ASSERTD (MPFR_IS_POS (r));
mpfr_div_2ui (r, r, K, GMP_RNDU); /* r = (x-n*log(2))/2^K, exact */
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
MY_INIT_MPZ(ss, 3 + 2*((q-1)/BITS_PER_MP_LIMB));
exps = mpfr_get_z_exp (ss, s);
/* s <- 1 + r/1! + r^2/2! + ... + r^l/l! */
@@ -179,7 +179,7 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
mpfr_set_z (s, ss, GMP_RNDN);
MPFR_SET_EXP(s, MPFR_GET_EXP (s) + exps);
- TMP_FREE(marker); /* don't need ss anymore */
+ MPFR_TMP_FREE(marker); /* don't need ss anymore */
mpfr_clear_underflow ();
mpfr_mul_2si (s, s, n, GMP_RNDU);
@@ -249,9 +249,9 @@ mpfr_exp2_aux (mpz_t s, mpfr_srcptr r, mp_prec_t q, mp_exp_t *exps)
mp_size_t qn;
mpz_t t, rr;
mp_size_t sbit, tbit;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
qn = 1 + (q-1)/BITS_PER_MP_LIMB;
expt = 0;
*exps = 1 - (mp_exp_t) q; /* s = 2^(q-1) */
@@ -284,7 +284,7 @@ mpfr_exp2_aux (mpz_t s, mpfr_srcptr r, mp_prec_t q, mp_exp_t *exps)
expr += mpz_normalize(rr, rr, tbit);
}
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return 3*l*(l+1);
}
@@ -306,7 +306,7 @@ mpfr_exp2_aux2 (mpz_t s, mpfr_srcptr r, mp_prec_t q, mp_exp_t *exps)
unsigned long l, m, i;
mpz_t t, *R, rr, tmp;
mp_size_t sbit, rrbit;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
/* estimate value of l */
MPFR_ASSERTD (MPFR_GET_EXP (r) < 0);
@@ -316,9 +316,9 @@ mpfr_exp2_aux2 (mpz_t s, mpfr_srcptr r, mp_prec_t q, mp_exp_t *exps)
if (m < 2)
m = 2;
- TMP_MARK(marker);
- R = (mpz_t*) TMP_ALLOC((m+1)*sizeof(mpz_t)); /* R[i] is r^i */
- expR = (mp_exp_t*) TMP_ALLOC((m+1)*sizeof(mp_exp_t)); /* exponent for R[i] */
+ MPFR_TMP_MARK(marker);
+ R = (mpz_t*) MPFR_TMP_ALLOC((m+1)*sizeof(mpz_t)); /* R[i] is r^i */
+ expR = (mp_exp_t*) MPFR_TMP_ALLOC((m+1)*sizeof(mp_exp_t)); /* exponent for R[i] */
sizer = 1 + (MPFR_PREC(r)-1)/BITS_PER_MP_LIMB;
mpz_init(tmp);
MY_INIT_MPZ(rr, sizer+2);
@@ -394,7 +394,7 @@ mpfr_exp2_aux2 (mpz_t s, mpfr_srcptr r, mp_prec_t q, mp_exp_t *exps)
certainly wrong */
} while ((size_t) expr+rrbit > (size_t)((int)-q));
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
mpz_clear(tmp);
return l*(l+4);
}
diff --git a/generic.c b/generic.c
index 8917f176c..2c62328f7 100644
--- a/generic.c
+++ b/generic.c
@@ -47,19 +47,19 @@ GENERIC (mpfr_ptr y, mpz_srcptr p, long r, int m)
#endif
mp_exp_t diff, expo;
mp_prec_t precy = MPFR_PREC(y);
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
MPFR_CLEAR_FLAGS(y);
n = 1UL << m;
- P = (mpz_t*) TMP_ALLOC ((m+1) * sizeof(mpz_t));
- S = (mpz_t*) TMP_ALLOC ((m+1) * sizeof(mpz_t));
- ptoj = (mpz_t*) TMP_ALLOC ((m+1) * sizeof(mpz_t)); /* ptoj[i] = mantissa^(2^i) */
+ P = (mpz_t*) MPFR_TMP_ALLOC ((m+1) * sizeof(mpz_t));
+ S = (mpz_t*) MPFR_TMP_ALLOC ((m+1) * sizeof(mpz_t));
+ ptoj = (mpz_t*) MPFR_TMP_ALLOC ((m+1) * sizeof(mpz_t)); /* ptoj[i] = mantissa^(2^i) */
#ifdef A
- T = (mpz_t*) TMP_ALLOC ((m+1) * sizeof(mpz_t));
+ T = (mpz_t*) MPFR_TMP_ALLOC ((m+1) * sizeof(mpz_t));
#endif
#ifdef R_IS_RATIONAL
- qtoj = (mpz_t*) TMP_ALLOC ((m+1) * sizeof(mpz_t));
+ qtoj = (mpz_t*) MPFR_TMP_ALLOC ((m+1) * sizeof(mpz_t));
#endif
for (i = 0 ; i <= m ; i++)
{
@@ -195,7 +195,7 @@ GENERIC (mpfr_ptr y, mpz_srcptr p, long r, int m)
mpz_clear (T[i]);
#endif
}
- TMP_FREE (marker);
+ MPFR_TMP_FREE (marker);
return 0;
}
diff --git a/get_str.c b/get_str.c
index e47314b1f..43dd1ca69 100644
--- a/get_str.c
+++ b/get_str.c
@@ -223,7 +223,7 @@ mpfr_get_str_aux (char *const str, mp_exp_t *const exp, mp_limb_t *const r,
mp_rnd_t rnd1;
size_t i;
int exact = (e < 0);
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
/* if f > 0, then the maximal error 2^(e+f) is larger than 2 so we can't
determine the integer Y */
@@ -231,7 +231,7 @@ mpfr_get_str_aux (char *const str, mp_exp_t *const exp, mp_limb_t *const r,
/* if f is too small, then r*2^f is smaller than 1 */
MPFR_ASSERTN(f > (-n * BITS_PER_MP_LIMB));
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
/* R = 2^f sum r[i]K^(i)
r[i] = (r_(i,k-1)...r_(i,0))_2
@@ -282,7 +282,7 @@ mpfr_get_str_aux (char *const str, mp_exp_t *const exp, mp_limb_t *const r,
/* now the rounded value Y is in {r+i0, n-i0} */
/* convert r+i0 into base b */
- str1 = (unsigned char*) TMP_ALLOC (m + 3); /* need one extra character for mpn_get_str */
+ str1 = (unsigned char*) MPFR_TMP_ALLOC (m + 3); /* need one extra character for mpn_get_str */
size_s1 = mpn_get_str (str1, b, r + i0, n - i0);
/* round str1 */
@@ -367,7 +367,7 @@ mpfr_get_str_aux (char *const str, mp_exp_t *const exp, mp_limb_t *const r,
}
free_and_return:
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return dir;
}
@@ -425,7 +425,7 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd
int neg;
int ret; /* return value of mpfr_get_str_aux */
MPFR_ZIV_DECL (loop);
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
/* if exact = 1 then err is undefined */
/* otherwise err is such that |x*b^(m-g)-a*2^exp_a| < 2^(err+exp_a) */
@@ -513,8 +513,8 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd
prec = (m - 1) * pow2 + r; /* total number of bits */
n = (prec - 1) / BITS_PER_MP_LIMB + 1;
- TMP_MARK (marker);
- x1 = (mp_limb_t*) TMP_ALLOC((n + 1) * sizeof (mp_limb_t));
+ MPFR_TMP_MARK (marker);
+ x1 = (mp_limb_t*) MPFR_TMP_ALLOC((n + 1) * sizeof (mp_limb_t));
nb = n * BITS_PER_MP_LIMB - prec;
/* round xp to the precision prec, and put it into x1
put the carry into x1[n] */
@@ -552,7 +552,7 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd
/* the exponent of s is f + 1 */
*e = f + 1;
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return (s0);
}
@@ -572,7 +572,7 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd
MPFR_ZIV_INIT (loop, prec);
for (;;)
{
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
exact = 1;
@@ -580,7 +580,7 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd
n = 1 + (prec - 1) / BITS_PER_MP_LIMB;
/* a will contain the approximation of the mantissa */
- a = (mp_limb_t*) TMP_ALLOC (n * sizeof (mp_limb_t));
+ a = (mp_limb_t*) MPFR_TMP_ALLOC (n * sizeof (mp_limb_t));
nx = 1 + (MPFR_PREC(x) - 1) / BITS_PER_MP_LIMB;
@@ -614,7 +614,7 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd
err = (err <= 0) ? 2 : err + 1;
/* result = a * x */
- result = (mp_limb_t*) TMP_ALLOC ((n + nx1) * sizeof (mp_limb_t));
+ result = (mp_limb_t*) MPFR_TMP_ALLOC ((n + nx1) * sizeof (mp_limb_t));
mpn_mul (result, a, n, x1, nx1);
exp_a += MPFR_GET_EXP (x);
if (mpn_scan1 (result, 0) < (nx1 * BITS_PER_MP_LIMB))
@@ -637,9 +637,9 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd
exact = (err == -1);
/* allocate memory for x1, result and reste */
- x1 = (mp_limb_t*) TMP_ALLOC (2 * n * sizeof (mp_limb_t));
- result = (mp_limb_t*) TMP_ALLOC ((n + 1) * sizeof (mp_limb_t));
- reste = (mp_limb_t*) TMP_ALLOC (n * sizeof (mp_limb_t));
+ x1 = (mp_limb_t*) MPFR_TMP_ALLOC (2 * n * sizeof (mp_limb_t));
+ result = (mp_limb_t*) MPFR_TMP_ALLOC ((n + 1) * sizeof (mp_limb_t));
+ reste = (mp_limb_t*) MPFR_TMP_ALLOC (n * sizeof (mp_limb_t));
/* initialize x1 = x */
MPN_COPY2 (x1, 2 * n, xp, nx);
@@ -694,13 +694,13 @@ mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd
else
break;
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
}
MPFR_ZIV_FREE (loop);
*e += g;
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return s0;
diff --git a/init2.c b/init2.c
index a5145e3a6..efe4919ef 100644
--- a/init2.c
+++ b/init2.c
@@ -62,7 +62,7 @@ mpfr_init2 (mpfr_ptr x, mp_prec_t p)
MPFR_SET_NAN(x); /* initializes to NaN */
}
-#ifdef MPFR_USE_OWN_TMP_ALLOC
+#ifdef MPFR_USE_OWN_MPFR_TMP_ALLOC
static unsigned char mpfr_stack_tab[8000000];
unsigned char *mpfr_stack = mpfr_stack_tab;
#endif
diff --git a/log.c b/log.c
index 5d0eaa422..1ffcfe21e 100644
--- a/log.c
+++ b/log.c
@@ -45,7 +45,7 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode)
mpfr_t tmp1, tmp2;
mp_limb_t *tmp1p, *tmp2p;
MPFR_ZIV_DECL (loop);
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
MPFR_LOG_FUNC (("a[%#R]=%R rnd=%d", a, a, rnd_mode),
("r[%#R]=%R inexact=%d", r, r, inexact));
@@ -106,7 +106,7 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode)
/* if (MPFR_LIKELY(p % BITS_PER_MP_LIMB != 0))
p += BITS_PER_MP_LIMB - (p%BITS_PER_MP_LIMB); */
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
MPFR_ZIV_INIT (loop, p);
for (;;)
@@ -151,7 +151,7 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode)
MPFR_ZIV_FREE (loop);
inexact = mpfr_set (r, tmp1, rnd_mode);
/* We clean */
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return inexact; /* result is inexact */
}
diff --git a/mpfr-impl.h b/mpfr-impl.h
index 201ab5c85..32639cf4c 100644
--- a/mpfr-impl.h
+++ b/mpfr-impl.h
@@ -654,17 +654,30 @@ typedef union { mp_size_t s; mp_limb_t l; } mpfr_size_limb_t;
((mp_limb_t*) ((mpfr_size_limb_t*) MPFR_MANT(x) - 1))
/* Temporary memory gestion */
+#ifndef TMP_SALLOC
+/* GMP 4.1.x or below or internals */
+#define MPFR_TMP_DECL TMP_DECL
+#define MPFR_TMP_MARK TMP_MARK
+#define MPFR_TMP_ALLOC TMP_ALLOC
+#define MPFR_TMP_FREE TMP_FREE
+#else
+#define MPFR_TMP_DECL(x) TMP_DECL
+#define MPFR_TMP_MARK(x) TMP_MARK
+#define MPFR_TMP_ALLOC(s) TMP_SALLOC(s)
+#define MPFR_TMP_FREE(x) TMP_FREE
+#endif
+
/* This code is experimental: don't use it */
-#ifdef MPFR_USE_OWN_TMP_ALLOC
+#ifdef MPFR_USE_OWN_MPFR_TMP_ALLOC
extern unsigned char *mpfr_stack;
-#undef TMP_DECL
-#undef TMP_MARK
-#undef TMP_ALLOC
-#undef TMP_FREE
-#define TMP_DECL(_x) unsigned char *(_x)
-#define TMP_MARK(_x) ((_x) = mpfr_stack)
-#define TMP_ALLOC(_s) (mpfr_stack += (_s), mpfr_stack - (_s))
-#define TMP_FREE(_x) (mpfr_stack = (_x))
+#undef MPFR_TMP_DECL
+#undef MPFR_TMP_MARK
+#undef MPFR_TMP_ALLOC
+#undef MPFR_TMP_FREE
+#define MPFR_TMP_DECL(_x) unsigned char *(_x)
+#define MPFR_TMP_MARK(_x) ((_x) = mpfr_stack)
+#define MPFR_TMP_ALLOC(_s) (mpfr_stack += (_s), mpfr_stack - (_s))
+#define MPFR_TMP_FREE(_x) (mpfr_stack = (_x))
#endif
/* temporary allocate 1 limb at xp, and initialize mpfr variable x */
@@ -677,7 +690,7 @@ extern unsigned char *mpfr_stack;
MPFR_SET_INVALID_EXP(x))
#define MPFR_TMP_INIT(xp, x, p, s) \
- (xp = (mp_ptr) TMP_ALLOC(BYTES_PER_MP_LIMB * ((size_t) s)), \
+ (xp = (mp_ptr) MPFR_TMP_ALLOC(BYTES_PER_MP_LIMB * ((size_t) s)), \
MPFR_TMP_INIT1(xp, x, p))
#define MPFR_TMP_INIT_ABS(d, s) \
diff --git a/mpn_exp.c b/mpn_exp.c
index 5f4c5f731..0d325ea27 100644
--- a/mpn_exp.c
+++ b/mpn_exp.c
@@ -48,12 +48,12 @@ mpfr_mpn_exp (mp_limb_t *a, mp_exp_t *exp_r, int b, mp_exp_t e, size_t n)
/* error == t means no error */
int err_s_a2 = 0;
int err_s_ab = 0; /* number of error when shift A^2, AB */
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
MPFR_ASSERTN(e > 0);
MPFR_ASSERTN((2 <= b) && (b <= 36));
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
/* initialization of a, b, f, h */
@@ -67,7 +67,7 @@ mpfr_mpn_exp (mp_limb_t *a, mp_exp_t *exp_r, int b, mp_exp_t e, size_t n)
h = - h;
/* allocate space for A and set it to B */
- c = (mp_limb_t*) TMP_ALLOC(2 * n * BYTES_PER_MP_LIMB);
+ c = (mp_limb_t*) MPFR_TMP_ALLOC(2 * n * BYTES_PER_MP_LIMB);
a [n - 1] = B;
MPN_ZERO (a, n - 1);
/* initial exponent for A: invariant is A = {a, n} * 2^f */
@@ -98,7 +98,7 @@ mpfr_mpn_exp (mp_limb_t *a, mp_exp_t *exp_r, int b, mp_exp_t e, size_t n)
if (MPFR_UNLIKELY(f < MPFR_EXP_MIN/2 || f > MPFR_EXP_MAX/2))
{
overflow:
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return -2;
}
/* FIXME: Could f = 2*f + n * BITS_PER_MP_LIMB be used? */
@@ -145,7 +145,7 @@ mpfr_mpn_exp (mp_limb_t *a, mp_exp_t *exp_r, int b, mp_exp_t e, size_t n)
}
}
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
*exp_r = f;
diff --git a/mul.c b/mul.c
index 1694b9bae..556ed2644 100644
--- a/mul.c
+++ b/mul.c
@@ -43,7 +43,7 @@ mpfr_mul3 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
mp_limb_t b1;
mp_prec_t bq, cq;
mp_size_t bn, cn, tn, k;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
/* deal with special cases */
if (MPFR_ARE_SINGULAR(b,c))
@@ -109,8 +109,8 @@ mpfr_mul3 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
/* Check for no size_t overflow*/
MPFR_ASSERTD((size_t) k <= ((size_t) ~0) / BYTES_PER_MP_LIMB);
- TMP_MARK(marker);
- tmp = (mp_limb_t *) TMP_ALLOC((size_t) k * BYTES_PER_MP_LIMB);
+ MPFR_TMP_MARK(marker);
+ tmp = (mp_limb_t *) MPFR_TMP_ALLOC((size_t) k * BYTES_PER_MP_LIMB);
/* multiplies two mantissa in temporary allocated space */
b1 = (MPFR_LIKELY(bn >= cn)) ?
@@ -135,7 +135,7 @@ mpfr_mul3 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
if (MPFR_UNLIKELY(cc))
MPFR_MANT(a)[MPFR_LIMB_SIZE(a)-1] = MPFR_LIMB_HIGHBIT;
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
{
mp_exp_t ax2 = ax + (mp_exp_t) (b1 - 1 + cc);
@@ -209,7 +209,7 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
mp_limb_t b1;
mp_prec_t bq, cq;
mp_size_t bn, cn, tn, k;
- TMP_DECL (marker);
+ MPFR_TMP_DECL (marker);
MPFR_LOG_FUNC (("b[%#R]=%R c[%#R]=%R rnd=%d", b, b, c, c, rnd_mode),
("a[%#R]=%R inexact=%d", a, a, inexact));
@@ -290,8 +290,8 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
/* Check for no size_t overflow*/
MPFR_ASSERTD ((size_t) k <= ((size_t) ~0) / BYTES_PER_MP_LIMB);
- TMP_MARK (marker);
- tmp = (mp_limb_t *) TMP_ALLOC ((size_t) k * BYTES_PER_MP_LIMB);
+ MPFR_TMP_MARK (marker);
+ tmp = (mp_limb_t *) MPFR_TMP_ALLOC ((size_t) k * BYTES_PER_MP_LIMB);
/* multiplies two mantissa in temporary allocated space */
if (MPFR_UNLIKELY (bn < cn))
@@ -380,7 +380,7 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
bp --;
else
{
- bp = TMP_ALLOC ((n+1)*sizeof (mp_limb_t));
+ bp = MPFR_TMP_ALLOC ((n+1)*sizeof (mp_limb_t));
bp[0] = 0;
MPN_COPY (bp+1, MPFR_MANT (b)+bn-n, n);
}
@@ -388,7 +388,7 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
cp --; /* FIXME: Could this happen? */
else
{
- cp = TMP_ALLOC ((n+1)*sizeof (mp_limb_t));
+ cp = MPFR_TMP_ALLOC ((n+1)*sizeof (mp_limb_t));
cp[0] = 0;
MPN_COPY (cp+1, MPFR_MANT (c)+cn-n, n);
}
@@ -400,7 +400,7 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
if (MPFR_LIKELY (k < 2*n))
{
- tmp = TMP_ALLOC (2*n*sizeof (mp_limb_t));
+ tmp = MPFR_TMP_ALLOC (2*n*sizeof (mp_limb_t));
tmp += 2*n-k; /* `tmp' still points to an area of `k' limbs */
}
}
@@ -446,7 +446,7 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
ax2 = ax + (mp_exp_t) (b1 - 1);
MPFR_RNDRAW (inexact, a, tmp, bq+cq, rnd_mode, sign, ax2++);
- TMP_FREE (marker);
+ MPFR_TMP_FREE (marker);
MPFR_EXP (a) = ax2; /* Can't use MPFR_SET_EXP: Expo may be out of range */
MPFR_SET_SIGN (a, sign);
if (MPFR_UNLIKELY (ax2 > __gmpfr_emax))
diff --git a/mul_ui.c b/mul_ui.c
index 2e0b4ec10..05f6ebfdd 100644
--- a/mul_ui.c
+++ b/mul_ui.c
@@ -30,7 +30,7 @@ mpfr_mul_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode)
mp_limb_t *yp;
mp_size_t xn, yn;
int cnt, inexact;
- TMP_DECL (marker);
+ MPFR_TMP_DECL (marker);
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x)))
{
@@ -78,9 +78,9 @@ mpfr_mul_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode)
xn = MPFR_LIMB_SIZE (x);
MPFR_ASSERTD (xn < MP_SIZE_T_MAX);
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
if (MPFR_LIKELY (yn < xn + 1))
- yp = (mp_ptr) TMP_ALLOC ((size_t) (xn + 1) * BYTES_PER_MP_LIMB);
+ yp = (mp_ptr) MPFR_TMP_ALLOC ((size_t) (xn + 1) * BYTES_PER_MP_LIMB);
MPFR_ASSERTN (u == (mp_limb_t) u);
yp[xn] = mpn_mul_1 (yp, MPFR_MANT (x), xn, u);
@@ -105,7 +105,7 @@ mpfr_mul_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode)
MPFR_RNDRAW (inexact, y, yp, (mp_prec_t) (xn + 1) * BITS_PER_MP_LIMB,
rnd_mode, MPFR_SIGN (x), cnt -- );
- TMP_FREE (marker);
+ MPFR_TMP_FREE (marker);
cnt = BITS_PER_MP_LIMB - cnt;
if (MPFR_UNLIKELY (__gmpfr_emax < MPFR_EMAX_MIN + cnt
diff --git a/round_prec.c b/round_prec.c
index b08292198..dafbbf3d7 100644
--- a/round_prec.c
+++ b/round_prec.c
@@ -51,7 +51,7 @@ mpfr_prec_round (mpfr_ptr x, mp_prec_t prec, mp_rnd_t rnd_mode)
mp_limb_t *tmp, *xp;
int carry, inexact;
mp_prec_t nw, ow;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
MPFR_ASSERTN(prec >= MPFR_PREC_MIN && prec <= MPFR_PREC_MAX);
@@ -79,8 +79,8 @@ mpfr_prec_round (mpfr_ptr x, mp_prec_t prec, mp_rnd_t rnd_mode)
/* x is a non-zero real number */
- TMP_MARK(marker);
- tmp = (mp_limb_t*) TMP_ALLOC (nw * BYTES_PER_MP_LIMB);
+ MPFR_TMP_MARK(marker);
+ tmp = (mp_limb_t*) MPFR_TMP_ALLOC (nw * BYTES_PER_MP_LIMB);
xp = MPFR_MANT(x);
carry = mpfr_round_raw (tmp, xp, MPFR_PREC(x), MPFR_IS_NEG(x),
prec, rnd_mode, &inexact);
@@ -104,7 +104,7 @@ mpfr_prec_round (mpfr_ptr x, mp_prec_t prec, mp_rnd_t rnd_mode)
else
MPN_COPY(xp, tmp, nw);
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return inexact;
}
@@ -137,7 +137,7 @@ mpfr_can_round_raw (const mp_limb_t *bp, mp_size_t bn, int neg, mp_exp_t err0,
int s, s1;
mp_limb_t cc, cc2;
mp_limb_t *tmp;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
if (MPFR_UNLIKELY(err0 < 0 || (mp_exp_unsigned_t) err0 <= prec))
return 0; /* can't round */
@@ -173,10 +173,10 @@ mpfr_can_round_raw (const mp_limb_t *bp, mp_size_t bn, int neg, mp_exp_t err0,
/* if when adding or subtracting (1 << s) in bp[bn-1-k], it does not
change bp[bn-1] >> s1, then we can round */
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
tn = bn;
k++; /* since we work with k+1 everywhere */
- tmp = (mp_limb_t*) TMP_ALLOC(tn * BYTES_PER_MP_LIMB);
+ tmp = (mp_limb_t*) MPFR_TMP_ALLOC(tn * BYTES_PER_MP_LIMB);
if (bn > k)
MPN_COPY (tmp, bp, bn - k);
@@ -216,13 +216,13 @@ mpfr_can_round_raw (const mp_limb_t *bp, mp_size_t bn, int neg, mp_exp_t err0,
if (cc2 && cc)
{
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return 0;
}
cc2 = (tmp[bn - 1] >> s1) & 1;
cc2 ^= mpfr_round_raw2 (tmp, bn, neg, rnd2, prec);
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return cc == cc2;
}
diff --git a/set_f.c b/set_f.c
index 8d6032b5d..55dc987c3 100644
--- a/set_f.c
+++ b/set_f.c
@@ -28,7 +28,7 @@ mpfr_set_f (mpfr_ptr y, mpf_srcptr x, mp_rnd_t rnd_mode)
mp_limb_t *my, *mx, *tmp;
unsigned long cnt, sx, sy;
int inexact, carry = 0;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
sx = ABS(SIZ(x)); /* number of limbs of the mantissa of x */
@@ -55,8 +55,8 @@ mpfr_set_f (mpfr_ptr y, mpf_srcptr x, mp_rnd_t rnd_mode)
{
unsigned long xprec = sx * BITS_PER_MP_LIMB;
- TMP_MARK(marker);
- tmp = (mp_limb_t*) TMP_ALLOC(sx * BYTES_PER_MP_LIMB);
+ MPFR_TMP_MARK(marker);
+ tmp = (mp_limb_t*) MPFR_TMP_ALLOC(sx * BYTES_PER_MP_LIMB);
if (cnt)
mpn_lshift (tmp, mx, sx, cnt);
else
@@ -67,7 +67,7 @@ mpfr_set_f (mpfr_ptr y, mpf_srcptr x, mp_rnd_t rnd_mode)
rnd_mode, &inexact);
if (MPFR_UNLIKELY(carry)) /* result is a power of two */
my[sy - 1] = MPFR_LIMB_HIGHBIT;
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
}
else
{
diff --git a/sqr.c b/sqr.c
index df1e0e1b0..63ecda961 100644
--- a/sqr.c
+++ b/sqr.c
@@ -33,7 +33,7 @@ mpfr_sqr (mpfr_ptr a, mpfr_srcptr b, mp_rnd_t rnd_mode)
mp_limb_t b1;
mp_prec_t bq;
mp_size_t bn, tn;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
/* deal with special cases */
if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(b)))
@@ -59,8 +59,8 @@ mpfr_sqr (mpfr_ptr a, mpfr_srcptr b, mp_rnd_t rnd_mode)
bn = (bq+BITS_PER_MP_LIMB-1)/BITS_PER_MP_LIMB; /* number of limbs of b */
tn = (2*bq + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB;
- TMP_MARK(marker);
- tmp = (mp_limb_t *) TMP_ALLOC((size_t) 2*bn * BYTES_PER_MP_LIMB);
+ MPFR_TMP_MARK(marker);
+ tmp = (mp_limb_t *) MPFR_TMP_ALLOC((size_t) 2*bn * BYTES_PER_MP_LIMB);
/* Multiplies the mantissa in temporary allocated space */
mpn_sqr_n (tmp, MPFR_MANT(b), bn);
@@ -83,7 +83,7 @@ mpfr_sqr (mpfr_ptr a, mpfr_srcptr b, mp_rnd_t rnd_mode)
if (MPFR_UNLIKELY(cc))
MPFR_MANT(a)[MPFR_LIMB_SIZE(a)-1] = MPFR_LIMB_HIGHBIT;
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
{
mp_exp_t ax2 = ax + (mp_exp_t) (b1 - 1 + cc);
if (MPFR_UNLIKELY( ax2 > __gmpfr_emax))
diff --git a/sqrt.c b/sqrt.c
index 181164287..a8ef38be8 100644
--- a/sqrt.c
+++ b/sqrt.c
@@ -41,7 +41,7 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
int sh; /* number of extra bits in rp[0] */
int inexact; /* return ternary flag */
mp_exp_t expr;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(u)))
{
@@ -89,8 +89,8 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
odd_exp = (unsigned int) MPFR_GET_EXP (u) & 1;
inexact = -1; /* return ternary flag */
- TMP_MARK (marker);
- sp = (mp_limb_t *) TMP_ALLOC (rrsize * sizeof (mp_limb_t));
+ MPFR_TMP_MARK (marker);
+ sp = (mp_limb_t *) MPFR_TMP_ALLOC (rrsize * sizeof (mp_limb_t));
/* copy the most significant limbs of u to {sp, rrsize} */
if (MPFR_LIKELY(usize <= rrsize)) /* in case r and u have the same precision,
@@ -247,7 +247,7 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
MPFR_SET_EXP(r, expr);
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return inexact;
}
diff --git a/strtofr.c b/strtofr.c
index 5a01b5712..c25941478 100644
--- a/strtofr.c
+++ b/strtofr.c
@@ -410,20 +410,20 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
mp_size_t ysize, real_ysize;
int res, err;
MPFR_ZIV_DECL (loop);
- TMP_DECL (marker);
+ MPFR_TMP_DECL (marker);
/* determine the minimal precision for the computation */
prec = MPFR_PREC (x) + MPFR_INT_CEIL_LOG2 (MPFR_PREC (x));
/* compute y as long as rounding is not possible */
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
MPFR_ZIV_INIT (loop, prec);
for (;;)
{
/* initialize y to the value of 0.mant_s[0]...mant_s[pr-1] */
ysize = (prec - 1) / BITS_PER_MP_LIMB + 1;
ysize_bits = ysize * BITS_PER_MP_LIMB;
- y = (mp_limb_t*) TMP_ALLOC ((2 * ysize + 1) * sizeof (mp_limb_t));
+ y = (mp_limb_t*) MPFR_TMP_ALLOC ((2 * ysize + 1) * sizeof (mp_limb_t));
y += ysize;
/* required precision for str to have ~ysize limbs
@@ -519,7 +519,7 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
mp_limb_t *z;
mp_exp_t exp_z;
- result = (mp_limb_t*) TMP_ALLOC ((2*ysize+1)*BYTES_PER_MP_LIMB);
+ result = (mp_limb_t*) MPFR_TMP_ALLOC ((2*ysize+1)*BYTES_PER_MP_LIMB);
/* z = base^(exp_base-sptr_size) using space allocated at y-ysize */
z = y - ysize;
@@ -569,7 +569,7 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
mp_limb_t *z;
mp_exp_t exp_z;
- result = (mp_limb_t*) TMP_ALLOC ( (3*ysize+1) * BYTES_PER_MP_LIMB);
+ result = (mp_limb_t*) MPFR_TMP_ALLOC ( (3*ysize+1) * BYTES_PER_MP_LIMB);
/* set y to y * K^ysize */
y = y - ysize; /* we have allocated ysize limbs at y - ysize */
@@ -674,7 +674,7 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
res = mpfr_overflow (x, rnd, (pstr->negative) ? -1 : 1);
end:
- TMP_FREE (marker);
+ MPFR_TMP_FREE (marker);
return res;
}
diff --git a/sub1.c b/sub1.c
index a1d91e243..78f9ae9f6 100644
--- a/sub1.c
+++ b/sub1.c
@@ -39,9 +39,9 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
mp_limb_t carry, bb, cc, borrow = 0;
int inexact, shift_b, shift_c, is_exact = 1, down = 0, add_exp = 0;
int sh, k;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
ap = MPFR_MANT(a);
an = MPFR_LIMB_SIZE(a);
@@ -156,13 +156,13 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
/* Ensure ap != bp */
if (MPFR_UNLIKELY (ap == bp))
{
- bp = (mp_ptr) TMP_ALLOC(bn * BYTES_PER_MP_LIMB);
+ bp = (mp_ptr) MPFR_TMP_ALLOC(bn * BYTES_PER_MP_LIMB);
MPN_COPY (bp, ap, bn);
}
}
else
{
- bp = (mp_ptr) TMP_ALLOC ((bn + 1) * BYTES_PER_MP_LIMB);
+ bp = (mp_ptr) MPFR_TMP_ALLOC ((bn + 1) * BYTES_PER_MP_LIMB);
bp[0] = mpn_rshift (bp + 1, MPFR_MANT(b), bn++, shift_b);
}
@@ -185,13 +185,13 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
/* Ensure ap != cp */
if (ap == cp)
{
- cp = (mp_ptr) TMP_ALLOC (cn * BYTES_PER_MP_LIMB);
+ cp = (mp_ptr) MPFR_TMP_ALLOC (cn * BYTES_PER_MP_LIMB);
MPN_COPY(cp, ap, cn);
}
}
else
{
- cp = (mp_ptr) TMP_ALLOC ((cn + 1) * BYTES_PER_MP_LIMB);
+ cp = (mp_ptr) MPFR_TMP_ALLOC ((cn + 1) * BYTES_PER_MP_LIMB);
cp[0] = mpn_rshift (cp + 1, MPFR_MANT(c), cn++, shift_c);
}
@@ -501,7 +501,7 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
exp_a = MPFR_GET_EXP (b) - cancel;
if (MPFR_UNLIKELY(exp_a < __gmpfr_emin))
{
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
if (rnd_mode == GMP_RNDN &&
(exp_a < __gmpfr_emin - 1 ||
(inexact >= 0 && mpfr_powerof2_raw (a))))
@@ -520,12 +520,12 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
exp_b = MPFR_GET_EXP (b);
if (MPFR_UNLIKELY(add_exp && exp_b == __gmpfr_emax))
{
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return mpfr_overflow (a, rnd_mode, MPFR_SIGN(a));
}
MPFR_SET_EXP (a, exp_b + add_exp);
}
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
#ifdef DEBUG
printf ("result is a="); mpfr_print_binary(a); putchar('\n');
#endif
diff --git a/sub1sp.c b/sub1sp.c
index 4c3411082..1f159387f 100644
--- a/sub1sp.c
+++ b/sub1sp.c
@@ -139,9 +139,9 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
int inexact;
mp_limb_t bcp,bcp1; /* Cp and C'p+1 */
mp_limb_t bbcp, bbcp1; /* Cp+1 and C'p+2 */
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
MPFR_ASSERTD(MPFR_PREC(a) == MPFR_PREC(b) && MPFR_PREC(b) == MPFR_PREC(c));
MPFR_ASSERTD(MPFR_IS_PURE_FP(b) && MPFR_IS_PURE_FP(c));
@@ -258,7 +258,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
/* Check expo underflow */
if (MPFR_UNLIKELY(bx < __gmpfr_emin))
{
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
/* inexact=0 */
DEBUG( printf("(D==0 Underflow)\n") );
if (rnd_mode == GMP_RNDN &&
@@ -270,7 +270,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
MPFR_SET_EXP (a, bx);
/* No rounding is necessary since the result is exact */
MPFR_ASSERTD(ap[n-1] > ~ap[n-1]);
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return 0;
}
else /* if (d == 1) */
@@ -292,7 +292,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
/* Shift c in the allocated temporary block */
SubD1NoLose:
c0 = cp[0] & (MPFR_LIMB_ONE<<sh);
- cp = (mp_limb_t*) TMP_ALLOC(n * BYTES_PER_MP_LIMB);
+ cp = (mp_limb_t*) MPFR_TMP_ALLOC(n * BYTES_PER_MP_LIMB);
mpn_rshift(cp, MPFR_MANT(c), n, 1);
if (MPFR_LIKELY(c0 == 0))
{
@@ -303,7 +303,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
/* No truncate or normalize is needed */
MPFR_ASSERTD(ap[n-1] > ~ap[n-1]);
/* No rounding is necessary since the result is exact */
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return 0;
}
ap = MPFR_MANT(a);
@@ -337,7 +337,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
/* Calcul of 2*b-c (Exact) */
/* Shift b in the allocated temporary block */
SubD1Lose:
- bp = (mp_limb_t*) TMP_ALLOC (n * BYTES_PER_MP_LIMB);
+ bp = (mp_limb_t*) MPFR_TMP_ALLOC (n * BYTES_PER_MP_LIMB);
mpn_lshift (bp, MPFR_MANT(b), n, 1);
ap = MPFR_MANT(a);
mpn_sub_n (ap, bp, cp, n);
@@ -374,7 +374,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
MPFR_SET_EXP (a, bx); /* No expo overflow! */
/* No Normalize is needed*/
/* No Rounding is needed */
- TMP_FREE (marker);
+ MPFR_TMP_FREE (marker);
return 0;
}
/* carry = cp[k]/2+(cp[k-1]&1)<<(BITS_PER_MP_LIMB-1) = c'[k]*/
@@ -488,7 +488,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
/* General case: 2 <= d < p */
MPFR_UNSIGNED_MINUS_MODULO(sh, p);
- cp = (mp_limb_t*) TMP_ALLOC(n * BYTES_PER_MP_LIMB);
+ cp = (mp_limb_t*) MPFR_TMP_ALLOC(n * BYTES_PER_MP_LIMB);
/* Shift c in temporary allocated place */
dm = d % BITS_PER_MP_LIMB;
@@ -780,13 +780,13 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
(bx < __gmpfr_emin - 1 ||
(inexact >= 0 && mpfr_powerof2_raw (a))))
rnd_mode = GMP_RNDZ;
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return mpfr_underflow (a, rnd_mode, MPFR_SIGN(a));
}
*/
MPFR_SET_EXP (a, bx);
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return inexact*MPFR_INT_SIGN(a);
}
diff --git a/sum.c b/sum.c
index 650a7feca..32786dbed 100644
--- a/sum.c
+++ b/sum.c
@@ -35,9 +35,9 @@ void mpfr_count_sort (mpfr_ptr const tab[], unsigned long n,
unsigned long *account;
unsigned long exp_num;
unsigned long target_rank;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
min = max = MPFR_GET_EXP(tab[0]);
for (i = 1; i < n; i++)
@@ -55,7 +55,7 @@ void mpfr_count_sort (mpfr_ptr const tab[], unsigned long n,
heap_sort_exp_clean (tab, n, perm);
return;
}
- account = (unsigned long *) TMP_ALLOC(exp_num * sizeof(*account));
+ account = (unsigned long *) MPFR_TMP_ALLOC(exp_num * sizeof(*account));
for (i = 0; i < exp_num; i++)
account[i] = 0;
for (i = 0; i < n; i++)
@@ -68,7 +68,7 @@ void mpfr_count_sort (mpfr_ptr const tab[], unsigned long n,
perm[target_rank] = tab[i];
}
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
}
/* Performs a heap sort of the entries */
@@ -200,9 +200,9 @@ int mpfr_sum (mpfr_ptr ret, mpfr_ptr const tab[], unsigned long n,
mpfr_t cur_sum;
MPFR_ZIV_DECL (loop);
MPFR_SAVE_EXPO_DECL (expo);
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
- TMP_MARK(marker);
+ MPFR_TMP_MARK(marker);
if (MPFR_UNLIKELY (n == 0)) {
MPFR_SET_ZERO (ret);
MPFR_SET_POS (ret);
@@ -210,7 +210,7 @@ int mpfr_sum (mpfr_ptr ret, mpfr_ptr const tab[], unsigned long n,
}
/* Sort */
- perm = (mpfr_srcptr *) TMP_ALLOC(n * sizeof(mpfr_srcptr));
+ perm = (mpfr_srcptr *) MPFR_TMP_ALLOC(n * sizeof(mpfr_srcptr));
mpfr_count_sort (tab, n, perm);
/* Initial precision */
@@ -237,7 +237,7 @@ int mpfr_sum (mpfr_ptr ret, mpfr_ptr const tab[], unsigned long n,
error_trap |= mpfr_set (ret, cur_sum, rnd);
mpfr_clear (cur_sum);
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
MPFR_SAVE_EXPO_FREE (expo);
error_trap |= mpfr_check_range (ret, 0, rnd);
diff --git a/tests/tsum.c b/tests/tsum.c
index 65d4a59d4..dc26f501a 100644
--- a/tests/tsum.c
+++ b/tests/tsum.c
@@ -42,15 +42,15 @@ static int mpfr_list_sum (mpfr_ptr ret, mpfr_t *tab, unsigned long n,
mpfr_ptr *tabtmp;
unsigned long i;
int inexact;
- TMP_DECL(marker);
+ MPFR_TMP_DECL(marker);
- TMP_MARK(marker);
- tabtmp = (mpfr_ptr *) TMP_ALLOC(n * sizeof(mpfr_srcptr));
+ MPFR_TMP_MARK(marker);
+ tabtmp = (mpfr_ptr *) MPFR_TMP_ALLOC(n * sizeof(mpfr_srcptr));
for (i = 0; i < n; i++)
tabtmp[i] = tab[i];
inexact = mpfr_sum (ret, tabtmp, n, rnd);
- TMP_FREE(marker);
+ MPFR_TMP_FREE(marker);
return inexact;
}
diff --git a/tuneup.c b/tuneup.c
index 04c83d0dd..c42852dbd 100644
--- a/tuneup.c
+++ b/tuneup.c
@@ -42,11 +42,11 @@ int verbose;
double t; \
mpfr_t w, x; \
mp_size_t size; \
- TMP_DECL (marker); \
+ MPFR_TMP_DECL (marker); \
\
SPEED_RESTRICT_COND (s->size >= MPFR_PREC_MIN); \
SPEED_RESTRICT_COND (s->size <= MPFR_PREC_MAX); \
- TMP_MARK (marker); \
+ MPFR_TMP_MARK (marker); \
\
size = (s->size-1)/BITS_PER_MP_LIMB+1; \
s->xp[size-1] |= MPFR_LIMB_HIGHBIT; \
@@ -66,7 +66,7 @@ int verbose;
while (--i != 0); \
t = speed_endtime (); \
\
- TMP_FREE (marker); \
+ MPFR_TMP_FREE (marker); \
return t; \
} while (0)
@@ -76,11 +76,11 @@ int verbose;
double t; \
mpfr_t w, x, y; \
mp_size_t size; \
- TMP_DECL (marker); \
+ MPFR_TMP_DECL (marker); \
\
SPEED_RESTRICT_COND (s->size >= MPFR_PREC_MIN); \
SPEED_RESTRICT_COND (s->size <= MPFR_PREC_MAX); \
- TMP_MARK (marker); \
+ MPFR_TMP_MARK (marker); \
\
size = (s->size-1)/BITS_PER_MP_LIMB+1; \
s->xp[size-1] |= MPFR_LIMB_HIGHBIT; \
@@ -104,7 +104,7 @@ int verbose;
while (--i != 0); \
t = speed_endtime (); \
\
- TMP_FREE (marker); \
+ MPFR_TMP_FREE (marker); \
return t; \
} while (0)
@@ -333,16 +333,16 @@ tune_mulder_upto (mp_size_t n)
struct speed_params s;
mp_size_t k, kbest;
double t, tbest;
- TMP_DECL (marker);
+ MPFR_TMP_DECL (marker);
if (n == 0)
return -1;
- TMP_MARK (marker);
+ MPFR_TMP_MARK (marker);
s.align_xp = s.align_yp = s.align_wp = 64;
s.size = n;
- s.xp = TMP_ALLOC (n*sizeof (mp_limb_t));
- s.yp = TMP_ALLOC (n*sizeof (mp_limb_t));
+ s.xp = MPFR_TMP_ALLOC (n*sizeof (mp_limb_t));
+ s.yp = MPFR_TMP_ALLOC (n*sizeof (mp_limb_t));
mpn_random (s.xp, n);
mpn_random (s.yp, n);
@@ -367,7 +367,7 @@ tune_mulder_upto (mp_size_t n)
mulhigh_ktab[n] = kbest;
- TMP_FREE (marker);
+ MPFR_TMP_FREE (marker);
return kbest;
}