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

mercurial at gmplib.org mercurial at gmplib.org
Tue Sep 29 19:25:16 UTC 2015


details:   /var/hg/gmp/rev/f2de3787bbed
changeset: 16834:f2de3787bbed
user:      Torbjorn Granlund <torbjorng at google.com>
date:      Tue Sep 29 21:24:58 2015 +0200
description:
Streamline, use macros.

details:   /var/hg/gmp/rev/290669009166
changeset: 16835:290669009166
user:      Torbjorn Granlund <torbjorng at google.com>
date:      Tue Sep 29 21:25:12 2015 +0200
description:
ChangeLog

diffstat:

 ChangeLog    |   6 ++++++
 mpf/clear.c  |   4 ++--
 mpf/clears.c |   9 +++++----
 mpf/inits.c  |   7 ++++---
 mpq/clear.c  |  10 ++++------
 mpq/clears.c |  13 ++++++-------
 mpq/inits.c  |   7 ++++---
 mpz/clear.c  |   8 ++++----
 mpz/clears.c |   9 +++++----
 mpz/inits.c  |  17 +++++++++++++----
 10 files changed, 53 insertions(+), 37 deletions(-)

diffs (289 lines):

diff -r 7e89761ccc37 -r 290669009166 ChangeLog
--- a/ChangeLog	Sun Sep 27 07:45:29 2015 +0200
+++ b/ChangeLog	Tue Sep 29 21:25:12 2015 +0200
@@ -1,3 +1,9 @@
+2015-09-12  Torbjörn Granlund  <torbjorng at google.com>
+
+	* mpf/clear.c, mpf/clears.c, mpf/inits.c, mpq/clear.c, mpq/clears.c
+	* mpq/inits.c, mpz/clear.c, mpz/clears.c, mpz/inits.c:
+	Streamline, use macros.
+	
 2015-09-27 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* mpz/cfdiv_r_2exp.c: Use mpn_neg and MPZ_NEWALLOC.
diff -r 7e89761ccc37 -r 290669009166 mpf/clear.c
--- a/mpf/clear.c	Sun Sep 27 07:45:29 2015 +0200
+++ b/mpf/clear.c	Tue Sep 29 21:25:12 2015 +0200
@@ -33,7 +33,7 @@
 #include "gmp-impl.h"
 
 void
-mpf_clear (mpf_ptr m)
+mpf_clear (mpf_ptr x)
 {
-  (*__gmp_free_func) (m->_mp_d, (size_t) (m->_mp_prec + 1) * GMP_LIMB_BYTES);
+  __GMP_FREE_FUNC_LIMBS (PTR(x), PREC(x) + 1);
 }
diff -r 7e89761ccc37 -r 290669009166 mpf/clears.c
--- a/mpf/clears.c	Sun Sep 27 07:45:29 2015 +0200
+++ b/mpf/clears.c	Tue Sep 29 21:25:12 2015 +0200
@@ -1,6 +1,6 @@
 /* mpf_clears() -- Clear multiple mpf_t variables.
 
-Copyright 2009, 2014 Free Software Foundation, Inc.
+Copyright 2009, 2014, 2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -29,7 +29,6 @@
 see https://www.gnu.org/licenses/.  */
 
 #include <stdarg.h>
-#include <stdio.h>		/* for NULL */
 #include "gmp.h"
 #include "gmp-impl.h"
 
@@ -40,10 +39,12 @@
 
   va_start (ap, x);
 
-  while (x != NULL)
+  do
     {
-      (*__gmp_free_func) (x->_mp_d, (size_t) (x->_mp_prec + 1) * GMP_LIMB_BYTES);
+      __GMP_FREE_FUNC_LIMBS (PTR(x), PREC(x) + 1);
       x = va_arg (ap, mpf_ptr);
     }
+  while (x != NULL);
+
   va_end (ap);
 }
