[gmp-ecm] Add -gmp51 patch to deal with changes in GMP 5.1.
Jerry James
jjames at fedoraproject.org
Sat Feb 23 23:43:18 UTC 2013
commit 4d09f27237437b4ce6e3229ee08684065f553784
Author: Jerry James <loganjerry at gmail.com>
Date: Sat Feb 23 16:42:57 2013 -0700
Add -gmp51 patch to deal with changes in GMP 5.1.
gmp-ecm-gmp51.patch | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++
gmp-ecm.spec | 6 ++
2 files changed, 137 insertions(+), 0 deletions(-)
---
diff --git a/gmp-ecm-gmp51.patch b/gmp-ecm-gmp51.patch
new file mode 100644
index 0000000..d6c2057
--- /dev/null
+++ b/gmp-ecm-gmp51.patch
@@ -0,0 +1,131 @@
+This is SVN revision 2320, whose log says:
+
+ [mpmod.c] fix to deal with change of semantics of the internal GMP functions
+ mpn_redc_1 and mpn_redc_2
+
+and also SVN revision 2415, whose log says:
+
+ Merge r2412,r2413 from 6.4.4 branch:
+ Define correct __gmpn_redc_{12} prototype for GMP <5.1. Define REDC{12}
+ macros only if the functions exist.
+ Test was backwards :(
+
+--- ./mpmod.c.orig 2012-06-12 06:13:19.000000000 -0600
++++ ./mpmod.c 2013-02-23 16:09:58.442808398 -0700
+@@ -50,6 +50,30 @@ static void ecm_mulredc_basecase (mpres_
+ static void base2mod (mpres_t, const mpres_t, mpres_t, mpmod_t) ATTRIBUTE_HOT;
+ static void REDC (mpres_t, const mpres_t, mpz_t, mpmod_t);
+
++/* Up from GMP 5.1.0, mpn_redc{1,2} do not subtract the modulus if needed,
++ but return the carry of the final addition */
++#ifdef HAVE___GMPN_REDC_1
++#ifdef MPN_REDC12_RETURNS_CARRY
++#define REDC1(rp,cp,np,nn,invm) \
++ do {if (__gmpn_redc_1 (rp,cp,np,nn,invm)) \
++ mpn_sub_n (rp, rp, np, nn); \
++ } while (0)
++#else
++#define REDC1(rp,cp,np,nn,invm) __gmpn_redc_1(rp,cp,np,nn,invm)
++#endif
++#endif
++
++#ifdef HAVE___GMPN_REDC_2
++#ifdef MPN_REDC12_RETURNS_CARRY
++#define REDC2(rp,cp,np,nn,invm) \
++ do { if (__gmpn_redc_2 (rp,cp,np,nn,invm)) \
++ mpn_sub_n (rp, rp, np, nn); \
++ } while (0)
++#else
++#define REDC2(rp,cp,np,nn,invm) __gmpn_redc_2(rp,cp,np,nn,invm)
++#endif
++#endif
++
+ #if 0 /* PZ: commented out, since I don't see how to use this code.
+ Indeed, we need a large enough value of K to get significant
+ timings; however, for small B1 a too large value of K will
+@@ -316,10 +340,10 @@ redc_basecase_n (mp_ptr rp, mp_ptr cp, m
+ const mp_ptr invm)
+ {
+ #ifdef HAVE___GMPN_REDC_2
+- __gmpn_redc_2 (rp, cp, np, nn, invm);
++ REDC2(rp, cp, np, nn, invm);
+ #else /* HAVE___GMPN_REDC_2 is not defined */
+ #ifdef HAVE___GMPN_REDC_1
+- __gmpn_redc_1 (rp, cp, np, nn, invm[0]);
++ REDC1(rp, cp, np, nn, invm[0]);
+ #else /* neither HAVE___GMPN_REDC_2 nor HAVE___GMPN_REDC_1 is defined */
+ mp_limb_t cy;
+ mp_size_t j;
+@@ -343,7 +367,6 @@ redc_basecase_n (mp_ptr rp, mp_ptr cp, m
+ }
+ #endif /* HAVE___GMPN_REDC_1 */
+ #endif /* HAVE___GMPN_REDC_2 */
+- /* Note: both mpn_redc_1 and mpn_redc_2 subtract N if needed */
+ }
+
+ /* r <- c/R^nn mod n, where n has nn limbs, and R=2^GMP_NUMB_BITS.
+@@ -642,13 +665,13 @@ ecm_mulredc_basecase_n (mp_ptr rp, mp_sr
+ case MPMOD_MUL_REDC1: /* mpn_mul_n + __gmpn_redc_1 */
+ #ifdef HAVE___GMPN_REDC_1
+ mpn_mul_n (tmp, s1p, s2p, nn);
+- __gmpn_redc_1 (rp, tmp, np, nn, invm[0]);
++ REDC1(rp, tmp, np, nn, invm[0]);
+ break;
+ #endif /* otherwise go through to the next available mode */
+ case MPMOD_MUL_REDC2: /* mpn_mul_n + __gmpn_redc_2 */
+ #ifdef HAVE___GMPN_REDC_2
+ mpn_mul_n (tmp, s1p, s2p, nn);
+- __gmpn_redc_2 (rp, tmp, np, nn, invm);
++ REDC2(rp, tmp, np, nn, invm);
+ break;
+ #endif /* otherwise go through to the next available mode */
+ case MPMOD_MUL_REDCN: /* mpn_mul_n + __gmpn_redc_n */
+@@ -699,13 +722,13 @@ ecm_sqrredc_basecase_n (mp_ptr rp, mp_sr
+ case MPMOD_MUL_REDC1: /* mpn_sqr + __gmpn_redc_1 */
+ #ifdef HAVE___GMPN_REDC_1
+ mpn_sqr (tmp, s1p, nn);
+- __gmpn_redc_1 (rp, tmp, np, nn, invm[0]);
++ REDC1(rp, tmp, np, nn, invm[0]);
+ break;
+ #endif /* otherwise go through to the next available mode */
+ case MPMOD_MUL_REDC2: /* mpn_sqr + __gmpn_redc_2 */
+ #ifdef HAVE___GMPN_REDC_2
+ mpn_sqr (tmp, s1p, nn);
+- __gmpn_redc_2 (rp, tmp, np, nn, invm);
++ REDC2(rp, tmp, np, nn, invm);
+ break;
+ #endif /* otherwise go through to the next available mode */
+ case MPMOD_MUL_REDCN: /* mpn_sqr + __gmpn_redc_n */
+--- ./ecm-gmp.h.orig 2012-06-12 06:13:19.000000000 -0600
++++ ./ecm-gmp.h 2013-02-23 16:18:45.470080784 -0700
+@@ -123,13 +123,28 @@ __GMP_DECLSPEC mp_limb_t __gmpn_add_nc (
+ #endif
+ #endif
+
+-#if defined(HAVE___GMPN_REDC_1)
++#define ECM_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
++
++#if !defined( __MPIR_RELEASE ) && ECM_VERSION_NUM(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL) >= ECM_VERSION_NUM(5,1,0)
++#define MPN_REDC12_RETURNS_CARRY 1
++#endif
++
++/* GMP currently does not define prototypes for these, but MPIR does */
++#if defined(HAVE___GMPN_REDC_1) && !defined( __MPIR_RELEASE )
++#ifdef MPN_REDC12_RETURNS_CARRY
++ mp_limb_t __gmpn_redc_1 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
++#else
+ void __gmpn_redc_1 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
+ #endif
++#endif
+
+-#if defined(HAVE___GMPN_REDC_2)
++#if defined(HAVE___GMPN_REDC_2) && !defined( __MPIR_RELEASE )
++#ifdef MPN_REDC12_RETURNS_CARRY
++ mp_limb_t __gmpn_redc_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr);
++#else
+ void __gmpn_redc_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr);
+ #endif
++#endif
+
+ #if defined(HAVE___GMPN_REDC_N)
+ void __gmpn_redc_n (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr);
diff --git a/gmp-ecm.spec b/gmp-ecm.spec
index f7ffa05..717867f 100644
--- a/gmp-ecm.spec
+++ b/gmp-ecm.spec
@@ -10,6 +10,8 @@ Source0: https://gforge.inria.fr/frs/download.php/30965/ecm-%{version}.ta
Patch0: %{name}-ppc64-func-descs.patch
# SVN revision 2171, which fixes a bug with multithread support
Patch1: %{name}-thread.patch
+# SVN revisions 2320 and 2412, which adapt to GMP 5.1
+Patch2: %{name}-gmp51.patch
BuildRequires: docbook-style-xsl
BuildRequires: gmp-devel
@@ -61,6 +63,7 @@ The static libraries for using %{name} for development.
%setup -q -n ecm-%{version}
%patch0
%patch1
+%patch2
# Fix non-UTF-8 encodings
for badfile in ChangeLog README AUTHORS ; do
@@ -174,6 +177,9 @@ make check
%changelog
+* Sat Feb 23 2013 Jerry James <loganjerry at gmail.com> - 6.4.3-2
+- Add -gmp51 patch to deal with changes in GMP 5.1
+
* Wed Feb 13 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 6.4.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
More information about the scm-commits
mailing list