[Gmp-commit] /var/hg/gmp: 5 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Wed Jan 31 03:32:29 UTC 2018


details:   /var/hg/gmp/rev/6cac12c693bd
changeset: 17543:6cac12c693bd
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Jan 25 22:30:43 2018 +0100
description:
mpz/bin_uiui.c: unnecessary corrections to unused code.

details:   /var/hg/gmp/rev/363210a8a721
changeset: 17544:363210a8a721
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Jan 25 22:39:03 2018 +0100
description:
mpz/bin_uiui.c (mpz_bdiv_bin_uiui): Use TMP_ALLOC_LIMBS_2.

details:   /var/hg/gmp/rev/725745f3637f
changeset: 17545:725745f3637f
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Jan 31 04:24:21 2018 +0100
description:
printf/snprntffuns.c: Use size_t instead of int

details:   /var/hg/gmp/rev/3c492799efd4
changeset: 17546:3c492799efd4
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Jan 31 04:26:52 2018 +0100
description:
mpz/{2fac_ui,bin_uiui}.c: Use size_t instead of mp_limb_t

details:   /var/hg/gmp/rev/339f813ab986
changeset: 17547:339f813ab986
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Jan 31 04:30:38 2018 +0100
description:
printf/*.c: Use __GMP_FREE_FUNC_TYPE

diffstat:

 mpz/2fac_ui.c           |   3 ++-
 mpz/bin_uiui.c          |  32 +++++++++++++++++++++++++-------
 printf/doprnt.c         |   4 ++--
 printf/doprntf.c        |   2 +-
 printf/repl-vsnprintf.c |   2 +-
 printf/snprntffuns.c    |   3 ++-
 6 files changed, 33 insertions(+), 13 deletions(-)

diffs (142 lines):

diff -r bd031c4d736b -r 339f813ab986 mpz/2fac_ui.c
--- a/mpz/2fac_ui.c	Wed Jan 17 05:34:55 2018 +0100
+++ b/mpz/2fac_ui.c	Wed Jan 31 04:30:38 2018 +0100
@@ -69,7 +69,8 @@
       MPZ_NEWALLOC (x, 1)[0] = __gmp_odd2fac_table[n >> 1];
       SIZ (x) = 1;
     } else if (BELOW_THRESHOLD (n, FAC_2DSC_THRESHOLD)) { /* odd basecase, */
-      mp_limb_t *factors, prod, max_prod, j;
+      mp_limb_t *factors, prod, max_prod;
+      mp_size_t j;
       TMP_SDECL;
 
       /* FIXME: we might alloc a fixed amount 1+FAC_2DSC_THRESHOLD/FACTORS_PER_LIMB */
diff -r bd031c4d736b -r 339f813ab986 mpz/bin_uiui.c
--- a/mpz/bin_uiui.c	Wed Jan 17 05:34:55 2018 +0100
+++ b/mpz/bin_uiui.c	Wed Jan 31 04:30:38 2018 +0100
@@ -147,13 +147,31 @@
   return m0257 * m1346;
 }
 
+/*
+static mp_limb_t
+mul9 (mp_limb_t m)
+{
+  return (m + 8) * (mul8 (m) >> 1) ;
+}
+
+static mp_limb_t
+mul10 (mp_limb_t m)
+{
+  mp_limb_t m09 = (m + 0) * (m + 9);
+  mp_limb_t m18 = (m09 >> 1) + 4;
+  mp_limb_t m0369 = m09 * (m09 + 18) >> 3;
+  mp_limb_t m2457 = m09 * 2 + 35 + m0369;
+  return ((m0369 * m2457) >> 1) * m18;
+}
+*/
+
 typedef mp_limb_t (* mulfunc_t) (mp_limb_t);
 
-static const mulfunc_t mulfunc[] = {mul1,mul2,mul3,mul4,mul5,mul6,mul7,mul8};
+static const mulfunc_t mulfunc[] = {mul1,mul2,mul3,mul4,mul5,mul6,mul7,mul8 /* ,mul9,mul10 */};
 #define M (numberof(mulfunc))
 
 /* Number of factors-of-2 removed by the corresponding mulN function.  */
-static const unsigned char tcnttab[] = {0, 1, 1, 2, 2, 4, 4, 6};
+static const unsigned char tcnttab[] = {0, 1, 1, 2, 2, 4, 4, 6 /*,7 ,8*/};
 
 #if 1
 /* This variant is inaccurate but share the code with other functions.  */
@@ -168,11 +186,11 @@
 static const unsigned long ftab[] =
 #if GMP_NUMB_BITS == 64
   /* 1 to 8 factors per iteration */