diff -r 7e89761ccc37 -r 290669009166 mpf/inits.c
--- a/mpf/inits.c	Sun Sep 27 07:45:29 2015 +0200
+++ b/mpf/inits.c	Tue Sep 29 21:25:12 2015 +0200
@@ -1,6 +1,6 @@
 /* mpf_inits() -- Initialize multiple mpf_t variables and set them to 0.
 
-Copyright 2009 Free Software Foundation, Inc.
+Copyright 2009, 2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -29,7 +29,6 @@
 see https://www.gnu.org/licenses/.  */
 
 #include <stdarg.h>
-#include <stdio.h>		/* for NULL */
 #include "gmp.h"
 #include "gmp-impl.h"
 
@@ -40,10 +39,12 @@
 
   va_start (ap, x);
 
-  while (x != NULL)
+  do
     {
       mpf_init (x);
       x = va_arg (ap, mpf_ptr);
     }
+  while (x != NULL);
+
   va_end (ap);
 }
diff -r 7e89761ccc37 -r 290669009166 mpq/clear.c
--- a/mpq/clear.c	Sun Sep 27 07:45:29 2015 +0200
+++ b/mpq/clear.c	Tue Sep 29 21:25:12 2015 +0200
@@ -1,6 +1,6 @@
 /* mpq_clear -- free the space occupied by an mpq_t.
 
-Copyright 1991, 1994, 1995, 2000, 2001 Free Software Foundation, Inc.
+Copyright 1991, 1994, 1995, 2000, 2001, 2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -32,10 +32,8 @@
 #include "gmp-impl.h"
 
 void
-mpq_clear (mpq_t m)
+mpq_clear (mpq_t x)
 {
-  (*__gmp_free_func) (PTR(NUM(m)),
-		    (size_t) ALLOC(NUM(m)) * GMP_LIMB_BYTES);
-  (*__gmp_free_func) (PTR(DEN(m)),
-		    (size_t) ALLOC(DEN(m)) * GMP_LIMB_BYTES);
+  __GMP_FREE_FUNC_LIMBS (PTR(NUM(x)), ALLOC(NUM(x)));
+  __GMP_FREE_FUNC_LIMBS (PTR(DEN(x)), ALLOC(DEN(x)));
 }
diff -r 7e89761ccc37 -r 290669009166 mpq/clears.c
--- a/mpq/clears.c	Sun Sep 27 07:45:29 2015 +0200
+++ b/mpq/clears.c	Tue Sep 29 21:25:12 2015 +0200
@@ -1,6 +1,6 @@
 /* mpq_clears() -- Clear multiple mpq_t variables.
 
-Copyright 2009, 2014 Free Software Foundation, Inc.
+Copyright 2009, 2014, 2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -29,7 +29,6 @@
 see https://www.gnu.org/licenses/.  */
 
 #include <stdarg.h>
-#include <stdio.h>		/* for NULL */
 #include "gmp.h"
 #include "gmp-impl.h"
 
@@ -40,13 +39,13 @@
 
   va_start (ap, x);
 
-  while (x != NULL)
+  do
     {
-      (*__gmp_free_func) (PTR(NUM(x)),
-			  (size_t) ALLOC(NUM(x)) * GMP_LIMB_BYTES);
-      (*__gmp_free_func) (PTR(DEN(x)),
-			  (size_t) ALLOC(DEN(x)) * GMP_LIMB_BYTES);
+      __GMP_FREE_FUNC_LIMBS (PTR(NUM(x)), ALLOC(NUM(x)));
+      __GMP_FREE_FUNC_LIMBS (PTR(DEN(x)), ALLOC(DEN(x)));
       x = va_arg (ap, mpq_ptr);
     }
+  while (x != NULL);
+
   va_end (ap);
 }
diff -r 7e89761ccc37 -r 290669009166 mpq/inits.c
--- a/mpq/inits.c	Sun Sep 27 07:45:29 2015 +0200
+++ b/mpq/inits.c	Tue Sep 29 21:25:12 2015 +0200
@@ -1,6 +1,6 @@
 /* mpq_inits() -- Initialize multiple mpq_t variables and set them to 0.
 
-Copyright 2009 Free Software Foundation, Inc.
+Copyright 2009, 2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -29,7 +29,6 @@
 see https://www.gnu.org/licenses/.  */
 
 #include <stdarg.h>
