[Ecm-commits] r2415 - trunk

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


Author: kruppa
Date: 2013-02-19 18:10:30 +0100 (Tue, 19 Feb 2013)
New Revision: 2415

Log:
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 :(



Modified:
   trunk/ecm-gmp.h
   trunk/ecm-impl.h
   trunk/mpmod.c
Modified: trunk/ecm-gmp.h
===================================================================
--- trunk/ecm-gmp.h	2013-02-19 16:36:35 UTC (rev 2414)
+++ trunk/ecm-gmp.h	2013-02-19 17:10:30 UTC (rev 2415)
@@ -107,16 +107,27 @@
 #endif
 #endif
 
-#if !defined( __MPIR_RELEASE )
+#define ECM_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
 
-#if defined(HAVE___GMPN_REDC_1)
+#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);
-#  endif
+#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)

Modified: trunk/ecm-impl.h
===================================================================
--- trunk/ecm-impl.h	2013-02-19 16:36:35 UTC (rev 2414)
+++ trunk/ecm-impl.h	2013-02-19 17:10:30 UTC (rev 2415)
@@ -83,8 +83,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: trunk/mpmod.c
===================================================================
--- trunk/mpmod.c	2013-02-19 16:36:35 UTC (rev 2414)
+++ trunk/mpmod.c	2013-02-19 17:10:30 UTC (rev 2415)
@@ -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