diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-10-28 17:33:01 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-10-28 17:33:01 +0000 |
commit | a721e12b15d0f19534b3c301cdb27be12e2c24ed (patch) | |
tree | 0a65600ed589db15bd730137a78ee2942b1c7e71 | |
parent | d1ac2e8949afff094f5e7de849bd46977d3cf8fe (diff) | |
download | mpfr-a721e12b15d0f19534b3c301cdb27be12e2c24ed.tar.gz |
adapt mini-gmp stuff to GMP 6.1.0-rc1
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9701 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | doc/mini-gmp | 6 | ||||
-rw-r--r-- | src/free_cache.c | 6 | ||||
-rw-r--r-- | src/mpfr-mini-gmp.c | 118 | ||||
-rw-r--r-- | src/mpfr-mini-gmp.h | 14 |
4 files changed, 25 insertions, 119 deletions
diff --git a/doc/mini-gmp b/doc/mini-gmp index af2757fed..1a98996d9 100644 --- a/doc/mini-gmp +++ b/doc/mini-gmp @@ -2,6 +2,7 @@ How to compile GNU MPFR with mini-gmp ===================================== (this was tested with MPFR 3.1.2 and GMP 5.1.3 on x86_64 GNU/Linux machine) +(also with MPFR svn 9700 and GMP 6.1.0-rc1: some GMP functions are missing) 1) extract the GMP tarball in say /tmp/gmp-5.1.3 go into /tmp/gmp-5.1.3/mini-gmp @@ -34,6 +35,11 @@ $ diff gmp.h.orig gmp.h > typedef long int __gmp_randstate_struct; > typedef __gmp_randstate_struct gmp_randstate_t[1]; +You also need to define GMP_NUMB_BITS and GMP_NAIL_BITS, for example: + +#define GMP_NUMB_BITS 64 +#define GMP_NAIL_BITS 0 + 4) extract the MPFR tarball in say /tmp/mpfr-3.1.2 ./configure --with-gmp=/tmp --enable-mini-gmp diff --git a/src/free_cache.c b/src/free_cache.c index 90bd207ea..8c46058fb 100644 --- a/src/free_cache.c +++ b/src/free_cache.c @@ -24,7 +24,11 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., /* Default value for the cache of mpz_t */ #ifndef MPFR_MY_MPZ_INIT -# define MPFR_MY_MPZ_INIT 32 +# ifndef MPFR_USE_MINI_GMP +# define MPFR_MY_MPZ_INIT 32 +# else +# define MPFR_MY_MPZ_INIT 0 +# endif #endif /* If the number of value to cache is not zero */ diff --git a/src/mpfr-mini-gmp.c b/src/mpfr-mini-gmp.c index 344db6792..17756cf1f 100644 --- a/src/mpfr-mini-gmp.c +++ b/src/mpfr-mini-gmp.c @@ -29,10 +29,6 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #include "mpfr-mini-gmp.h" -#ifndef mp_bits_per_limb -const int mp_bits_per_limb = GMP_NUMB_BITS; -#endif - #ifdef WANT_gmp_randinit_default void gmp_randinit_default (gmp_randstate_t state) @@ -79,49 +75,15 @@ gmp_default_free (void *x, size_t s) } #endif -#ifdef WANT_mpn_scan1 -mp_bitcnt_t -mpn_scan1 (const mp_limb_t *s, mp_bitcnt_t n) -{ - while (1) - { - if (s[n / GMP_NUMB_BITS] & (MPFR_LIMB_ONE << (n % GMP_NUMB_BITS))) - return n; - n ++; - } -} -#endif - -#ifdef WANT_mpz_perfect_square_p -int -mpz_perfect_square_p (const mpz_t z) -{ - mpz_t s, r; - int ret; - - if (mpz_sgn (z) < 0) - return 0; - - mpz_init (s); - mpz_init (r); - mpz_sqrtrem (s, r, z); - ret = mpz_sgn (r) == 0; - mpz_clear (s); - mpz_clear (r); - return ret; -} -#endif - -#ifdef WANT_mpz_addmul_ui -void -mpz_addmul_ui (mpz_t a, const mpz_t b, unsigned long c) +#ifdef WANT_mpn_neg +mp_limb_t +mpn_neg (mp_limb_t *rp, const mp_limb_t *sp, mp_size_t n) { - mpz_t t; + mp_size_t i; - mpz_init (t); - mpz_mul_ui (t, b, c); - mpz_add (a, a, t); - mpz_clear (t); + for (i = 0; i < n; i++) + rp[i] = ~sp[i]; + return mpn_add_1 (rp, rp, n, (mp_limb_t) 1); } #endif @@ -164,29 +126,13 @@ mpn_divrem_1 (mp_limb_t *qp, mp_size_t qxn, mp_limb_t *np, mp_size_t nn, } #endif -#ifdef WANT_mpz_realloc2 -void -mpz_realloc2 (mpz_t x, mp_bitcnt_t nbits) -{ - unsigned long n = (nbits - 1) / GMP_NUMB_BITS + 1; - - if (n > x->_mp_alloc) - { - x->_mp_d = gmp_default_realloc (x->_mp_d, - x->_mp_alloc * sizeof (mp_limb_t), - n * sizeof (mp_limb_t)); - x->_mp_alloc = n; - } -} -#endif - static mp_limb_t random_limb (void) { #if GMP_NUMB_BITS == 32 return lrand48 (); #else - return ((mp_limb_t) lrand48 ()) << 32 + lrand48 (); + return (((mp_limb_t) lrand48 ()) << 32) + lrand48 (); #endif } @@ -197,7 +143,7 @@ mpz_urandomb (mpz_t rop, gmp_randstate_t state, mp_bitcnt_t nbits) unsigned long n, i; mpz_realloc2 (rop, nbits); - n = (N - 1) / GMP_NUMB_BITS + 1; /* number of limbs */ + n = (nbits - 1) / GMP_NUMB_BITS + 1; /* number of limbs */ for (i = n; i-- > 0;) rop->_mp_d[i] = random_limb (); i = n * GMP_NUMB_BITS - nbits; @@ -210,26 +156,6 @@ mpz_urandomb (mpz_t rop, gmp_randstate_t state, mp_bitcnt_t nbits) } #endif -#ifdef WANT_mpn_zero -void -mpn_zero (mp_limb_t *rp, mp_size_t n) -{ - memset (rp, 0, n * sizeof (mp_limb_t)); -} -#endif - -#ifdef WANT_mpn_popcount -mp_bitcnt_t -mpn_popcount (const mp_limb_t *s1p, mp_size_t n) -{ - mpz_t t; - - t->_mp_d = (mp_limb_t*) s1p; - t->_mp_size = n; - return mpz_popcount (t); -} -#endif - #ifdef WANT_mpn_divrem mp_limb_t mpn_divrem (mp_limb_t *qp, mp_size_t qn, mp_limb_t *np, @@ -260,32 +186,6 @@ mpn_divrem (mp_limb_t *qp, mp_size_t qn, mp_limb_t *np, } #endif -#ifdef WANT_mpz_submul -void -mpz_submul (mpz_t rop, const mpz_t op1, const mpz_t op2) -{ - mpz_t t; - - mpz_init (t); - mpz_mul (t, op1, op2); - mpz_sub (rop, rop, t); - mpz_clear (t); -} -#endif - -#ifdef WANT_mpz_addmul -void -mpz_addmul (mpz_t rop, const mpz_t op1, const mpz_t op2) -{ - mpz_t t; - - mpz_init (t); - mpz_mul (t, op1, op2); - mpz_add (rop, rop, t); - mpz_clear (t); -} -#endif - #ifdef WANT_mpn_tdiv_qr void mpn_tdiv_qr (mp_limb_t *qp, mp_limb_t *rp, mp_size_t qxn, diff --git a/src/mpfr-mini-gmp.h b/src/mpfr-mini-gmp.h index 215b42496..4072135b8 100644 --- a/src/mpfr-mini-gmp.h +++ b/src/mpfr-mini-gmp.h @@ -31,10 +31,6 @@ extern char gmp_version[]; #define GMP_NUMB_BITS 64 #endif -#ifndef mp_bits_per_limb -extern const int mp_bits_per_limb; -#endif - #ifndef __gmp_allocate_func #define __gmp_allocate_func gmp_default_alloc #define __gmp_reallocate_func gmp_default_realloc @@ -76,6 +72,11 @@ void gmp_default_free (void *, size_t); mp_bitcnt_t mpn_scan1 (const mp_limb_t *, mp_bitcnt_t); #endif +#ifndef mpn_neg +#define WANT_mpn_neg +mp_limb_t mpn_neg (mp_limb_t *rp, const mp_limb_t *sp, mp_size_t n); +#endif + #ifndef mpz_perfect_square_p #define WANT_mpz_perfect_square_p int mpz_perfect_square_p (const mpz_t); @@ -134,11 +135,6 @@ void mpn_tdiv_qr (mp_limb_t *, mp_limb_t *, mp_size_t, const mp_limb_t *, mp_size_t, const mp_limb_t *, mp_size_t); #endif -#ifndef mpn_sqrtrem -#define WANT_mpn_sqrtrem -mp_size_t mpn_sqrtrem (mp_limb_t *, mp_limb_t *, const mp_limb_t *, mp_size_t); -#endif - #ifndef mpz_dump #define WANT_mpz_dump void mpz_dump (mpz_t); |