[Gmp-commit] /var/hg/gmp: 2 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Sat Dec 3 23:17:30 UTC 2016
details: /var/hg/gmp/rev/1b9724673f49
changeset: 17157:1b9724673f49
user: Torbjorn Granlund <tg at gmplib.org>
date: Sun Dec 04 00:17:13 2016 +0100
description:
Use mpz_clobber. Split mpz_gcdext macros to avoid spurious res3 dependency.
details: /var/hg/gmp/rev/6ef9ffecc52c
changeset: 17158:6ef9ffecc52c
user: Torbjorn Granlund <tg at gmplib.org>
date: Sun Dec 04 00:17:26 2016 +0100
description:
ChangeLog
diffstat:
ChangeLog | 19 ++++++++
tests/mpz/reuse.c | 128 ++++++++++++++++++++++++++++++++++++++---------------
2 files changed, 111 insertions(+), 36 deletions(-)
diffs (274 lines):
diff -r cc51eddeb50c -r 6ef9ffecc52c ChangeLog
--- a/ChangeLog Sun Dec 04 00:10:03 2016 +0100
+++ b/ChangeLog Sun Dec 04 00:17:26 2016 +0100
@@ -1,3 +1,10 @@
+2016-12-04 Torbjörn Granlund <tg at gmplib.org>
+
+ * tests/mpz/reuse.c: Use mpz_clobber. Split mpz_gcdext macros to avoid
+ spurious res3 dependency.
+
+ * tests/misc.c (mpz_clobber): New function.
+
2016-12-03 Niels Möller <nisse at lysator.liu.se>
* doc/gmp.texi (Number Theoretic Functions): Tweak mpz_gcdext
@@ -9,6 +16,18 @@
* tests/mpz/reuse.c (main): Test additional cases of reuse for
mpz_gcd and mpz_gcdext.
+2016-12-01 Torbjörn Granlund <tg at gmplib.org>
+
+ * tests/misc.c (seed_from_tod): Make shift well-defined.
+
+2016-11-29 Torbjörn Granlund <tg at gmplib.org>
+
+ * gmp-h.in (__GNU_MP__): Bump.
+
+ * mpz/inp_raw.c: Rewrite size computation to avoid overflow.
+
+ * mpz/kronsz.c: Use ABS_CAST to avoid undefined code.
+
2016-11-27 Marco Bodrato <bodrato at mail.dm.unipi.it>
* mpz/gcd.c, mpz/gcdext.c: Use NEWALLOC.
diff -r cc51eddeb50c -r 6ef9ffecc52c tests/mpz/reuse.c
--- a/tests/mpz/reuse.c Sun Dec 04 00:10:03 2016 +0100
+++ b/tests/mpz/reuse.c Sun Dec 04 00:17:26 2016 +0100
@@ -231,6 +231,10 @@
mpz_init (res3);
mpz_init (t);
+ mpz_set_ui (res1, 1); /* force allocation */
+ mpz_set_ui (res2, 1); /* force allocation */
+ mpz_set_ui (res3, 1); /* force allocation */
+
for (pass = 1; pass <= reps; pass++)
{
#ifndef VERBOSE
@@ -307,12 +311,14 @@
MPZ_CHECK_FORMAT (ref2);
mpz_set (res1, in1);
+ mpz_clobber (res2);
INVOKE_RRSS (ddss_div[i], res1, res2, res1, in2);
MPZ_CHECK_FORMAT (res1);
MPZ_CHECK_FORMAT (res2);
if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0)
FAIL (ddss_div, i, in1, in2, NULL);
+ mpz_clobber (res1);
mpz_set (res2, in1);
INVOKE_RRSS (ddss_div[i], res1, res2, res2, in2);
MPZ_CHECK_FORMAT (res1);
@@ -321,12 +327,14 @@
FAIL (ddss_div, i, in1, in2, NULL);
mpz_set (res1, in2);
+ mpz_clobber (res2);
INVOKE_RRSS (ddss_div[i], res1, res2, in1, res1);
MPZ_CHECK_FORMAT (res1);
MPZ_CHECK_FORMAT (res2);
if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0)
FAIL (ddss_div, i, in1, in2, NULL);
+ mpz_clobber (res1);
mpz_set (res2, in2);
INVOKE_RRSS (ddss_div[i], res1, res2, in1, res2);
MPZ_CHECK_FORMAT (res1);
@@ -387,11 +395,13 @@
MPZ_CHECK_FORMAT (ref1);
mpz_set (res1, in1);
+ mpz_clobber (res2);
r2 = (ddsi_div[i].fptr) (res1, res2, res1, in2i);
MPZ_CHECK_FORMAT (res1);
if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 || r1 != r2)
FAIL (ddsi_div, i, in1, in2, NULL);
+ mpz_clobber (res1);
mpz_set (res2, in1);
(ddsi_div[i].fptr) (res1, res2, res2, in2i);
MPZ_CHECK_FORMAT (res1);
@@ -467,100 +477,146 @@
MPZ_CHECK_FORMAT (ref2);
MPZ_CHECK_FORMAT (ref3);
-#define GCDEXT_CHECK(t, i1,i2) do { \
- mpz_gcdext (res1, res2, t ? res3 : NULL, i1, i2); \
+#define GCDEXT_CHECK3(i1, i2) do { \
+ mpz_gcdext (res1, res2, res3, i1, i2); \
MPZ_CHECK_FORMAT (res1); \
MPZ_CHECK_FORMAT (res2); \
MPZ_CHECK_FORMAT (res3); \
if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 \
|| mpz_cmp (ref3, res3) != 0) \
FAIL2 (mpz_gcdext, i1, i2, NULL); \
- } while(0)
+ } while (0)
+#define GCDEXT_CHECK2(i1, i2) do { \
+ mpz_gcdext (res1, res2, NULL, i1, i2); \
+ MPZ_CHECK_FORMAT (res1); \
+ MPZ_CHECK_FORMAT (res2); \
+ if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0) \
+ FAIL2 (mpz_gcdext, i1, i2, NULL); \
+ } while (0)
mpz_set (res1, in1);
- GCDEXT_CHECK (1, res1, in2);
+ mpz_clobber (res2);
+ mpz_clobber (res3);
+ GCDEXT_CHECK3 (res1, in2);
+ mpz_clobber (res1);
mpz_set (res2, in1);
- GCDEXT_CHECK (1, res2, in2);
+ mpz_clobber (res3);
+ GCDEXT_CHECK3 (res2, in2);
+ mpz_clobber (res1);
+ mpz_clobber (res2);
mpz_set (res3, in1);
- GCDEXT_CHECK (1, res3, in2);
+ GCDEXT_CHECK3 (res3, in2);
mpz_set (res1, in2);
- GCDEXT_CHECK (1, in1, res1);
+ mpz_clobber (res2);
+ mpz_clobber (res3);
+ GCDEXT_CHECK3 (in1, res1);
+ mpz_clobber (res1);
mpz_set (res2, in2);
- GCDEXT_CHECK (1, in1, res2);
+ mpz_clobber (res3);
+ GCDEXT_CHECK3 (in1, res2);
+ mpz_clobber (res1);
+ mpz_clobber (res2);
mpz_set (res3, in2);
- GCDEXT_CHECK (1, in1, res3);
+ GCDEXT_CHECK3 (in1, res3);
mpz_set (res1, in1);
mpz_set (res2, in2);
- GCDEXT_CHECK (1, res1, res2);
+ mpz_clobber (res3);
+ GCDEXT_CHECK3 (res1, res2);
mpz_set (res1, in1);
+ mpz_clobber (res2);
mpz_set (res3, in2);
- GCDEXT_CHECK (1, res1, res3);
+ GCDEXT_CHECK3 (res1, res3);
+ mpz_clobber (res1);
mpz_set (res2, in1);
mpz_set (res3, in2);
- GCDEXT_CHECK (1, res2, res3);
-
- mpz_set (res2, in1);
- mpz_set (res1, in2);
- GCDEXT_CHECK (1, res2, res1);
+ GCDEXT_CHECK3 (res2, res3);
- mpz_set (res3, in1);
mpz_set (res1, in2);
- GCDEXT_CHECK (1, res3, res1);
+ mpz_set (res2, in1);
+ mpz_clobber (res3);
+ GCDEXT_CHECK3 (res2, res1);
+ mpz_set (res1, in2);
+ mpz_clobber (res2);
mpz_set (res3, in1);
+ GCDEXT_CHECK3 (res3, res1);
+
+ mpz_clobber (res1);
mpz_set (res2, in2);
- GCDEXT_CHECK(1, res3, res2);
+ mpz_set (res3, in1);
+ GCDEXT_CHECK3(res3, res2);
mpz_set (res1, in1);
- GCDEXT_CHECK (0, res1, in2);
+ mpz_clobber (res2);
+ GCDEXT_CHECK2 (res1, in2);
+ mpz_clobber (res1);
mpz_set (res2, in1);
- GCDEXT_CHECK (0, res2, in2);
+ GCDEXT_CHECK2 (res2, in2);
mpz_set (res1, in2);
- GCDEXT_CHECK (0, in1, res1);
+ mpz_clobber (res2);
+ GCDEXT_CHECK2 (in1, res1);
+ mpz_clobber (res1);
mpz_set (res2, in2);
- GCDEXT_CHECK (0, in1, res2);
+ GCDEXT_CHECK2 (in1, res2);
#undef GCDEXT_CHECK
/* Identical inputs, gcd(in1, in1). Then the result should be
gcd = abs(in1), s = 0, t = sgn(in1). */
mpz_abs (ref1, in1);
mpz_set_ui (ref2, 0);
- mpz_set_si (ref3, mpz_sgn(in1));
+ mpz_set_si (ref3, mpz_sgn (in1));
-#define GCDEXT_CHECK_SAME(t, i) do { \
- mpz_gcdext(res1, res2, t ? res3 : NULL, i, i); \
+#define GCDEXT_CHECK_SAME3(in) do { \
+ mpz_gcdext (res1, res2, res3, in, in); \
MPZ_CHECK_FORMAT (res1); \
MPZ_CHECK_FORMAT (res2); \
MPZ_CHECK_FORMAT (res3); \
if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 \
|| mpz_cmp (ref3, res3) != 0) \
- FAIL2 (mpz_gcdext, i, i, NULL); \
- } while(0)
+ FAIL2 (mpz_gcdext, in, in, NULL); \
+ } while (0)
+#define GCDEXT_CHECK_SAME2(in) do { \
+ mpz_gcdext (res1, res2, NULL, in, in); \
+ MPZ_CHECK_FORMAT (res1); \
+ MPZ_CHECK_FORMAT (res2); \
+ if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0) \
+ FAIL2 (mpz_gcdext, in, in, NULL); \
+ } while (0)
mpz_set (res1, in1);
- GCDEXT_CHECK_SAME (1, res1);
+ mpz_clobber (res2);
+ mpz_clobber (res3);
+ GCDEXT_CHECK_SAME3 (res1);
- mpz_set(res2, in1);
- GCDEXT_CHECK_SAME (1, res2);
+ mpz_clobber (res1);
+ mpz_set (res2, in1);
+ mpz_clobber (res3);
+ GCDEXT_CHECK_SAME3 (res2);
- mpz_set(res3, in1);
- GCDEXT_CHECK_SAME (1, res3);
+ mpz_clobber (res1);
+ mpz_clobber (res2);
+ mpz_set (res3, in1);
+ GCDEXT_CHECK_SAME3 (res3);
mpz_set (res1, in1);
- GCDEXT_CHECK_SAME (0, res1);
+ mpz_clobber (res2);
+ mpz_clobber (res3);
+ GCDEXT_CHECK_SAME2 (res1);
- mpz_set(res2, in1);
- GCDEXT_CHECK_SAME (0, res2);
+ mpz_clobber (res1);
+ mpz_set (res2, in1);
+ mpz_clobber (res3);
+ GCDEXT_CHECK_SAME2 (res2);
#undef GCDEXT_CHECK_SAME
}
More information about the gmp-commit
mailing list