[Ecm-commits] r2412 - branches/6.4.4

cvs commits ecm-commits at lists.gforge.inria.fr
Tue Feb 19 16:10:30 CET 2013


Author: kruppa
Date: 2013-02-19 16:10:27 +0100 (Tue, 19 Feb 2013)
New Revision: 2412

Log:
Define correct __gmpn_redc_{12} prototype for GMP <5.1. Define REDC{12} macros only if the functions exist.


Modified:
   branches/6.4.4/ecm-gmp.h
   branches/6.4.4/ecm-impl.h
   branches/6.4.4/mpmod.c
Modified: branches/6.4.4/ecm-gmp.h
===================================================================
--- branches/6.4.4/ecm-gmp.h	2013-02-19 12:29:43 UTC (rev 2411)
+++ branches/6.4.4/ecm-gmp.h	2013-02-19 15:10:27 UTC (rev 2412)
@@ -123,13 +123,28 @@
 #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);

Modified: branches/6.4.4/ecm-impl.h
===================================================================
--- branches/6.4.4/ecm-impl.h	2013-02-19 12:29:43 UTC (rev 2411)
+++ branches/6.4.4/ecm-impl.h	2013-02-19 15:10:27 UTC (rev 2412)
@@ -76,8 +76,6 @@
 #define __ECM_HAVE_TOKEN_PASTE  0
 #endif
 
-#define ECM_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-
 #ifndef __ECM
 #if __ECM_HAVE_TOKEN_PASTE
 #define __ECM(x) __ecm_##x

Modified: branches/6.4.4/mpmod.c
===================================================================
--- branches/6.4.4/mpmod.c	2013-02-19 12:29:43 UTC (rev 2411)
+++ branches/6.4.4/mpmod.c	2013-02-19 15:10:27 UTC (rev 2412)
@@ -52,19 +52,27 @@
 
 /* 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 */
-#if ECM_VERSION_NUM(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL) < ECM_VERSION_NUM(5,1,0)
-#define REDC1(rp,cp,np,nn,invm) __gmpn_redc_1(rp,cp,np,nn,invm)
-#define REDC2(rp,cp,np,nn,invm) __gmpn_redc_2(rp,cp,np,nn,invm)
-#else
+#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




More information about the Ecm-commits mailing list