-#include <stdio.h>		/* for NULL */
 #include "gmp.h"
 #include "gmp-impl.h"
 
@@ -40,10 +39,12 @@
 
   va_start (ap, x);
 
-  while (x != NULL)
+  do
     {
       mpq_init (x);
       x = va_arg (ap, mpq_ptr);
     }
+  while (x != NULL);
+
   va_end (ap);
 }
diff -r 7e89761ccc37 -r 290669009166 mpz/clear.c
--- a/mpz/clear.c	Sun Sep 27 07:45:29 2015 +0200
+++ b/mpz/clear.c	Tue Sep 29 21:25:12 2015 +0200
@@ -1,8 +1,8 @@
 /* mpz_clear -- de-allocate the space occupied by the dynamic digit space of
    an integer.
 
-Copyright 1991, 1993-1995, 2000, 2001, 2012, 2014 Free Software Foundation,
-Inc.
+Copyright 1991, 1993-1995, 2000, 2001, 2012, 2014, 2015 Free Software
+Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -34,7 +34,7 @@
 #include "gmp-impl.h"
 
 void
-mpz_clear (mpz_ptr m)
+mpz_clear (mpz_ptr x)
 {
-  (*__gmp_free_func) (PTR (m), (size_t) ALLOC (m) * GMP_LIMB_BYTES);
+  __GMP_FREE_FUNC_LIMBS (PTR (x), ALLOC(x));
 }
diff -r 7e89761ccc37 -r 290669009166 mpz/clears.c
--- a/mpz/clears.c	Sun Sep 27 07:45:29 2015 +0200
+++ b/mpz/clears.c	Tue Sep 29 21:25:12 2015 +0200
@@ -1,6 +1,6 @@
 /* mpz_clears() -- Clear multiple mpz_t variables.
 
-Copyright 2009, 2014 Free Software Foundation, Inc.
+Copyright 2009, 2014, 2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -29,7 +29,6 @@
 see https://www.gnu.org/licenses/.  */
 
 #include <stdarg.h>
-#include <stdio.h>		/* for NULL */
 #include "gmp.h"
 #include "gmp-impl.h"
 
@@ -40,10 +39,12 @@
 
   va_start (ap, x);
 
-  while (x != NULL)
+  do
     {
-      (*__gmp_free_func) (PTR (x), (size_t) ALLOC (x) * GMP_LIMB_BYTES);
+      __GMP_FREE_FUNC_LIMBS (PTR (x), ALLOC(x));
       x = va_arg (ap, mpz_ptr);
     }
+  while (x != NULL);
+
   va_end (ap);
 }
diff -r 7e89761ccc37 -r 290669009166 mpz/inits.c
--- a/mpz/inits.c	Sun Sep 27 07:45:29 2015 +0200
+++ b/mpz/inits.c	Tue Sep 29 21:25:12 2015 +0200
@@ -1,6 +1,6 @@
 /* mpz_inits() -- Initialize multiple mpz_t variables and set them to 0.
 
-Copyright 2009 Free Software Foundation, Inc.
+Copyright 2009, 2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -29,7 +29,6 @@
 see https://www.gnu.org/licenses/.  */
 
 #include <stdarg.h>
-#include <stdio.h>		/* for NULL */
 #include "gmp.h"
 #include "gmp-impl.h"
 
@@ -40,10 +39,20 @@
 
   va_start (ap, x);
 
-  while (x != NULL)
+  do
     {
-      mpz_init (x);
+      ALLOC (x) = 1;
+      PTR (x) = __GMP_ALLOCATE_FUNC_LIMBS (1);
+      SIZ (x) = 0;
+
+#ifdef __CHECKER__
+      /* let the low limb look initialized, for the benefit of mpz_get_ui etc */
+      PTR (x) = 0;
+#endif
+
       x = va_arg (ap, mpz_ptr);
     }
+  while (x != NULL);
+
   va_end (ap);
 }


More information about the gmp-commit mailing list