-  {CNST_LIMB(0xffffffffffffffff),CNST_LIMB(0x100000000),0x32cbfe,0x16a0b,0x24c4,0xa16,0x34b,0x1b2 /*,0xdf,0x8d */};
+  {CNST_LIMB(0xffffffffffffffff),CNST_LIMB(0x16a09e667),0x32cbfc,0x16a08,0x24c0,0xa11,0x345,0x1ab /*,0xe9,0x8e */};
 #endif
 #if GMP_NUMB_BITS == 32
   /* 1 to 7 factors per iteration */
-  {0xffffffff,0x10000,0x801,0x16b,0x71,0x42,0x26 /* ,0x1e */};
+  {0xffffffff,0x16a09,0x7ff,0x168,0x6f,0x3d,0x20 /* ,0x17 */};
 #endif
 
 #define MAXFACS(max,l)							\
@@ -208,8 +226,7 @@
      large.  */
   alloc = SOME_THRESHOLD - 1 + MAX (3 * maxn / 2, SOME_THRESHOLD);
   alloc = MIN (alloc, (mp_size_t) k) + 1;
-  np = TMP_ALLOC_LIMBS (alloc);
-  kp = TMP_ALLOC_LIMBS (SOME_THRESHOLD + 1);
+  TMP_ALLOC_LIMBS_2 (np, alloc, kp, SOME_THRESHOLD + 1);
 
   MAXFACS (nmax, n);
   ASSERT (nmax <= M);
@@ -567,7 +584,8 @@
 mpz_goetgheluck_bin_uiui (mpz_ptr r, unsigned long int n, unsigned long int k)
 {
   mp_limb_t *sieve, *factors, count;
-  mp_limb_t prod, max_prod, j;
+  mp_limb_t prod, max_prod;
+  mp_size_t j;
   TMP_DECL;
 
   ASSERT (BIN_GOETGHELUCK_THRESHOLD >= 13);
diff -r bd031c4d736b -r 339f813ab986 printf/doprnt.c
--- a/printf/doprnt.c	Wed Jan 17 05:34:55 2018 +0100
+++ b/printf/doprnt.c	Wed Jan 31 04:30:38 2018 +0100
@@ -339,7 +339,7 @@
 				       va_arg (ap, mpz_srcptr));
 	      gmp_integer:
 		ret = __gmp_doprnt_integer (funs, data, &param, gmp_str);
-		(*__gmp_free_func) (gmp_str, strlen(gmp_str)+1);
+		 __GMP_FREE_FUNC_TYPE (gmp_str, strlen(gmp_str)+1, char);
 		DOPRNT_ACCUMULATE (ret);
 		va_copy (last_ap, ap);
 		last_fmt = fmt;
@@ -617,7 +617,7 @@
       goto error;
 
  done:
-  (*__gmp_free_func) (alloc_fmt, alloc_fmt_size);
+  __GMP_FREE_FUNC_TYPE (alloc_fmt, alloc_fmt_size, char);
   return retval;
 
  error:
diff -r bd031c4d736b -r 339f813ab986 printf/doprntf.c
--- a/printf/doprntf.c	Wed Jan 17 05:34:55 2018 +0100
+++ b/printf/doprntf.c	Wed Jan 31 04:30:38 2018 +0100
@@ -380,7 +380,7 @@
     DOPRNT_REPS (p->fill, justlen);
 
  done:
-  (*__gmp_free_func) (free_ptr, free_size);
+  __GMP_FREE_FUNC_TYPE (free_ptr, free_size, char);
   return retval;
 
  error:
diff -r bd031c4d736b -r 339f813ab986 printf/repl-vsnprintf.c
--- a/printf/repl-vsnprintf.c	Wed Jan 17 05:34:55 2018 +0100
+++ b/printf/repl-vsnprintf.c	Wed Jan 31 04:30:38 2018 +0100
@@ -382,7 +382,7 @@
 	  memcpy (buf, s, copylen);
 	  buf[copylen] = '\0';
 	}
-      (*__gmp_free_func) (s, total_width);
+      __GMP_FREE_FUNC_TYPE (s, total_width, char);
     }
 
   /* If total_width was somehow wrong then chances are we've already
diff -r bd031c4d736b -r 339f813ab986 printf/snprntffuns.c
--- a/printf/snprntffuns.c	Wed Jan 17 05:34:55 2018 +0100
+++ b/printf/snprntffuns.c	Wed Jan 31 04:30:38 2018 +0100
@@ -62,7 +62,8 @@
 gmp_snprintf_format (struct gmp_snprintf_t *d, const char *fmt,
                      va_list orig_ap)
 {
-  int      ret, step, alloc, avail;
+  int      ret;
+  size_t   step, alloc, avail;
   va_list  ap;
   char     *p;
 


More information about the gmp-commit mailing list