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

mercurial at gmplib.org mercurial at gmplib.org
Fri Jan 18 15:53:02 CET 2013


details:   /var/hg/gmp/rev/3de4d2761b75
changeset: 15295:3de4d2761b75
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Fri Jan 18 15:51:19 2013 +0100
description:
(normalization_steps): Eliminate set-but-unused variable.

details:   /var/hg/gmp/rev/13b982e68291
changeset: 15296:13b982e68291
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Fri Jan 18 15:51:30 2013 +0100
description:
ChangeLog

details:   /var/hg/gmp/rev/caca6dbfced9
changeset: 15297:caca6dbfced9
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Fri Jan 18 15:52:52 2013 +0100
description:
Trivial merge.

diffstat:

 ChangeLog                 |   8 +++++
 mini-gmp/tests/t-double.c |   7 ++--
 mini-gmp/tests/t-signed.c |  67 ++++++++++++++++++++++------------------------
 mpn/generic/set_str.c     |   4 +--
 4 files changed, 45 insertions(+), 41 deletions(-)

diffs (195 lines):

diff -r 6898230ae9ba -r caca6dbfced9 ChangeLog
--- a/ChangeLog	Fri Jan 18 11:54:53 2013 +0100
+++ b/ChangeLog	Fri Jan 18 15:52:52 2013 +0100
@@ -1,5 +1,13 @@
+2013-01-18 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mini-gmp/tests/t-signed.c: Slightly larger coverage.
+	* mini-gmp/tests/t-double.c: Test also mpz_init_set_d.
+
 2013-01-18  Torbjorn Granlund  <tege at gmplib.org>
 
+	* mpn/generic/set_str.c (normalization_steps): Eliminate set-but-unused
+	variable.
+
 	* mini-gmp/tests/t-div.c: Test mpz_divisible_p and mpz_divisible_ui_p.
 
 	* tests/tests.h (TESTS_REPS): Fix printf argument type clashes.
diff -r 6898230ae9ba -r caca6dbfced9 mini-gmp/tests/t-double.c
--- a/mini-gmp/tests/t-double.c	Fri Jan 18 11:54:53 2013 +0100
+++ b/mini-gmp/tests/t-double.c	Fri Jan 18 15:52:52 2013 +0100
@@ -63,12 +63,10 @@
 
   hex_random_init ();
 
-  mpz_init (x);
-
   for (i = 0; values[i].s; i++)
     {
       char *s;
-      mpz_set_d (x, values[i].d);
+      mpz_init_set_d (x, values[i].d);
       s = mpz_get_str (NULL, 16, x);
       if (strcmp (s, values[i].s) != 0)
 	{
@@ -80,8 +78,11 @@
 	  abort ();
 	}
       free(s);
+      mpz_clear (x);
     }
 
+  mpz_init (x);
+
   for (i = 0; i < COUNT; i++)
     {
       double d, f;
diff -r 6898230ae9ba -r caca6dbfced9 mini-gmp/tests/t-signed.c
--- a/mini-gmp/tests/t-signed.c	Fri Jan 18 11:54:53 2013 +0100
+++ b/mini-gmp/tests/t-signed.c	Fri Jan 18 15:52:52 2013 +0100
@@ -22,12 +22,22 @@
 
 #include "mini-gmp.h"
 
-void
-check_si (mpz_t sz, mpz_t oz, long si, int c)
+int
+check_si (mpz_t sz, mpz_t oz, long si, long oi, int c)
 {
   mpz_t t;
   int fail;
 
+  if (mpz_cmp_si (sz, oi) != c)
+    {
+      printf ("mpz_cmp_si (sz, %ld) != %i.\n", oi, c);
+      printf (" sz="); mpz_out_str (stdout, 10, sz); printf ("\n");
+      abort ();
+    }
+
+  if ((si < oi ? -1 : si > oi) != c)
+    return 1;
+
   mpz_init_set_si (t, si);
 
   if ((fail = mpz_cmp_si (sz, si)) != 0)
@@ -54,6 +64,8 @@
       printf (" si=%ld\n", si);
       abort ();
     }
+
+  return 0;
 }
 
 void
