[Gmp-commit] /var/hg/gmp: 3 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Tue Feb 28 15:25:31 CET 2012
details: /var/hg/gmp/rev/d9b7f30bff56
changeset: 14696:d9b7f30bff56
user: Niels M?ller <nisse at lysator.liu.se>
date: Tue Feb 28 15:22:50 2012 +0100
description:
Bugfix for overlapping operations in mini-gmp.
details: /var/hg/gmp/rev/fdf6372dfaf1
changeset: 14697:fdf6372dfaf1
user: Niels M?ller <nisse at lysator.liu.se>
date: Tue Feb 28 15:23:53 2012 +0100
description:
Fixed mini-gmp mpz_cmp.
details: /var/hg/gmp/rev/809b16c44d82
changeset: 14698:809b16c44d82
user: Niels M?ller <nisse at lysator.liu.se>
date: Tue Feb 28 15:25:25 2012 +0100
description:
New make target check-mini-gmp.
diffstat:
ChangeLog | 18 +++++++++++++++++-
Makefile.am | 12 ++++++++++++
mini-gmp/mini-gmp.c | 44 +++++++++++++++++++++++---------------------
mini-gmp/tests/Makefile | 15 +++++++++------
4 files changed, 61 insertions(+), 28 deletions(-)
diffs (195 lines):
diff -r af165a15e6e7 -r 809b16c44d82 ChangeLog
--- a/ChangeLog Mon Feb 27 23:23:12 2012 +0100
+++ b/ChangeLog Tue Feb 28 15:25:25 2012 +0100
@@ -1,3 +1,19 @@
+2012-02-28 Niels Möller <nisse at lysator.liu.se>
+
+ * Makefile.am (check-mini-gmp): New target, for running the
+ mini-gmp testsuite.
+
+ * mini-gmp/tests/Makefile (srcdir, MINI_GMP_DIR): New make
+ variables. These can be overridden when using a separate build
+ directory.
+ (EXTRA_CFLAGS): Renamed, was OPTFLAGS.
+
+ * mini-gmp/mini-gmp.c (mpz_abs_add): Don't cache limb pointers
+ over MPZ_REALLOC, since that breaks in-place operation. Bug
+ spotted by Torbjörn.
+ (mpz_and, mpz_ior, mpz_xor): Likewise.
+ (mpz_cmp): Fixed comparison of negative numbers.
+
2012-02-27 Torbjorn Granlund <tege at gmplib.org>
* mpn/x86_64/fastsse/lshiftc.asm: New file.
@@ -29,7 +45,7 @@
* doc/gmp.texi: Document mpz_2fac_ui.
* mpz/Makefile.am (libmpz_la_SOURCES): Add 2fac_ui.c.
- * mpz/oddfac_1.c (mpz_oddfac_1): Use umul_ppmm when size = 2.
+ * mpz/oddfac_1.c (mpz_oddfac_1): Use umul_ppmm when size = 2.
2012-02-26 Niels Möller <nisse at lysator.liu.se>
diff -r af165a15e6e7 -r 809b16c44d82 Makefile.am
--- a/Makefile.am Mon Feb 27 23:23:12 2012 +0100
+++ b/Makefile.am Tue Feb 28 15:25:25 2012 +0100
@@ -397,3 +397,15 @@
# grep -F $(VERSION) $(srcdir)/Makefile.am \
# | grep -q "^# *$(VERSION) *$(LIBGMP_LT_CURRENT):$(LIBGMP_LT_REVISION):$(LIBGMP_LT_AGE) *$(LIBGMPXX_LT_CURRENT):$(LIBGMPXX_LT_REVISION):$(LIBGMPXX_LT_AGE) *$(LIBMP_LT_CURRENT):$(LIBMP_LT_REVISION):$(LIBMP_LT_AGE)"
# test -z "`sed -n 's/^# *[0-9]*\.[0-9]*\.[0-9]* *\([0-9]*:[0-9]*:[0-9]*\) *\([0-9]*:[0-9]*:[0-9]*\) *\([0-9]*:[0-9]*:[0-9]*\).*/A\1\nB\2\nC\3/p' $(srcdir)/Makefile.am | grep -v 'A6:3:3\|B3:5:0\|C4:7:1' | sort | uniq -d`"
+
+check-mini-gmp:
+ abs_srcdir="`cd $(srcdir) && pwd`" ; \
+ $(MKDIR_P) mini-gmp/tests \
+ && cd mini-gmp/tests \
+ && make -f "$$abs_srcdir/mini-gmp/tests/Makefile" \
+ VPATH="$$abs_srcdir/mini-gmp/tests" \
+ srcdir="$$abs_srcdir/mini-gmp/tests" \
+ MINI_GMP_DIR="$$abs_srcdir/mini-gmp" \
+ LDFLAGS="-L../../.libs" \
+ LIBS="-lgmp -lm" \
+ CC="$(CC_FOR_BUILD)" EXTRA_CFLAGS="-g" check
diff -r af165a15e6e7 -r 809b16c44d82 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c Mon Feb 27 23:23:12 2012 +0100
+++ b/mini-gmp/mini-gmp.c Tue Feb 28 15:25:25 2012 +0100
@@ -1694,7 +1694,7 @@
else if (asize > 0)
return mpn_cmp (a->_mp_d, b->_mp_d, asize);
else if (asize < 0)
- return -mpn_cmp (a->_mp_d, b->_mp_d, asize);
+ return -mpn_cmp (a->_mp_d, b->_mp_d, -asize);
else
return 0;
}
@@ -1835,21 +1835,20 @@
{
mp_size_t an = GMP_ABS (a->_mp_size);
mp_size_t bn = GMP_ABS (b->_mp_size);
- mp_ptr ap = a->_mp_d;
- mp_ptr bp = b->_mp_d;
+ mp_size_t rn;
mp_ptr rp;
mp_limb_t cy;
- if (an < bn)
- MPN_PTR_SWAP (ap, an, bp, bn);
-
- rp = MPZ_REALLOC (r, an + 1);
-
- cy = mpn_add (rp, ap, an, bp, bn);
- rp[an] = cy;
- an += (cy > 0);
-
- return an;
+ rn = GMP_MAX (an, bn);
+ rp = MPZ_REALLOC (r, rn + 1);
+ if (an >= bn)
+ cy = mpn_add (rp, a->_mp_d, an, b->_mp_d, bn);
+ else
+ cy = mpn_add (rp, b->_mp_d, bn, a->_mp_d, an);
+
+ rp[rn] = cy;
+
+ return rn + (cy > 0);
}
static mp_size_t
@@ -3287,9 +3286,6 @@
return;
}
- up = u->_mp_d;
- vp = v->_mp_d;
-
uc = u->_mp_size < 0;
vc = v->_mp_size < 0;
rc = uc & vc;
@@ -3303,6 +3299,9 @@
rp = MPZ_REALLOC (r, rn + rc);
+ up = u->_mp_d;
+ vp = v->_mp_d;
+
for (i = 0; i < vn; i++)
{
ul = (up[i] ^ ux) + uc;
@@ -3356,8 +3355,6 @@
mpz_set (r, u);
return;
}
- up = u->_mp_d;
- vp = v->_mp_d;
uc = u->_mp_size < 0;
vc = v->_mp_size < 0;
@@ -3372,6 +3369,10 @@
rn = vx ? vn : un;
rp = MPZ_REALLOC (r, rn + rc);
+
+ up = u->_mp_d;
+ vp = v->_mp_d;
+
for (i = 0; i < vn; i++)
{
ul = (up[i] ^ ux) + uc;
@@ -3426,9 +3427,6 @@
return;
}
- up = u->_mp_d;
- vp = v->_mp_d;
-
uc = u->_mp_size < 0;
vc = v->_mp_size < 0;
rc = uc ^ vc;
@@ -3438,6 +3436,10 @@
rx = -rc;
rp = MPZ_REALLOC (r, un + rc);
+
+ up = u->_mp_d;
+ vp = v->_mp_d;
+
for (i = 0; i < vn; i++)
{
ul = (up[i] ^ ux) + uc;
diff -r af165a15e6e7 -r 809b16c44d82 mini-gmp/tests/Makefile
--- a/mini-gmp/tests/Makefile Mon Feb 27 23:23:12 2012 +0100
+++ b/mini-gmp/tests/Makefile Tue Feb 28 15:25:25 2012 +0100
@@ -1,8 +1,11 @@
# Note: Requires GNU make
+srcdir=.
+MINI_GMP_DIR=..
+
CC = gcc
-OPTFLAGS = -O
-CFLAGS = $(OPTFLAGS) -Wall -g -I ..
+EXTRA_CFLAGS = -O -Wall -g
+CFLAGS = $(EXTRA_CFLAGS) -I$(MINI_GMP_DIR)
LDFLAGS =
LIBS = -lgmp -lm -lmcheck
@@ -24,11 +27,11 @@
# Keep object files
.PRECIOUS: %.o
-%.o: %.c ../mini-gmp.h hex-random.h mini-random.h
+%.o: %.c $(MINI_GMP_DIR)/mini-gmp.h hex-random.h mini-random.h
$(CC) $(CFLAGS) -c $< -o $@
-mini-gmp.o: ../mini-gmp.c ../mini-gmp.h
- $(CC) $(CFLAGS) -c ../mini-gmp.c -o mini-gmp.o
+mini-gmp.o: $(MINI_GMP_DIR)/mini-gmp.c $(MINI_GMP_DIR)/mini-gmp.h
+ $(CC) $(CFLAGS) -c $(MINI_GMP_DIR)/mini-gmp.c -o mini-gmp.o
%: %.o $(MISC_OBJS)
$(CC) $(LDFLAGS) $^ $(LIBS) -o $@
@@ -37,4 +40,4 @@
# mpz_cmp_d, mpz_popcount, mpz_hamdist, mpz_ui_pow_ui
check: $(CHECK_PROGRAMS)
- ./run-tests $(CHECK_PROGRAMS)
+ $(srcdir)/run-tests $(CHECK_PROGRAMS)
More information about the gmp-commit
mailing list