diff options
-rw-r--r-- | src/div.c | 22 | ||||
-rw-r--r-- | src/eq.c | 2 | ||||
-rw-r--r-- | src/init2.c | 4 | ||||
-rw-r--r-- | src/mpfr-gmp.h | 4 | ||||
-rw-r--r-- | src/mpfr-impl.h | 26 | ||||
-rw-r--r-- | src/mulders.c | 13 | ||||
-rw-r--r-- | src/rec_sqrt.c | 8 | ||||
-rw-r--r-- | src/round_prec.c | 2 | ||||
-rw-r--r-- | src/set_d.c | 2 | ||||
-rw-r--r-- | src/set_prec.c | 4 | ||||
-rw-r--r-- | src/sqrt.c | 6 | ||||
-rw-r--r-- | src/urandom.c | 2 | ||||
-rw-r--r-- | src/urandomb.c | 5 | ||||
-rw-r--r-- | src/vasprintf.c | 2 | ||||
-rw-r--r-- | tests/random2.c | 2 | ||||
-rw-r--r-- | tune/speed.c | 12 | ||||
-rw-r--r-- | tune/tuneup.c | 12 |
17 files changed, 72 insertions, 56 deletions
@@ -26,7 +26,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #ifdef DEBUG2 #define mpfr_mpn_print(ap,n) mpfr_mpn_print3 (ap,n,MPFR_LIMB_ZERO) static void -mpfr_mpn_print3 (mp_ptr ap, mp_size_t n, mp_limb_t cy) +mpfr_mpn_print3 (mpfr_limb_ptr ap, mp_size_t n, mp_limb_t cy) { mp_size_t i; for (i = 0; i < n; i++) @@ -40,7 +40,7 @@ mpfr_mpn_print3 (mp_ptr ap, mp_size_t n, mp_limb_t cy) /* check if {ap, an} is zero */ static int -mpfr_mpn_cmpzero (mp_ptr ap, mp_size_t an) +mpfr_mpn_cmpzero (mpfr_limb_ptr ap, mp_size_t an) { while (an > 0) if (MPFR_LIKELY(ap[--an] != MPFR_LIMB_ZERO)) @@ -53,7 +53,8 @@ mpfr_mpn_cmpzero (mp_ptr ap, mp_size_t an) Takes into account bp[0] for extra=1. */ static int -mpfr_mpn_cmp_aux (mp_ptr ap, mp_size_t an, mp_ptr bp, mp_size_t bn, int extra) +mpfr_mpn_cmp_aux (mpfr_limb_ptr ap, mp_size_t an, + mpfr_limb_ptr bp, mp_size_t bn, int extra) { int cmp = 0; mp_size_t k; @@ -109,7 +110,8 @@ mpfr_mpn_cmp_aux (mp_ptr ap, mp_size_t an, mp_ptr bp, mp_size_t bn, int extra) Return borrow out. */ static mp_limb_t -mpfr_mpn_sub_aux (mp_ptr ap, mp_ptr bp, mp_size_t n, mp_limb_t cy, int extra) +mpfr_mpn_sub_aux (mpfr_limb_ptr ap, mpfr_limb_ptr bp, mp_size_t n, + mp_limb_t cy, int extra) { mp_limb_t bb, rp; @@ -137,11 +139,11 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mpfr_rnd_t rnd_mode) mp_size_t qsize; /* number of limbs of the computed quotient */ mp_size_t qqsize; mp_size_t k; - mp_ptr q0p = MPFR_MANT(q), qp; - mp_ptr up = MPFR_MANT(u); - mp_ptr vp = MPFR_MANT(v); - mp_ptr ap; - mp_ptr bp; + mpfr_limb_ptr q0p = MPFR_MANT(q), qp; + mpfr_limb_ptr up = MPFR_MANT(u); + mpfr_limb_ptr vp = MPFR_MANT(v); + mpfr_limb_ptr ap; + mpfr_limb_ptr bp; mp_limb_t qh; mp_limb_t sticky_u = MPFR_LIMB_ZERO; mp_limb_t low_u; @@ -419,7 +421,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mpfr_rnd_t rnd_mode) r + low(u) has qsize + (usize-2*qsize) = usize-qsize limbs */ { mp_size_t l; - mp_ptr sp; + mpfr_limb_ptr sp; int cmp_s_r; mp_limb_t qh2; @@ -28,7 +28,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., int mpfr_eq (mpfr_srcptr u, mpfr_srcptr v, unsigned long int n_bits) { - mp_srcptr up, vp; + mpfr_limb_srcptr up, vp; mp_size_t usize, vsize, size, i; mpfr_exp_t uexp, vexp; int k; diff --git a/src/init2.c b/src/init2.c index 78194d138..e4329b666 100644 --- a/src/init2.c +++ b/src/init2.c @@ -26,7 +26,7 @@ void mpfr_init2 (mpfr_ptr x, mpfr_prec_t p) { mp_size_t xsize; - mp_ptr tmp; + mpfr_limb_ptr tmp; /* Check if we can represent the number of limbs * associated to the maximum of mpfr_prec_t*/ @@ -52,7 +52,7 @@ mpfr_init2 (mpfr_ptr x, mpfr_prec_t p) MPFR_ASSERTN(p >= MPFR_PREC_MIN && p <= MPFR_PREC_MAX); xsize = (mp_size_t) ((p - 1) / GMP_NUMB_BITS) + 1; - tmp = (mp_ptr) (*__gmp_allocate_func)(MPFR_MALLOC_SIZE(xsize)); + tmp = (mpfr_limb_ptr) (*__gmp_allocate_func)(MPFR_MALLOC_SIZE(xsize)); MPFR_PREC(x) = p; /* Set prec */ MPFR_EXP (x) = MPFR_EXP_INVALID; /* make sure that the exp field has a diff --git a/src/mpfr-gmp.h b/src/mpfr-gmp.h index 15c4e1a4c..d916d6bed 100644 --- a/src/mpfr-gmp.h +++ b/src/mpfr-gmp.h @@ -289,8 +289,8 @@ __MPFR_DECLSPEC void __gmp_default_free _MPFR_PROTO ((void *, size_t)); #if defined(WANT_GMP_INTERNALS) && defined(HAVE___GMPN_ROOTREM) #ifndef __gmpn_rootrem - __MPFR_DECLSPEC mp_size_t __gmpn_rootrem _MPFR_PROTO ((mp_ptr, mp_ptr, - mp_srcptr, mp_size_t, mp_limb_t)); + __MPFR_DECLSPEC mp_size_t __gmpn_rootrem _MPFR_PROTO ((mpfr_limb_ptr, + mpfr_limb_ptr, mpfr_limb_srcptr, mp_size_t, mp_limb_t)); #endif #endif diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h index bec792e78..bce7ff7c5 100644 --- a/src/mpfr-impl.h +++ b/src/mpfr-impl.h @@ -158,6 +158,15 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., /****************************************************** + ************* GMP Basic Pointer Types **************** + ******************************************************/ + +typedef mp_limb_t *mpfr_limb_ptr; +typedef __gmp_const mp_limb_t *mpfr_limb_srcptr; + + + +/****************************************************** ****************** (U)INTMAX_MAX ********************* ******************************************************/ @@ -1737,13 +1746,14 @@ __MPFR_DECLSPEC void mpfr_clear_cache _MPFR_PROTO ((mpfr_cache_t)); __MPFR_DECLSPEC int mpfr_cache _MPFR_PROTO ((mpfr_ptr, mpfr_cache_t, mpfr_rnd_t)); -__MPFR_DECLSPEC void mpfr_mulhigh_n _MPFR_PROTO ((mp_ptr, mp_srcptr, - mp_srcptr, mp_size_t)); -__MPFR_DECLSPEC void mpfr_mullow_n _MPFR_PROTO ((mp_ptr, mp_srcptr, - mp_srcptr, mp_size_t)); -__MPFR_DECLSPEC void mpfr_sqrhigh_n _MPFR_PROTO ((mp_ptr, mp_srcptr, mp_size_t)); -__MPFR_DECLSPEC mp_limb_t mpfr_divhigh_n _MPFR_PROTO ((mp_ptr qp, mp_ptr np, - mp_ptr dp, mp_size_t n)); +__MPFR_DECLSPEC void mpfr_mulhigh_n _MPFR_PROTO ((mpfr_limb_ptr, + mpfr_limb_srcptr, mpfr_limb_srcptr, mp_size_t)); +__MPFR_DECLSPEC void mpfr_mullow_n _MPFR_PROTO ((mpfr_limb_ptr, + mpfr_limb_srcptr, mpfr_limb_srcptr, mp_size_t)); +__MPFR_DECLSPEC void mpfr_sqrhigh_n _MPFR_PROTO ((mpfr_limb_ptr, + mpfr_limb_srcptr, mp_size_t)); +__MPFR_DECLSPEC mp_limb_t mpfr_divhigh_n _MPFR_PROTO ((mpfr_limb_ptr, + mpfr_limb_ptr, mpfr_limb_ptr, mp_size_t)); __MPFR_DECLSPEC int mpfr_round_p _MPFR_PROTO ((mp_limb_t *, mp_size_t, mpfr_exp_t, mpfr_prec_t)); @@ -1758,7 +1768,7 @@ __MPFR_DECLSPEC int mpfr_round_near_x _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, __MPFR_DECLSPEC void mpfr_abort_prec_max _MPFR_PROTO ((void)) MPFR_NORETURN_ATTR; -__MPFR_DECLSPEC void mpfr_rand_raw _MPFR_PROTO((mp_ptr, gmp_randstate_t, +__MPFR_DECLSPEC void mpfr_rand_raw _MPFR_PROTO((mpfr_limb_ptr, gmp_randstate_t, unsigned long)); __MPFR_DECLSPEC mpz_t* mpfr_bernoulli_internal _MPFR_PROTO((mpz_t*, diff --git a/src/mulders.c b/src/mulders.c index 0fb5fffdb..cb6e48a31 100644 --- a/src/mulders.c +++ b/src/mulders.c @@ -39,7 +39,8 @@ static short mulhigh_ktab[] = {MPFR_MULHIGH_TAB}; /* Put in rp[n..2n-1] an approximation of the n high limbs of {up, n} * {vp, n}. The error is less than n-1 ulps of rp[n]. */ static void -mpfr_mulhigh_n_basecase (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n) +mpfr_mulhigh_n_basecase (mpfr_limb_ptr rp, mpfr_limb_srcptr up, + mpfr_limb_srcptr vp, mp_size_t n) { mp_size_t i; @@ -55,7 +56,8 @@ mpfr_mulhigh_n_basecase (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n) /* Put in rp[n..2n-1] an approximation of the n high limbs of {np, n} * {mp, n}. The error is less than n-1 ulps of rp[n]. */ void -mpfr_mulhigh_n (mp_ptr rp, mp_srcptr np, mp_srcptr mp, mp_size_t n) +mpfr_mulhigh_n (mpfr_limb_ptr rp, mpfr_limb_srcptr np, mpfr_limb_srcptr mp, + mp_size_t n) { mp_size_t k; @@ -98,7 +100,7 @@ static short sqrhigh_ktab[] = {MPFR_SQRHIGH_TAB}; /* Put in rp[n..2n-1] an approximation of the n high limbs of {np, n}^2. The error is less than n ulps of rp[n]. */ void -mpfr_sqrhigh_n (mp_ptr rp, mp_srcptr np, mp_size_t n) +mpfr_sqrhigh_n (mpfr_limb_ptr rp, mpfr_limb_srcptr np, mp_size_t n) { mp_size_t k; @@ -140,11 +142,12 @@ static short divhigh_ktab[] = {MPFR_DIVHIGH_TAB}; THIS IS PRELIMINARY CODE, DO NOT USE IT. */ mp_limb_t -mpfr_divhigh_n (mp_ptr qp, mp_ptr np, mp_ptr dp, mp_size_t n) +mpfr_divhigh_n (mpfr_limb_ptr qp, mpfr_limb_ptr np, mpfr_limb_ptr dp, + mp_size_t n) { mp_size_t k, l; mp_limb_t qh, cy; - mp_ptr tp; + mpfr_limb_ptr tp; MPFR_TMP_DECL(marker); k = divhigh_ktab[n]; diff --git a/src/rec_sqrt.c b/src/rec_sqrt.c index ef49bd2fb..1450cc52d 100644 --- a/src/rec_sqrt.c +++ b/src/rec_sqrt.c @@ -70,8 +70,8 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., http://www.loria.fr/~zimmerma/mca/pub226.html */ static void -mpfr_mpn_rec_sqrt (mp_ptr x, mpfr_prec_t p, - mp_srcptr a, mpfr_prec_t ap, int as) +mpfr_mpn_rec_sqrt (mpfr_limb_ptr x, mpfr_prec_t p, + mpfr_limb_srcptr a, mpfr_prec_t ap, int as) { /* the following T1 and T2 are bipartite tables giving initial @@ -192,7 +192,7 @@ mpfr_mpn_rec_sqrt (mp_ptr x, mpfr_prec_t p, else /* p >= 12 */ { mpfr_prec_t h, pl; - mp_ptr r, s, t, u; + mpfr_limb_ptr r, s, t, u; mp_size_t xn, rn, th, ln, tn, sn, ahn, un; mp_limb_t neg, cy, cu; MPFR_TMP_DECL(marker); @@ -421,7 +421,7 @@ mpfr_rec_sqrt (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode) mpfr_prec_t rp, up, wp; mp_size_t rn, wn; int s, cy, inex; - mp_ptr x; + mpfr_limb_ptr x; MPFR_TMP_DECL(marker); MPFR_LOG_FUNC (("x[%#R]=%R rnd=%d", u, u, rnd_mode), diff --git a/src/round_prec.c b/src/round_prec.c index 8616390c1..cbc200574 100644 --- a/src/round_prec.c +++ b/src/round_prec.c @@ -69,7 +69,7 @@ mpfr_prec_round (mpfr_ptr x, mpfr_prec_t prec, mpfr_rnd_t rnd_mode) if (nw > ow) { /* Realloc significand */ - mp_ptr tmpx = (mp_ptr) (*__gmp_reallocate_func) + mpfr_limb_ptr tmpx = (mpfr_limb_ptr) (*__gmp_reallocate_func) (MPFR_GET_REAL_PTR(x), MPFR_MALLOC_SIZE(ow), MPFR_MALLOC_SIZE(nw)); MPFR_SET_MANT_PTR(x, tmpx); /* mant ptr must be set before alloc size */ diff --git a/src/set_d.c b/src/set_d.c index a95e3e492..b1a4c2d80 100644 --- a/src/set_d.c +++ b/src/set_d.c @@ -29,7 +29,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., /* extracts the bits of d in rp[0..n-1] where n=ceil(53/GMP_NUMB_BITS). Assumes d is neither 0 nor NaN nor Inf. */ static long -__gmpfr_extract_double (mp_ptr rp, double d) +__gmpfr_extract_double (mpfr_limb_ptr rp, double d) /* e=0 iff GMP_NUMB_BITS=32 and rp has only one limb */ { long exp; diff --git a/src/set_prec.c b/src/set_prec.c index a5f5887a6..ede9b25d9 100644 --- a/src/set_prec.c +++ b/src/set_prec.c @@ -26,7 +26,7 @@ void mpfr_set_prec (mpfr_ptr x, mpfr_prec_t p) { mp_size_t xsize, xoldsize; - mp_ptr tmp; + mpfr_limb_ptr tmp; /* first, check if p is correct */ MPFR_ASSERTN (p >= MPFR_PREC_MIN && p <= MPFR_PREC_MAX); @@ -38,7 +38,7 @@ mpfr_set_prec (mpfr_ptr x, mpfr_prec_t p) xoldsize = MPFR_GET_ALLOC_SIZE (x); if (xsize > xoldsize) { - tmp = (mp_ptr) (*__gmp_reallocate_func) + tmp = (mpfr_limb_ptr) (*__gmp_reallocate_func) (MPFR_GET_REAL_PTR(x), MPFR_MALLOC_SIZE(xoldsize), MPFR_MALLOC_SIZE(xsize)); MPFR_SET_MANT_PTR(x, tmp); MPFR_SET_ALLOC_SIZE(x, xsize); diff --git a/src/sqrt.c b/src/sqrt.c index 9a9a10cd4..d958ef64c 100644 --- a/src/sqrt.c +++ b/src/sqrt.c @@ -31,9 +31,9 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode) mp_size_t tsize; /* number of limbs of the sqrtrem remainder */ mp_size_t k; mp_size_t l; - mp_ptr rp, rp0; - mp_ptr up; - mp_ptr sp; + mpfr_limb_ptr rp, rp0; + mpfr_limb_ptr up; + mpfr_limb_ptr sp; mp_limb_t sticky0; /* truncated part of input */ mp_limb_t sticky1; /* truncated part of rp[0] */ mp_limb_t sticky; diff --git a/src/urandom.c b/src/urandom.c index dcc43ec0a..46c083047 100644 --- a/src/urandom.c +++ b/src/urandom.c @@ -41,7 +41,7 @@ random_rounding_bit (gmp_randstate_t rstate) int mpfr_urandom (mpfr_ptr rop, gmp_randstate_t rstate, mpfr_rnd_t rnd_mode) { - mp_ptr rp; + mpfr_limb_ptr rp; mpfr_prec_t nbits; mp_size_t nlimbs; mp_size_t n; diff --git a/src/urandomb.c b/src/urandomb.c index 27aef4a88..15c38d1b0 100644 --- a/src/urandomb.c +++ b/src/urandomb.c @@ -30,7 +30,8 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., /* generate nbits random bits into mp[], assuming mp was allocated to contain a sufficient number of limbs */ void -mpfr_rand_raw (mp_ptr mp, gmp_randstate_t rstate, unsigned long int nbits) +mpfr_rand_raw (mpfr_limb_ptr mp, gmp_randstate_t rstate, + unsigned long int nbits) { mpz_t z; @@ -43,7 +44,7 @@ mpfr_rand_raw (mp_ptr mp, gmp_randstate_t rstate, unsigned long int nbits) int mpfr_urandomb (mpfr_ptr rop, gmp_randstate_t rstate) { - mp_ptr rp; + mpfr_limb_ptr rp; mpfr_prec_t nbits; mp_size_t nlimbs; mp_size_t k; /* number of high zero limbs */ diff --git a/src/vasprintf.c b/src/vasprintf.c index 068f372ab..152875986 100644 --- a/src/vasprintf.c +++ b/src/vasprintf.c @@ -461,7 +461,7 @@ typedef wint_t mpfr_va_wint; (void) va_arg ((ap), mp_limb_t); \ break; \ case MP_LIMB_ARRAY_ARG: \ - (void) va_arg ((ap), mp_ptr); \ + (void) va_arg ((ap), mpfr_limb_ptr); \ (void) va_arg ((ap), mp_size_t); \ break; \ case MPZ_ARG: \ diff --git a/tests/random2.c b/tests/random2.c index beeeb8607..ececf01e3 100644 --- a/tests/random2.c +++ b/tests/random2.c @@ -36,7 +36,7 @@ mpfr_random2 (mpfr_ptr x, mp_size_t size, mpfr_exp_t exp, { mp_size_t xn, k, ri; unsigned long sh; - mp_ptr xp; + mp_limb_t *xp; mp_limb_t elimb, ran, acc; int ran_nbits, bit_pos, nb; diff --git a/tune/speed.c b/tune/speed.c index 7fc8d45e8..c8c7206fd 100644 --- a/tune/speed.c +++ b/tune/speed.c @@ -47,7 +47,7 @@ int verbose; #define SPEED_MPFR_FUNC(mean_fun) do { \ unsigned i; \ - mp_ptr wp; \ + mpfr_limb_ptr wp; \ double t; \ mpfr_t w, x; \ mp_size_t size; \ @@ -57,7 +57,7 @@ int verbose; SPEED_RESTRICT_COND (s->size <= MPFR_PREC_MAX); \ MPFR_TMP_MARK (marker); \ \ - size = (s->size-1)/GMP_NUMB_BITS+1; \ + size = (s->size-1)/GMP_NUMB_BITS+1; \ s->xp[size-1] |= MPFR_LIMB_HIGHBIT; \ MPFR_TMP_INIT1 (s->xp, x, s->size); \ MPFR_SET_EXP (x, 0); \ @@ -71,7 +71,7 @@ int verbose; speed_starttime (); \ i = s->reps; \ do \ - mean_fun (w, x, MPFR_RNDN); \ + mean_fun (w, x, MPFR_RNDN); \ while (--i != 0); \ t = speed_endtime (); \ \ @@ -81,7 +81,7 @@ int verbose; #define SPEED_MPFR_OP(mean_fun) do { \ unsigned i; \ - mp_ptr wp; \ + mpfr_limb_ptr wp; \ double t; \ mpfr_t w, x, y; \ mp_size_t size; \ @@ -91,7 +91,7 @@ int verbose; SPEED_RESTRICT_COND (s->size <= MPFR_PREC_MAX); \ MPFR_TMP_MARK (marker); \ \ - size = (s->size-1)/GMP_NUMB_BITS+1; \ + size = (s->size-1)/GMP_NUMB_BITS+1; \ s->xp[size-1] |= MPFR_LIMB_HIGHBIT; \ MPFR_TMP_INIT1 (s->xp, x, s->size); \ MPFR_SET_EXP (x, 0); \ @@ -109,7 +109,7 @@ int verbose; speed_starttime (); \ i = s->reps; \ do \ - mean_fun (w, x, y, MPFR_RNDN); \ + mean_fun (w, x, y, MPFR_RNDN); \ while (--i != 0); \ t = speed_endtime (); \ \ diff --git a/tune/tuneup.c b/tune/tuneup.c index caeef0578..19ae6bc3d 100644 --- a/tune/tuneup.c +++ b/tune/tuneup.c @@ -40,7 +40,7 @@ int verbose; do \ { \ unsigned i; \ - mp_ptr wp; \ + mpfr_limb_ptr wp; \ double t; \ mpfr_t w, x; \ mp_size_t size; \ @@ -78,7 +78,7 @@ int verbose; do \ { \ unsigned i; \ - mp_ptr vp, wp; \ + mpfr_limb_ptr vp, wp; \ double t; \ mpfr_t v, w, x; \ mp_size_t size; \ @@ -118,7 +118,7 @@ int verbose; do \ { \ unsigned i; \ - mp_ptr wp; \ + mpfr_limb_ptr wp; \ double t; \ mpfr_t w, x, y; \ mp_size_t size; \ @@ -156,11 +156,11 @@ int verbose; while (0) /* special template for mpfr_mul(a,b,b) */ -#define SPEED_MPFR_SQR(mean_fun) \ +#define SPEED_MPFR_SQR(mean_fun) \ do \ { \ unsigned i; \ - mp_ptr wp; \ + mpfr_limb_ptr wp; \ double t; \ mpfr_t w, x; \ mp_size_t size; \ @@ -202,7 +202,7 @@ int verbose; do \ { \ unsigned i; \ - mp_ptr wp; \ + mpfr_limb_ptr wp; \ double t; \ mpfr_t w, x; \ mp_size_t size; \ |