[Gmp-commit] /var/hg/gmp: Add casts for C++ compatibility.

mercurial at gmplib.org mercurial at gmplib.org
Thu Nov 13 22:04:59 UTC 2014


details:   /var/hg/gmp/rev/39aad582e1f7
changeset: 16514:39aad582e1f7
user:      Torbjorn Granlund <torbjorng at google.com>
date:      Thu Nov 13 23:04:54 2014 +0100
description:
Add casts for C++ compatibility.

diffstat:

 ChangeLog         |  17 +++++++++++++++++
 tune/speed.h      |  10 ++++++----
 tune/tune-gcd-p.c |   2 +-
 tune/tuneup.c     |  34 ++++++++++++++++++----------------
 4 files changed, 42 insertions(+), 21 deletions(-)

diffs (163 lines):

diff -r 1b2fa94bdd8e -r 39aad582e1f7 ChangeLog
--- a/ChangeLog	Thu Nov 13 06:42:25 2014 +0100
+++ b/ChangeLog	Thu Nov 13 23:04:54 2014 +0100
@@ -1,3 +1,20 @@
+2014-11-13  Hans Wennborg  <hwennborg at google.com>
+
+	* mpn/generic/toom_interpolate_8pts.c: Fix operator precedence in
+	ASSERT.
+	
+2014-11-13  Torbjörn Granlund  <torbjorng at google.com>
+
+	* tune/speed.h: Add casts for C++ compatibility.
+	(speed_cyclecounter): Mark as extern "C".
+	(mpn_mod_1_1p_1, mpn_mod_1_1p_2): Correct prototype.
+
+	* tune/tune-gcd-p.c: Add casts for C++ compatibility.
+
+	* tune/tuneup.c:  Add casts for C++ compatibility.
+	(mpn_divrem_1_tune, mpn_mod_1_tune): Mark as extern "C".
+	(INSERT_FFTTAB): Produce sentinels differently to silence compiler.
+	
 2014-11-12  Torbjörn Granlund  <torbjorng at google.com>
 
 	* gen-psqr.c: Add casts for C++ compatibility.
diff -r 1b2fa94bdd8e -r 39aad582e1f7 tune/speed.h
--- a/tune/speed.h	Thu Nov 13 06:42:25 2014 +0100
+++ b/tune/speed.h	Thu Nov 13 23:04:54 2014 +0100
@@ -412,8 +412,10 @@
 
 /* Prototypes for other routines */
 
+extern "C" {
 /* low 32-bits in p[0], high 32-bits in p[1] */
 void speed_cyclecounter (unsigned p[2]);
+}
 
 void mftb_function (unsigned p[2]);
 
@@ -459,8 +461,8 @@
 mp_limb_t mpn_mod_1_div (mp_srcptr, mp_size_t, mp_limb_t);
 mp_limb_t mpn_mod_1_inv (mp_srcptr, mp_size_t, mp_limb_t);
 
-mp_limb_t mpn_mod_1_1p_1 (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t [4]);
-mp_limb_t mpn_mod_1_1p_2 (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t [4]);
+mp_limb_t mpn_mod_1_1p_1 (mp_srcptr, mp_size_t, mp_limb_t, const mp_limb_t [4]);
+mp_limb_t mpn_mod_1_1p_2 (mp_srcptr, mp_size_t, mp_limb_t, const mp_limb_t [4]);
 
 void mpn_mod_1_1p_cps_1 (mp_limb_t [4], mp_limb_t);
 void mpn_mod_1_1p_cps_2 (mp_limb_t [4], mp_limb_t);
@@ -3356,7 +3358,7 @@
     SPEED_TMP_ALLOC_LIMBS (xp, s->size + 1, s->align_xp);		\
 									\
     MPN_SIZEINBASE (wn, s->xp, s->size, base);				\
