Apply GMP 4.2.1 patches to MPIR

This commit is contained in:
brgladman 2008-05-19 16:03:48 +00:00
parent 083b01a860
commit f6ef7209a4
3 changed files with 11 additions and 18 deletions

View File

@ -974,21 +974,11 @@ __GMP_DECLSPEC extern gmp_randstate_t __gmp_rands;
fastest hardware currently (2003) would need 100 million years, which
suggests that these limits are acceptable. */
#if WANT_FFT
#if HAVE_NATIVE_mpn_sublsh1_n
#define MPN_TOOM3_MUL_N_TSIZE(n) (2*(n) + 63)
#define MPN_TOOM3_SQR_N_TSIZE(n) (2*(n) + 63)
#else
#define MPN_TOOM3_MUL_N_TSIZE(n) (2*(n) + 2*(n/3) + 63)
#define MPN_TOOM3_SQR_N_TSIZE(n) (2*(n) + 2*(n/3) + 63)
#endif
#else /* WANT_FFT */
#if HAVE_NATIVE_mpn_sublsh1_n
#define MPN_TOOM3_MUL_N_TSIZE(n) (2*(n) + 255)
#define MPN_TOOM3_SQR_N_TSIZE(n) (2*(n) + 255)
#else
#define MPN_TOOM3_MUL_N_TSIZE(n) (2*(n) + 2*(n/3) + 255)
#define MPN_TOOM3_SQR_N_TSIZE(n) (2*(n) + 2*(n/3) + 255)
#endif
#define MPN_TOOM3_MAX_N 285405
#endif /* WANT_FFT */

View File

@ -1,6 +1,6 @@
/* mpn_addsub_n -- Add and Subtract two limb vectors of equal, non-zero length.
Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
Copyright 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@ -58,13 +58,13 @@ mpn_addsub_n (mp_ptr r1p, mp_ptr r2p, mp_srcptr s1p, mp_srcptr s2p, mp_size_t n)
for (off = 0; off < n; off += PART_SIZE)
{
this_n = MIN (n - off, PART_SIZE);
#if HAVE_NATIVE_mpn_add_nc || !HAVE_NATIVE_mpn_add_n
#if HAVE_NATIVE_mpn_add_nc
acyo = mpn_add_nc (r1p + off, s1p + off, s2p + off, this_n, acyo);
#else
acyn = mpn_add_n (r1p + off, s1p + off, s2p + off, this_n);
acyo = acyn + mpn_add_1 (r1p + off, r1p + off, this_n, acyo);
#endif
#if HAVE_NATIVE_mpn_sub_nc || !HAVE_NATIVE_mpn_sub_n
#if HAVE_NATIVE_mpn_sub_nc
scyo = mpn_sub_nc (r2p + off, s1p + off, s2p + off, this_n, scyo);
#else
scyn = mpn_sub_n (r2p + off, s1p + off, s2p + off, this_n);
@ -81,13 +81,13 @@ mpn_addsub_n (mp_ptr r1p, mp_ptr r2p, mp_srcptr s1p, mp_srcptr s2p, mp_size_t n)
for (off = 0; off < n; off += PART_SIZE)
{
this_n = MIN (n - off, PART_SIZE);
#if HAVE_NATIVE_mpn_sub_nc || !HAVE_NATIVE_mpn_sub_n
#if HAVE_NATIVE_mpn_sub_nc
scyo = mpn_sub_nc (r2p + off, s1p + off, s2p + off, this_n, scyo);
#else
scyn = mpn_sub_n (r2p + off, s1p + off, s2p + off, this_n);
scyo = scyn + mpn_sub_1 (r2p + off, r2p + off, this_n, scyo);
#endif
#if HAVE_NATIVE_mpn_add_nc || !HAVE_NATIVE_mpn_add_n
#if HAVE_NATIVE_mpn_add_nc
acyo = mpn_add_nc (r1p + off, s1p + off, s2p + off, this_n, acyo);
#else
acyn = mpn_add_n (r1p + off, s1p + off, s2p + off, this_n);
@ -97,7 +97,7 @@ mpn_addsub_n (mp_ptr r1p, mp_ptr r2p, mp_srcptr s1p, mp_srcptr s2p, mp_size_t n)
}
else
{
/* r1 and r2 are identical to s1 and s2 (r1==s1 and r2=s2 or vice versa)
/* r1 and r2 are identical to s1 and s2 (r1==s1 and r2==s2 or vice versa)
Need temporary storage. */
mp_limb_t tp[PART_SIZE];
acyo = 0;
@ -105,13 +105,13 @@ mpn_addsub_n (mp_ptr r1p, mp_ptr r2p, mp_srcptr s1p, mp_srcptr s2p, mp_size_t n)
for (off = 0; off < n; off += PART_SIZE)
{
this_n = MIN (n - off, PART_SIZE);
#if HAVE_NATIVE_mpn_add_nc || !HAVE_NATIVE_mpn_add_n
#if HAVE_NATIVE_mpn_add_nc
acyo = mpn_add_nc (tp, s1p + off, s2p + off, this_n, acyo);
#else
acyn = mpn_add_n (tp, s1p + off, s2p + off, this_n);
acyo = acyn + mpn_add_1 (tp, tp, this_n, acyo);
#endif
#if HAVE_NATIVE_mpn_sub_nc || !HAVE_NATIVE_mpn_sub_n
#if HAVE_NATIVE_mpn_sub_nc
scyo = mpn_sub_nc (r2p + off, s1p + off, s2p + off, this_n, scyo);
#else
scyn = mpn_sub_n (r2p + off, s1p + off, s2p + off, this_n);

View File

@ -56,6 +56,9 @@ mpz_set_d (mpz_ptr r, double d)
if (ALLOC(r) < rn)
_mpz_realloc (r, rn);
if (rn <= 0)
rn = 0;
rp = PTR (r);
switch (rn)