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

mercurial at gmplib.org mercurial at gmplib.org
Sat May 30 06:37:08 UTC 2015


details:   /var/hg/gmp/rev/6593cc5d34cd
changeset: 16664:6593cc5d34cd
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sat May 30 08:07:57 2015 +0200
description:
Make mpn_zero_p public (inline).

details:   /var/hg/gmp/rev/2898c9c527b7
changeset: 16665:2898c9c527b7
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sat May 30 08:26:40 2015 +0200
description:
doc/gmp.texi: Documentation for mpn_zero_p

details:   /var/hg/gmp/rev/fae7c40baa09
changeset: 16666:fae7c40baa09
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sat May 30 08:33:51 2015 +0200
description:
ChangeLog

diffstat:

 ChangeLog            |   6 ++++++
 configure.ac         |   2 +-
 doc/gmp.texi         |   6 +++++-
 gmp-h.in             |  21 +++++++++++++++++++++
 gmp-impl.h           |  13 +------------
 mpn/generic/zero_p.c |  34 ++++++++++++++++++++++++++++++++++
 6 files changed, 68 insertions(+), 14 deletions(-)

diffs (157 lines):

diff -r ba77dddd5b1b -r fae7c40baa09 ChangeLog
--- a/ChangeLog	Sat May 30 07:07:04 2015 +0200
+++ b/ChangeLog	Sat May 30 08:33:51 2015 +0200
@@ -6,6 +6,12 @@
 
 	* mpf/sqrt_ui.c: Special case for sqrt(1).
 	* tests/mpf/t-sqrt_ui.c: Test special cases.
+
+	* gmp-h.in: Declare (and inline) mpn_zero_p.
+	* gmp-impl.h: Remove mpn_zero_p.
+	* mpn/generic/zero_p: New file to include the function in the library.
+	* configure.ac (gmp_mpn_functions): Add it.
+	* doc/gmp.texi: Document it.
 	
 2015-05-28  Niels Möller  <nisse at lysator.liu.se>
 
diff -r ba77dddd5b1b -r fae7c40baa09 configure.ac
--- a/configure.ac	Sat May 30 07:07:04 2015 +0200
+++ b/configure.ac	Sat May 30 08:33:51 2015 +0200
@@ -2854,7 +2854,7 @@
   mulmid_basecase toom42_mulmid mulmid_n mulmid				   \
   random random2 pow_1							   \
   rootrem sqrtrem sizeinbase get_str set_str				   \
-  scan0 scan1 popcount hamdist cmp					   \
+  scan0 scan1 popcount hamdist cmp zero_p				   \
   perfsqr perfpow							   \
   gcd_1 gcd gcdext_1 gcdext gcd_subdiv_step				   \
   gcdext_lehmer								   \
diff -r ba77dddd5b1b -r fae7c40baa09 doc/gmp.texi
--- a/doc/gmp.texi	Sat May 30 07:07:04 2015 +0200
+++ b/doc/gmp.texi	Sat May 30 08:33:51 2015 +0200
@@ -14,7 +14,7 @@
 This manual describes how to install and use the GNU multiple precision
 arithmetic library, version @value{VERSION}.
 
-Copyright 1991, 1993-2014 Free Software Foundation, Inc.
+Copyright 1991, 1993-2015 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document under
 the terms of the GNU Free Documentation License, Version 1.3 or any later
@@ -5440,6 +5440,10 @@
 negative value if @math{@var{s1} < @var{s2}}.
 @end deftypefun
 
+ at deftypefun int mpn_zero_p (const mp_limb_t *@var{sp}, mp_size_t @var{n})
+Test @{@var{sp}, @var{n}@} and return 1 if the operand is zero, 0 otherwise.
+ at end deftypefun
+
 @deftypefun mp_size_t mpn_gcd (mp_limb_t *@var{rp}, mp_limb_t *@var{xp}, mp_size_t @var{xn}, mp_limb_t *@var{yp}, mp_size_t @var{yn})
 Set @{@var{rp}, @var{retval}@} to the greatest common divisor of @{@var{xp},
 @var{xn}@} and @{@var{yp}, @var{yn}@}.  The result can be up to @var{yn} limbs,
diff -r ba77dddd5b1b -r fae7c40baa09 gmp-h.in
--- a/gmp-h.in	Sat May 30 07:07:04 2015 +0200
+++ b/gmp-h.in	Sat May 30 08:33:51 2015 +0200
@@ -1475,6 +1475,11 @@
 __GMP_DECLSPEC int mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
 #endif
 
+#define mpn_zero_p __MPN(zero_p)
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_zero_p)
+__GMP_DECLSPEC int mpn_zero_p (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+#endif
+
 #define mpn_divexact_1 __MPN(divexact_1)
 __GMP_DECLSPEC void mpn_divexact_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
 
@@ -2156,6 +2161,22 @@
 }
 #endif
 
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_zero_p)
+#if ! defined (__GMP_FORCE_mpn_zero_p)
+__GMP_EXTERN_INLINE
+#endif
+int
+mpn_zero_p (mp_srcptr __gmp_p, mp_size_t __gmp_n) __GMP_NOTHROW
+{
+  if (__gmp_n != 0)
+    do {
+      if (__gmp_p[--__gmp_n] != 0)
+	return 0;
+    } while (__gmp_n != 0);
+  return 1;
+}
+#endif
+
 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub)
 #if ! defined (__GMP_FORCE_mpn_sub)
 __GMP_EXTERN_INLINE
diff -r ba77dddd5b1b -r fae7c40baa09 gmp-impl.h
--- a/gmp-impl.h	Sat May 30 07:07:04 2015 +0200
+++ b/gmp-impl.h	Sat May 30 08:33:51 2015 +0200
@@ -3,7 +3,7 @@
    THE CONTENTS OF THIS FILE ARE FOR INTERNAL USE AND ARE ALMOST CERTAIN TO
    BE SUBJECT TO INCOMPATIBLE CHANGES IN FUTURE GNU MP RELEASES.
 
-Copyright 1991, 1993-1997, 1999-2014 Free Software Foundation, Inc.
+Copyright 1991, 1993-1997, 1999-2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -4656,17 +4656,6 @@
 }
 #endif
 
-static inline int
-mpn_zero_p (mp_srcptr ap, mp_size_t n)
-{
-  while (--n >= 0)
-    {
-      if (ap[n] != 0)
-	return 0;
-    }
-  return 1;
-}
-
 #if TUNE_PROGRAM_BUILD
 /* Some extras wanted when recompiling some .c files for use by the tune
    program.  Not part of a normal build.
diff -r ba77dddd5b1b -r fae7c40baa09 mpn/generic/zero_p.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/generic/zero_p.c	Sat May 30 08:33:51 2015 +0200
@@ -0,0 +1,34 @@
+/* mpn_zero_p (x,xsize) -- Return 1 if X is zero, 0 if it is non-zero.
+
+Copyright 2015 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of either:
+
+  * the GNU Lesser General Public License as published by the Free
+    Software Foundation; either version 3 of the License, or (at your
+    option) any later version.
+
+or
+
+  * the GNU General Public License as published by the Free Software
+    Foundation; either version 2 of the License, or (at your option) any
+    later version.
+
+or both in parallel, as here.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received copies of the GNU General Public License and the
+GNU Lesser General Public License along with the GNU MP Library.  If not,
+see https://www.gnu.org/licenses/.  */
+
+#define __GMP_FORCE_mpn_zero_p 1
+
+#include "gmp.h"
+#include "gmp-impl.h"


More information about the gmp-commit mailing list