[Gmp-commit] /var/hg/gmp-5.0: 2 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Tue Jan 17 16:06:37 CET 2012
details: /var/hg/gmp-5.0/rev/3b400782eaeb
changeset: 13499:3b400782eaeb
user: Torbjorn Granlund <tege at gmplib.org>
date: Tue Jan 17 16:05:17 2012 +0100
description:
Merge mpz/scan0.c and mpz/scan1.c fixes from mainline repo.
details: /var/hg/gmp-5.0/rev/26b089872ad2
changeset: 13500:26b089872ad2
user: Torbjorn Granlund <tege at gmplib.org>
date: Tue Jan 17 16:06:13 2012 +0100
description:
*** empty log message ***
diffstat:
ChangeLog | 8 ++++
mpz/scan0.c | 74 +++++++++++++++++++++---------------------
mpz/scan1.c | 102 ++++++++++++++++++++++++++++++------------------------------
3 files changed, 96 insertions(+), 88 deletions(-)
diffs (282 lines):
diff -r e20b2b5caf36 -r 26b089872ad2 ChangeLog
--- a/ChangeLog Tue Jan 17 14:35:57 2012 +0100
+++ b/ChangeLog Tue Jan 17 16:06:13 2012 +0100
@@ -7,8 +7,16 @@
* Makefile.am (LIBGMP_LT_*, LIBGMPXX_LT_*, LIBMP_LT_*):
Bump version info.
+ * configure.in: Add ultrasparc T4 support.
+
* demos/isprime.c (main): Run 25 millerrabin tests.
+2012-01-15 Niels Möller <nisse at lysator.liu.se>
+
+ * mpz/scan0.c (mpz_scan0): Use ~(mp_bitcnt_t) 0, rather than
+ ULONG_MAX, when returning "infinity".
+ * mpz/scan1.c (mpz_scan1): Likewise.
+
2011-12-30 Torbjorn Granlund <tege at gmplib.org>
* mpz/hamdist.c: Fix typo in a return statement.
diff -r e20b2b5caf36 -r 26b089872ad2 mpz/scan0.c
--- a/mpz/scan0.c Tue Jan 17 14:35:57 2012 +0100
+++ b/mpz/scan0.c Tue Jan 17 16:06:13 2012 +0100
@@ -1,6 +1,6 @@
/* mpz_scan0 -- search for a 0 bit.
-Copyright 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002, 2004, 2012 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -42,7 +42,7 @@
/* When past end, there's an immediate 0 bit for u>=0, or no 0 bits for
u<0. Notice this test picks up all cases of u==0 too. */
if (starting_limb >= abs_size)
- return (size >= 0 ? starting_bit : ULONG_MAX);
+ return (size >= 0 ? starting_bit : ~(mp_bitcnt_t) 0);
limb = *p;
@@ -52,14 +52,14 @@
limb |= (CNST_LIMB(1) << (starting_bit % GMP_NUMB_BITS)) - 1;
/* Search for a limb which isn't all ones. If the end is reached then
- the zero bit immediately past the end is returned. */
+ the zero bit immediately past the end is returned. */
while (limb == GMP_NUMB_MAX)
- {
- p++;
- if (p == u_end)
- return (mp_bitcnt_t) abs_size * GMP_NUMB_BITS;
- limb = *p;
- }
+ {
+ p++;
+ if (p == u_end)
+ return (mp_bitcnt_t) abs_size * GMP_NUMB_BITS;
+ limb = *p;
+ }
/* Now seek low 1 bit. */
limb = ~limb;
@@ -69,21 +69,21 @@
mp_srcptr q;
/* If there's a non-zero limb before ours then we're in the ones
- complement region. Search from *(p-1) downwards since that might
- give better cache locality, and since a non-zero in the middle of a
- number is perhaps a touch more likely than at the end. */
+ complement region. Search from *(p-1) downwards since that might
+ give better cache locality, and since a non-zero in the middle of a
+ number is perhaps a touch more likely than at the end. */
q = p;
while (q != u_ptr)
- {
- q--;
- if (*q != 0)
- goto inverted;
- }
+ {
+ q--;
+ if (*q != 0)
+ goto inverted;
+ }
/* Adjust so ~limb implied by searching for 1 bit below becomes -limb.
- If limb==0 here then this isn't the beginning of twos complement
- inversion, but that doesn't matter because limb==0 is a zero bit
- immediately (-1 is all ones for below). */
+ If limb==0 here then this isn't the beginning of twos complement
+ inversion, but that doesn't matter because limb==0 is a zero bit
+ immediately (-1 is all ones for below). */
limb--;
inverted:
@@ -93,24 +93,24 @@
limb &= (MP_LIMB_T_MAX << (starting_bit % GMP_NUMB_BITS));
if (limb == 0)
- {
- /* If the high limb is zero after masking, then no 1 bits past
- starting_bit. */
- p++;
- if (p == u_end)
- return ULONG_MAX;
+ {
+ /* If the high limb is zero after masking, then no 1 bits past
+ starting_bit. */
+ p++;
+ if (p == u_end)
+ return ~(mp_bitcnt_t) 0;
- /* Search further for a non-zero limb. The high limb is non-zero,
- if nothing else. */
- for (;;)
- {
- limb = *p;
- if (limb != 0)
- break;
- p++;
- ASSERT (p < u_end);
- }
- }
+ /* Search further for a non-zero limb. The high limb is non-zero,
+ if nothing else. */
+ for (;;)
+ {
+ limb = *p;
+ if (limb != 0)
+ break;
+ p++;
+ ASSERT (p < u_end);
+ }
+ }
}
ASSERT (limb != 0);
diff -r e20b2b5caf36 -r 26b089872ad2 mpz/scan1.c
--- a/mpz/scan1.c Tue Jan 17 14:35:57 2012 +0100
+++ b/mpz/scan1.c Tue Jan 17 16:06:13 2012 +0100
@@ -1,6 +1,6 @@
/* mpz_scan1 -- search for a 1 bit.
-Copyright 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002, 2004, 2012 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -42,7 +42,7 @@
/* Past the end there's no 1 bits for u>=0, or an immediate 1 bit for u<0.
Notice this test picks up any u==0 too. */
if (starting_limb >= abs_size)
- return (size >= 0 ? ULONG_MAX : starting_bit);
+ return (size >= 0 ? ~(mp_bitcnt_t) 0 : starting_bit);
limb = *p;
@@ -52,60 +52,60 @@
limb &= (MP_LIMB_T_MAX << (starting_bit % GMP_NUMB_BITS));
if (limb == 0)
- {
- /* If it's the high limb which is zero after masking, then there's
- no 1 bits after starting_bit. */
- p++;
- if (p == u_end)
- return ULONG_MAX;
+ {
+ /* If it's the high limb which is zero after masking, then there's
+ no 1 bits after starting_bit. */
+ p++;
+ if (p == u_end)
+ return ~(mp_bitcnt_t) 0;
- /* Otherwise search further for a non-zero limb. The high limb is
- non-zero, if nothing else. */
- for (;;)
- {
- limb = *p;
- if (limb != 0)
- break;
- p++;
- ASSERT (p < u_end);
- }
- }
+ /* Otherwise search further for a non-zero limb. The high limb is
+ non-zero, if nothing else. */
+ for (;;)
+ {
+ limb = *p;
+ if (limb != 0)
+ break;
+ p++;
+ ASSERT (p < u_end);
+ }
+ }
}
else
{
mp_srcptr q;
/* If there's a non-zero limb before ours then we're in the ones
- complement region. Search from *(p-1) downwards since that might
- give better cache locality, and since a non-zero in the middle of a
- number is perhaps a touch more likely than at the end. */
+ complement region. Search from *(p-1) downwards since that might
+ give better cache locality, and since a non-zero in the middle of a
+ number is perhaps a touch more likely than at the end. */
q = p;
while (q != u_ptr)
- {
- q--;
- if (*q != 0)
- goto inverted;
- }
+ {
+ q--;
+ if (*q != 0)
+ goto inverted;
+ }
if (limb == 0)
- {
- /* Skip zero limbs, to find the start of twos complement. The
- high limb is non-zero, if nothing else. This search is
- necessary so the -limb is applied at the right spot. */
- do
- {
- p++;
- ASSERT (p < u_end);
- limb = *p;
- }
- while (limb == 0);
+ {
+ /* Skip zero limbs, to find the start of twos complement. The
+ high limb is non-zero, if nothing else. This search is
+ necessary so the -limb is applied at the right spot. */
+ do
+ {
+ p++;
+ ASSERT (p < u_end);
+ limb = *p;
+ }
+ while (limb == 0);
- /* Apply twos complement, and look for a 1 bit in that. Since
- limb!=0 here, also have (-limb)!=0 so there's certainly a 1
- bit. */
- limb = -limb;
- goto got_limb;
- }
+ /* Apply twos complement, and look for a 1 bit in that. Since
+ limb!=0 here, also have (-limb)!=0 so there's certainly a 1
+ bit. */
+ limb = -limb;
+ goto got_limb;
+ }
/* Adjust so ~limb implied by searching for 0 bit becomes -limb. */
limb--;
@@ -117,14 +117,14 @@
limb |= (CNST_LIMB(1) << (starting_bit % GMP_NUMB_BITS)) - 1;
/* Search for a limb which is not all ones. If the end is reached
- then the zero immediately past the end is the result. */
+ then the zero immediately past the end is the result. */
while (limb == GMP_NUMB_MAX)
- {
- p++;
- if (p == u_end)
- return (mp_bitcnt_t) abs_size * GMP_NUMB_BITS;
- limb = *p;
- }
+ {
+ p++;
+ if (p == u_end)
+ return (mp_bitcnt_t) abs_size * GMP_NUMB_BITS;
+ limb = *p;
+ }
/* Now seeking low 1 bit. */
limb = ~limb;
More information about the gmp-commit
mailing list