-    wp = TMP_ALLOC (wn);						\
+    wp = (unsigned char *) TMP_ALLOC (wn);				\
 									\
     /* use this during development to guard against overflowing wp */	\
     /*									\
@@ -3402,7 +3404,7 @@
 									\
     TMP_MARK;								\
 									\
-    xp = TMP_ALLOC (s->size);						\
+    xp = (unsigned char *) TMP_ALLOC (s->size);				\
     for (i = 0; i < s->size; i++)					\
       xp[i] = s->xp[i] % base;						\
 									\
diff -r 1b2fa94bdd8e -r 39aad582e1f7 tune/tune-gcd-p.c
--- a/tune/tune-gcd-p.c	Thu Nov 13 06:42:25 2014 +0100
+++ b/tune/tune-gcd-p.c	Thu Nov 13 23:04:54 2014 +0100
@@ -142,7 +142,7 @@
 static double
 bench_gcd (void *ctx, int p)
 {
-  struct bench_data *data = ctx;
+  struct bench_data *data = (struct bench_data *) ctx;
   double t;
 
   p_table[data->n] = p;
diff -r 1b2fa94bdd8e -r 39aad582e1f7 tune/tuneup.c
--- a/tune/tuneup.c	Thu Nov 13 06:42:25 2014 +0100
+++ b/tune/tuneup.c	Thu Nov 13 23:04:54 2014 +0100
@@ -387,9 +387,11 @@
  * mpn/generic/divrem_1.c, mpn/generic/mod_1.c and mpz/fac_ui.c */
 
 mp_limb_t mpn_div_qr_1_tune (mp_ptr, mp_limb_t *, mp_srcptr, mp_size_t, mp_limb_t);
+extern "C" {
 mp_limb_t mpn_divrem_1_tune (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t);
 mp_limb_t mpn_mod_1_tune (mp_srcptr, mp_size_t, mp_limb_t);
 void mpz_fac_ui_tune (mpz_ptr, unsigned long);
+}
 
 double
 speed_mpn_mod_1_tune (struct speed_params *s)
@@ -858,8 +860,8 @@
   do {									\
     fft_tab[idx].n = nval;						\
     fft_tab[idx].k = kval;						\
-    fft_tab[idx+1].n = -1;	/* sentinel */				\
-    fft_tab[idx+1].k = -1;						\
+    fft_tab[idx+1].n = (1 << 27) - 1;	/* sentinel, 27b wide field */	\
+    fft_tab[idx+1].k = (1 <<  5) - 1;					\
   } while (0)
 
 int
@@ -902,12 +904,12 @@
       idx = 1;
     }
 
-  ap = malloc (sizeof (mp_limb_t));
+  ap = (mp_ptr) malloc (sizeof (mp_limb_t));
   if (p->sqr)
     bp = ap;
   else
-    bp = malloc (sizeof (mp_limb_t));
-  rp = malloc (sizeof (mp_limb_t));
+    bp = (mp_ptr) malloc (sizeof (mp_limb_t));
+  rp = (mp_ptr) malloc (sizeof (mp_limb_t));
   alloc = 1;
 
   /* Round n to comply to initial k value */
@@ -945,22 +947,22 @@
 	      alloc = n1;
 	      if (p->sqr)
 		{
-		  ap = realloc (ap, sizeof (mp_limb_t));
-		  rp = realloc (rp, sizeof (mp_limb_t));
-		  ap = bp = realloc (ap, alloc * sizeof (mp_limb_t));
+		  ap = (mp_ptr) realloc (ap, sizeof (mp_limb_t));
+		  rp = (mp_ptr) realloc (rp, sizeof (mp_limb_t));
+		  ap = bp = (mp_ptr) realloc (ap, alloc * sizeof (mp_limb_t));
 		  mpn_random (ap, alloc);
-		  rp = realloc (rp, alloc * sizeof (mp_limb_t));
+		  rp = (mp_ptr) realloc (rp, alloc * sizeof (mp_limb_t));
 		}
 	      else
 		{
-		  ap = realloc (ap, sizeof (mp_limb_t));
-		  bp = realloc (bp, sizeof (mp_limb_t));
-		  rp = realloc (rp, sizeof (mp_limb_t));
-		  ap = realloc (ap, alloc * sizeof (mp_limb_t));
+		  ap = (mp_ptr) realloc (ap, sizeof (mp_limb_t));
+		  bp = (mp_ptr) realloc (bp, sizeof (mp_limb_t));
+		  rp = (mp_ptr) realloc (rp, sizeof (mp_limb_t));
+		  ap = (mp_ptr) realloc (ap, alloc * sizeof (mp_limb_t));
 		  mpn_random (ap, alloc);
-		  bp = realloc (bp, alloc * sizeof (mp_limb_t));
+		  bp = (mp_ptr) realloc (bp, alloc * sizeof (mp_limb_t));
 		  mpn_random (bp, alloc);
-		  rp = realloc (rp, alloc * sizeof (mp_limb_t));
+		  rp = (mp_ptr) realloc (rp, alloc * sizeof (mp_limb_t));
 		}
 	    }
 
@@ -2603,7 +2605,7 @@
 
   TMP_MARK;
 
-  str = TMP_ALLOC (s->size);
+  str = (unsigned char *) TMP_ALLOC (s->size);
   for (i = 0; i < s->size; i++)
     str[i] = s->xp[i] % base;
 


More information about the gmp-commit mailing list