diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2011-01-03 20:00:11 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2011-01-03 20:00:11 +0100 |
commit | bb0d5b1f6b37144d9cde4d95144290ee9b3faea4 (patch) | |
tree | bdd6f6aba6a6d8181e2972fb21a04ee57bf751e2 | |
parent | 37d49aca5da88720e54d9c965daa1798be53faf6 (diff) | |
download | gmp-bb0d5b1f6b37144d9cde4d95144290ee9b3faea4.tar.gz |
Removed all #ifdef BERKELEY_MP.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | mpz/aors.h | 3 | ||||
-rw-r--r-- | mpz/cmp.c | 10 | ||||
-rw-r--r-- | mpz/gcd.c | 65 | ||||
-rw-r--r-- | mpz/mul.c | 17 | ||||
-rw-r--r-- | mpz/powm.c | 11 | ||||
-rw-r--r-- | mpz/set.c | 25 | ||||
-rw-r--r-- | mpz/sqrtrem.c | 39 | ||||
-rw-r--r-- | mpz/tdiv_qr.c | 10 |
9 files changed, 71 insertions, 116 deletions
@@ -1,6 +1,13 @@ 2011-01-03 Marco Bodrato <bodrato@mail.dm.unipi.it> * mpz/aors.h: Remove #ifdef BERKELEY_MP, and cleanup. + * mpz/cmp.c: Likewise. + * mpz/gcd.c: Likewise. + * mpz/mul.c: Likewise. + * mpz/powm.c: Likewise. + * mpz/set.c: Likewise. + * mpz/sqrtrem.c: Likewise. + * mpz/tdiv_qr.c: Likewise. 2010-12-28 Torbjorn Granlund <tege@gmplib.org> diff --git a/mpz/aors.h b/mpz/aors.h index a33613d0b..b52030361 100644 --- a/mpz/aors.h +++ b/mpz/aors.h @@ -30,7 +30,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #define FUNCTION mpz_sub #define VARIATION - #endif -#define ARGUMENTS mpz_ptr w, mpz_srcptr u, mpz_srcptr v #ifndef FUNCTION Error, need OPERATION_add or OPERATION_sub @@ -38,7 +37,7 @@ Error, need OPERATION_add or OPERATION_sub void -FUNCTION (ARGUMENTS) +FUNCTION (mpz_ptr w, mpz_srcptr u, mpz_srcptr v) { mp_srcptr up, vp; mp_ptr wp; @@ -1,7 +1,8 @@ /* mpz_cmp(u,v) -- Compare U, V. Return positive, zero, or negative based on if U > V, U == V, or U < V. -Copyright 1991, 1993, 1994, 1996, 2001, 2002 Free Software Foundation, Inc. +Copyright 1991, 1993, 1994, 1996, 2001, 2002, 2011 Free Software +Foundation, Inc. This file is part of the GNU MP Library. @@ -18,18 +19,11 @@ License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ -#ifdef BERKELEY_MP -#include "mp.h" -#endif #include "gmp.h" #include "gmp-impl.h" int -#ifdef BERKELEY_MP -mcmp (mpz_srcptr u, mpz_srcptr v) -#else mpz_cmp (mpz_srcptr u, mpz_srcptr v) __GMP_NOTHROW -#endif { mp_size_t usize, vsize, dsize, asize; mp_srcptr up, vp; @@ -1,7 +1,7 @@ /* mpz/gcd.c: Calculate the greatest common divisor of two integers. -Copyright 1991, 1993, 1994, 1996, 2000, 2001, 2002, 2005 Free Software -Foundation, Inc. +Copyright 1991, 1993, 1994, 1996, 2000, 2001, 2002, 2005, 2010 Free +Software Foundation, Inc. This file is part of the GNU MP Library. @@ -21,63 +21,58 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" -#ifdef BERKELEY_MP -#include "mp.h" -#endif void -#ifndef BERKELEY_MP mpz_gcd (mpz_ptr g, mpz_srcptr u, mpz_srcptr v) -#else /* BERKELEY_MP */ -gcd (mpz_srcptr u, mpz_srcptr v, mpz_ptr g) -#endif /* BERKELEY_MP */ { unsigned long int g_zero_bits, u_zero_bits, v_zero_bits; mp_size_t g_zero_limbs, u_zero_limbs, v_zero_limbs; mp_ptr tp; - mp_ptr up = u->_mp_d; - mp_size_t usize = ABS (u->_mp_size); - mp_ptr vp = v->_mp_d; - mp_size_t vsize = ABS (v->_mp_size); + mp_ptr up; + mp_size_t usize; + mp_ptr vp; + mp_size_t vsize; mp_size_t gsize; TMP_DECL; + up = PTR(u); + usize = ABSIZ (u); + vp = PTR(v); + vsize = ABSIZ (v); /* GCD(0, V) == V. */ if (usize == 0) { - g->_mp_size = vsize; + SIZ (g) = vsize; if (g == v) return; - if (g->_mp_alloc < vsize) - _mpz_realloc (g, vsize); - MPN_COPY (g->_mp_d, vp, vsize); + MPZ_REALLOC (g, vsize); + MPN_COPY (PTR (g), vp, vsize); return; } /* GCD(U, 0) == U. */ if (vsize == 0) { - g->_mp_size = usize; + SIZ (g) = usize; if (g == u) return; - if (g->_mp_alloc < usize) - _mpz_realloc (g, usize); - MPN_COPY (g->_mp_d, up, usize); + MPZ_REALLOC (g, usize); + MPN_COPY (PTR (g), up, usize); return; } if (usize == 1) { - g->_mp_size = 1; - g->_mp_d[0] = mpn_gcd_1 (vp, vsize, up[0]); + SIZ (g) = 1; + PTR (g)[0] = mpn_gcd_1 (vp, vsize, up[0]); return; } if (vsize == 1) { - g->_mp_size = 1; - g->_mp_d[0] = mpn_gcd_1 (up, usize, vp[0]); + SIZ(g) = 1; + PTR (g)[0] = mpn_gcd_1 (up, usize, vp[0]); return; } @@ -86,7 +81,7 @@ gcd (mpz_srcptr u, mpz_srcptr v, mpz_ptr g) /* Eliminate low zero bits from U and V and move to temporary storage. */ while (*up == 0) up++; - u_zero_limbs = up - u->_mp_d; + u_zero_limbs = up - PTR(u); usize -= u_zero_limbs; count_trailing_zeros (u_zero_bits, *up); tp = up; @@ -101,7 +96,7 @@ gcd (mpz_srcptr u, mpz_srcptr v, mpz_ptr g) while (*vp == 0) vp++; - v_zero_limbs = vp - v->_mp_d; + v_zero_limbs = vp - PTR (v); vsize -= v_zero_limbs; count_trailing_zeros (v_zero_bits, *vp); tp = vp; @@ -141,23 +136,21 @@ gcd (mpz_srcptr u, mpz_srcptr v, mpz_ptr g) { mp_limb_t cy_limb; gsize += (vp[vsize - 1] >> (GMP_NUMB_BITS - g_zero_bits)) != 0; - if (g->_mp_alloc < gsize) - _mpz_realloc (g, gsize); - MPN_ZERO (g->_mp_d, g_zero_limbs); + MPZ_REALLOC (g, gsize); + MPN_ZERO (PTR (g), g_zero_limbs); - tp = g->_mp_d + g_zero_limbs; + tp = PTR(g) + g_zero_limbs; cy_limb = mpn_lshift (tp, vp, vsize, g_zero_bits); if (cy_limb != 0) tp[vsize] = cy_limb; } else { - if (g->_mp_alloc < gsize) - _mpz_realloc (g, gsize); - MPN_ZERO (g->_mp_d, g_zero_limbs); - MPN_COPY (g->_mp_d + g_zero_limbs, vp, vsize); + MPZ_REALLOC (g, gsize); + MPN_ZERO (PTR (g), g_zero_limbs); + MPN_COPY (PTR (g) + g_zero_limbs, vp, vsize); } - g->_mp_size = gsize; + SIZ (g) = gsize; TMP_FREE; } @@ -1,7 +1,7 @@ /* mpz_mul -- Multiply two integers. -Copyright 1991, 1993, 1994, 1996, 2000, 2001, 2005, 2009 Free Software -Foundation, Inc. +Copyright 1991, 1993, 1994, 1996, 2000, 2001, 2005, 2009, 2011 Free +Software Foundation, Inc. This file is part of the GNU MP Library. @@ -21,20 +21,13 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include <stdio.h> /* for NULL */ #include "gmp.h" #include "gmp-impl.h" -#ifdef BERKELEY_MP -#include "mp.h" -#endif void -#ifndef BERKELEY_MP mpz_mul (mpz_ptr w, mpz_srcptr u, mpz_srcptr v) -#else /* BERKELEY_MP */ -mult (mpz_srcptr u, mpz_srcptr v, mpz_ptr w) -#endif /* BERKELEY_MP */ { - mp_size_t usize = SIZ(u); - mp_size_t vsize = SIZ(v); + mp_size_t usize; + mp_size_t vsize; mp_size_t wsize; mp_size_t sign_product; mp_ptr up, vp; @@ -44,6 +37,8 @@ mult (mpz_srcptr u, mpz_srcptr v, mpz_ptr w) mp_limb_t cy_limb; TMP_DECL; + usize = SIZ(u); + vsize = SIZ(v); sign_product = usize ^ vsize; usize = ABS (usize); vsize = ABS (vsize); diff --git a/mpz/powm.c b/mpz/powm.c index 369fd36c3..ea3900e8d 100644 --- a/mpz/powm.c +++ b/mpz/powm.c @@ -2,8 +2,8 @@ Contributed to the GNU project by Torbjorn Granlund. -Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2005, 2008, 2009 -Free Software Foundation, Inc. +Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2005, 2008, +2009, 2011 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -24,9 +24,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" -#ifdef BERKELEY_MP -#include "mp.h" -#endif /* TODO @@ -52,11 +49,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #define HANDLE_NEGATIVE_EXPONENT 1 void -#ifndef BERKELEY_MP mpz_powm (mpz_ptr r, mpz_srcptr b, mpz_srcptr e, mpz_srcptr m) -#else /* BERKELEY_MP */ -pow (mpz_srcptr b, mpz_srcptr e, mpz_srcptr m, mpz_ptr r) -#endif /* BERKELEY_MP */ { mp_size_t n, nodd, ncnt; int cnt; @@ -21,33 +21,20 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" -#ifdef BERKELEY_MP -#include "mp.h" -#define FUNCTION move -#define ARGUMENTS mpz_srcptr u, mpz_ptr w - -#else -#define FUNCTION mpz_set -#define ARGUMENTS mpz_ptr w, mpz_srcptr u - -#endif - - void -FUNCTION (ARGUMENTS) +mpz_set (mpz_ptr w, mpz_srcptr u) { mp_ptr wp, up; mp_size_t usize, size; - usize = u->_mp_size; + usize = SIZ(u); size = ABS (usize); - if (w->_mp_alloc < size) - _mpz_realloc (w, size); + MPZ_REALLOC (w, size); - wp = w->_mp_d; - up = u->_mp_d; + wp = PTR(w); + up = PTR(u); MPN_COPY (wp, up, size); - w->_mp_size = usize; + SIZ(w) = usize; } diff --git a/mpz/sqrtrem.c b/mpz/sqrtrem.c index 87d18d511..e853f168f 100644 --- a/mpz/sqrtrem.c +++ b/mpz/sqrtrem.c @@ -1,8 +1,8 @@ /* mpz_sqrtrem(root,rem,x) -- Set ROOT to floor(sqrt(X)) and REM to the remainder, i.e. X - ROOT**2. -Copyright 1991, 1993, 1994, 1996, 2000, 2001, 2005 Free Software Foundation, -Inc. +Copyright 1991, 1993, 1994, 1996, 2000, 2001, 2005, 2011 Free Software +Foundation, Inc. This file is part of the GNU MP Library. @@ -22,25 +22,19 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include <stdio.h> /* for NULL */ #include "gmp.h" #include "gmp-impl.h" -#ifdef BERKELEY_MP -#include "mp.h" -#endif void -#ifndef BERKELEY_MP mpz_sqrtrem (mpz_ptr root, mpz_ptr rem, mpz_srcptr op) -#else /* BERKELEY_MP */ -msqrt (mpz_srcptr op, mpz_ptr root, mpz_ptr rem) -#endif /* BERKELEY_MP */ { mp_size_t op_size, root_size, rem_size; mp_ptr root_ptr, op_ptr; - mp_ptr free_me = NULL; + mp_ptr free_me; mp_size_t free_me_size; TMP_DECL; TMP_MARK; - op_size = op->_mp_size; + free_me = NULL; + op_size = SIZ (op); if (op_size <= 0) { if (op_size < 0) @@ -50,28 +44,27 @@ msqrt (mpz_srcptr op, mpz_ptr root, mpz_ptr rem) return; } - if (rem->_mp_alloc < op_size) - _mpz_realloc (rem, op_size); + MPZ_REALLOC (rem, op_size); /* The size of the root is accurate after this simple calculation. */ root_size = (op_size + 1) / 2; - root_ptr = root->_mp_d; - op_ptr = op->_mp_d; + root_ptr = PTR (root); + op_ptr = PTR (op); - if (root->_mp_alloc < root_size) + if (ALLOC (root) < root_size) { if (root_ptr == op_ptr) { free_me = root_ptr; - free_me_size = root->_mp_alloc; + free_me_size = ALLOC (root); } else - (*__gmp_free_func) (root_ptr, root->_mp_alloc * BYTES_PER_MP_LIMB); + (*__gmp_free_func) (root_ptr, ALLOC (root) * BYTES_PER_MP_LIMB); - root->_mp_alloc = root_size; + ALLOC (root) = root_size; root_ptr = (mp_ptr) (*__gmp_allocate_func) (root_size * BYTES_PER_MP_LIMB); - root->_mp_d = root_ptr; + PTR (root) = root_ptr; } else { @@ -86,14 +79,14 @@ msqrt (mpz_srcptr op, mpz_ptr root, mpz_ptr rem) } } - rem_size = mpn_sqrtrem (root_ptr, rem->_mp_d, op_ptr, op_size); + rem_size = mpn_sqrtrem (root_ptr, PTR (rem), op_ptr, op_size); - root->_mp_size = root_size; + SIZ (root) = root_size; /* Write remainder size last, to enable us to define this function to give only the square root remainder, if the user calls if with ROOT == REM. */ - rem->_mp_size = rem_size; + SIZ (rem) = rem_size; if (free_me != NULL) (*__gmp_free_func) (free_me, free_me_size * BYTES_PER_MP_LIMB); diff --git a/mpz/tdiv_qr.c b/mpz/tdiv_qr.c index 64b6e03f0..120b0f27b 100644 --- a/mpz/tdiv_qr.c +++ b/mpz/tdiv_qr.c @@ -1,7 +1,8 @@ /* mpz_tdiv_qr(quot,rem,dividend,divisor) -- Set QUOT to DIVIDEND/DIVISOR, and REM to DIVIDEND mod DIVISOR. -Copyright 1991, 1993, 1994, 2000, 2001, 2005 Free Software Foundation, Inc. +Copyright 1991, 1993, 1994, 2000, 2001, 2005, 2011 Free Software +Foundation, Inc. This file is part of the GNU MP Library. @@ -21,16 +22,9 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" -#ifdef BERKELEY_MP -#include "mp.h" -#endif void -#ifndef BERKELEY_MP mpz_tdiv_qr (mpz_ptr quot, mpz_ptr rem, mpz_srcptr num, mpz_srcptr den) -#else /* BERKELEY_MP */ -mdiv (mpz_srcptr num, mpz_srcptr den, mpz_ptr quot, mpz_ptr rem) -#endif /* BERKELEY_MP */ { mp_size_t ql; mp_size_t ns, ds, nl, dl; |