@@ -72,58 +84,28 @@
     si *= 2; /* c * 2^k */
     mpz_mul_2exp (sz, sz, 1);
 
-    if (mpz_cmp_si (sz, oi) != c)
-      {
-	printf ("mpz_cmp_si (sz, %ld) != %i.\n", oi, c);
-	printf (" sz="); mpz_out_str (stdout, 10, sz); printf ("\n");
-	abort ();
-      }
-
-    if ((si < oi ? -1 : si > oi) != c)
+    if (check_si (sz, oz, si, oi, c))
       {
 	mpz_set (oz, sz);
 	break;
       }
 
-    check_si (sz, oz, si, c);
-
     oi = si + c; /* c * (2^k + 1) */
     if (c == -1)
       mpz_sub_ui (oz, sz, 1);
     else
       mpz_add_ui (oz, sz, 1);
 
-    if (mpz_cmp_si (oz, si) != c)
-      {
-	printf ("mpz_cmp_si (oz, %ld) != %i.\n", si, c);
-	printf (" oz="); mpz_out_str (stdout, 10, oz); printf ("\n");
-	abort ();
-      }
-
-    if ((oi < si ? -1 : oi > si) != c)
+    if (check_si (oz, sz, oi, si, c))
       break;
 
-    check_si (oz, sz, oi, c);
-
     oi = (si - c) * 2 + c; /* c * (2^K - 1) */
     mpz_mul_si (oz, sz, 2*c); 
     if (c == -1)
       mpz_ui_sub (oz, 1, oz); /* oz = sz * 2 + 1 */
     else
       mpz_sub_ui (oz, oz, 1); /* oz = sz * 2 - 1 */
-
-    if (mpz_cmp_si (oz, si) != c)
-      {
-	printf ("mpz_cmp_si (oz, %ld) != %i.\n", si, c);
-	printf (" oz="); mpz_out_str (stdout, 10, oz); printf ("\n");
-	abort ();
-      }
-
-    if ((oi < si ? -1 : oi > si) != c)
-      break;
-
-    check_si (oz, sz, oi, c);
-  } while (1);
+  } while (check_si (oz, sz, oi, si, c) == 0);
 
   mpz_clear (sz);
 
@@ -134,6 +116,21 @@
       abort ();
     }
 
+  if (mpz_cmp_si (oz, -c) != c)
+      {
+	printf ("mpz_cmp_si (oz, %i) != %i.\n", c, c);
+	printf (" oz="); mpz_out_str (stdout, 10, oz); printf ("\n");
+	abort ();
+      }
+
+  mpz_mul_2exp (oz, oz, 1);
+  if (mpz_cmp_si (oz, -c) != c)
+      {
+	printf ("mpz_cmp_si (oz, %i) != %i.\n", c, c);
+	printf (" oz="); mpz_out_str (stdout, 10, oz); printf ("\n");
+	abort ();
+      }
+
   mpz_clear (oz);
 }
 
diff -r 6898230ae9ba -r caca6dbfced9 mpn/generic/set_str.c
--- a/mpn/generic/set_str.c	Fri Jan 18 11:54:53 2013 +0100
+++ b/mpn/generic/set_str.c	Fri Jan 18 15:52:52 2013 +0100
@@ -10,7 +10,7 @@
    GNU MP RELEASE.
 
 Copyright 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002, 2004, 2006, 2007,
-2008, 2012 Free Software Foundation, Inc.
+2008, 2012, 2013 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -131,7 +131,6 @@
   long i, pi;
   mp_size_t n;
   mp_ptr p, t;
-  unsigned normalization_steps;
   mp_limb_t big_base;
   int chars_per_limb;
   size_t digits_in_base;
@@ -141,7 +140,6 @@
 
   chars_per_limb = mp_bases[base].chars_per_limb;
   big_base = mp_bases[base].big_base;
-  count_leading_zeros (normalization_steps, big_base);
 
   p = powtab_mem_ptr;
   powtab_mem_ptr += 1;


More information about the gmp-commit mailing list