[Gmp-commit] /var/hg/gmp: mini-gmp/tests: Use mpz_lucas_mod from GMP only if ...
mercurial at gmplib.org
mercurial at gmplib.org
Wed Nov 14 07:28:17 UTC 2018
details: /var/hg/gmp/rev/a10492fa57c7
changeset: 17700:a10492fa57c7
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Wed Nov 14 08:27:41 2018 +0100
description:
mini-gmp/tests: Use mpz_lucas_mod from GMP only if available.
diffstat:
mini-gmp/tests/hex-random.c | 15 ++++++++++++++-
mini-gmp/tests/t-lucm.c | 5 +++++
2 files changed, 19 insertions(+), 1 deletions(-)
diffs (53 lines):
diff -r 7bc252d49b16 -r a10492fa57c7 mini-gmp/tests/hex-random.c
--- a/mini-gmp/tests/hex-random.c Mon Nov 12 19:58:01 2018 +0100
+++ b/mini-gmp/tests/hex-random.c Wed Nov 14 08:27:41 2018 +0100
@@ -28,12 +28,21 @@
#endif
#include "gmp.h"
+
+#include "hex-random.h"
+
/* FIXME: gmp-impl.h included only for mpz_lucas_mod */
/* #include "gmp-impl.h" */
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
#define mpz_lucas_mod __gmpz_lucas_mod
__GMP_DECLSPEC int mpz_lucas_mod (mpz_ptr, mpz_ptr, long, mp_bitcnt_t, mpz_srcptr, mpz_ptr, mpz_ptr);
-#include "hex-random.h"
+#if defined (__cplusplus)
+}
+#endif
static gmp_randstate_t state;
@@ -519,7 +528,11 @@
if (*Q == 1 || gmp_urandomb_ui (state, 1))
*Q = - *Q;
+#if (__GNU_MP_VERSION == 6 && (__GNU_MP_VERSION_MINOR > 1 || __GNU_MP_VERSION_PATCHLEVEL > 9))
*res = mpz_lucas_mod (v, q, *Q, *b0, m, t1, t2);
+#else
+ *b0 = 0;
+#endif
gmp_asprintf (vp, "%Zx", v);
gmp_asprintf (qp, "%Zx", q);
diff -r 7bc252d49b16 -r a10492fa57c7 mini-gmp/tests/t-lucm.c
--- a/mini-gmp/tests/t-lucm.c Mon Nov 12 19:58:01 2018 +0100
+++ b/mini-gmp/tests/t-lucm.c Wed Nov 14 08:27:41 2018 +0100
@@ -48,6 +48,11 @@
for (i = 0; i < COUNT; i++)
{
mini_random_lucm_op (MAXBITS, vr, qr, m, &Q, &b0, &resr);
+ if (b0 == 0)
+ {
+ fprintf (stderr, "lucas_mod: test disabled (%u tests done).\n", i);
+ break;
+ }
resm = mpz_lucas_mod (vm, qm, Q, b0, m);
if (resr != resm)
More information about the gmp-commit
mailing list