[Gmp-commit] /var/hg/gmp: 3 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Tue Jan 1 20:16:16 UTC 2019
details: /var/hg/gmp/rev/c26b8e7004b5
changeset: 17745:c26b8e7004b5
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Tue Jan 01 20:59:01 2019 +0100
description:
mini-gmp/mini-gmp.c: Reindent.
details: /var/hg/gmp/rev/66286726789f
changeset: 17746:66286726789f
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Tue Jan 01 21:01:08 2019 +0100
description:
mini-gmp/mini-gmp.c (gmp_umul_ppmm): Use bit sizes.
details: /var/hg/gmp/rev/14649658a790
changeset: 17747:14649658a790
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Tue Jan 01 21:15:39 2019 +0100
description:
mini-gmp/ (mpz_lucas_mod): Use a wrapper as suggested by Niels.
diffstat:
mini-gmp/mini-gmp.c | 19 ++++++++-----------
mini-gmp/tests/t-lucm.c | 2 --
mini-gmp/tests/testutils.c | 7 +++++++
mini-gmp/tests/testutils.h | 4 +---
4 files changed, 16 insertions(+), 16 deletions(-)
diffs (102 lines):
diff -r ba431100f429 -r 14649658a790 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c Fri Dec 21 07:01:55 2018 +0100
+++ b/mini-gmp/mini-gmp.c Tue Jan 01 21:15:39 2019 +0100
@@ -130,13 +130,13 @@
#define gmp_umul_ppmm(w1, w0, u, v) \
do { \
int LOCAL_GMP_LIMB_BITS = GMP_LIMB_BITS; \
- if (sizeof (unsigned int) >= 2 * sizeof (mp_limb_t)) \
+ if (sizeof(unsigned int) * CHAR_BIT >= 2 * GMP_LIMB_BITS) \
{ \
unsigned int __ww = (unsigned int) (u) * (v); \
w0 = (mp_limb_t) __ww; \
w1 = (mp_limb_t) (__ww >> LOCAL_GMP_LIMB_BITS); \
} \
- else if (sizeof (unsigned long int) >= 2 * sizeof (mp_limb_t)) \
+ else if (GMP_ULONG_BITS >= 2 * GMP_LIMB_BITS) \
{ \
unsigned long int __ww = (unsigned long int) (u) * (v); \
w0 = (mp_limb_t) __ww; \
@@ -1550,8 +1550,8 @@
int
mpz_fits_slong_p (const mpz_t u)
{
- return (LONG_MAX + LONG_MIN == 0 || mpz_cmp_ui (u, LONG_MAX) <= 0) &&
- mpz_cmpabs_ui (u, GMP_NEG_CAST (unsigned long int, LONG_MIN)) <= 0;
+ return (LONG_MAX + LONG_MIN == 0 || mpz_cmp_ui (u, LONG_MAX) <= 0) &&
+ mpz_cmpabs_ui (u, GMP_NEG_CAST (unsigned long int, LONG_MIN)) <= 0;
}
static int
@@ -1571,7 +1571,7 @@
{
mp_size_t us = u->_mp_size;
- return us >= 0 && mpn_absfits_ulong_p (u->_mp_d, us);
+ return us >= 0 && mpn_absfits_ulong_p (u->_mp_d, us);
}
long int
@@ -3400,11 +3400,8 @@
/* with P=1, Q=Q; k = (n>>b0)|1. */
/* Requires an odd n > 4; b0 > 0; -2*Q must not overflow a long */
/* Returns (U_k == 0) and sets V=V_k and Qk=Q^k. */
-#ifndef __MINI_GMP_TESTING
-static
-#endif
-int
-mpz_lucas_mod (mpz_t V, mpz_t Qk, long Q,
+static int
+gmp_lucas_mod (mpz_t V, mpz_t Qk, long Q,
mp_bitcnt_t b0, const mpz_t n)
{
mp_bitcnt_t bs;
@@ -3504,7 +3501,7 @@
/* D= P^2 - 4Q; P = 1; Q = (1-D)/4 */
Q = (D & 2) ? (D >> 2) + 1 : -(long) (D >> 2);
- if (! mpz_lucas_mod (V, Qk, Q, b0, n)) /* If Ud != 0 */
+ if (! gmp_lucas_mod (V, Qk, Q, b0, n)) /* If Ud != 0 */
while (V->_mp_size != 0 && --b0 != 0) /* while Vk != 0 */
/* V <- V ^ 2 - 2Q^k */
/* Q^{2k} = (Q^k)^2 */
diff -r ba431100f429 -r 14649658a790 mini-gmp/tests/t-lucm.c
--- a/mini-gmp/tests/t-lucm.c Fri Dec 21 07:01:55 2018 +0100
+++ b/mini-gmp/tests/t-lucm.c Tue Jan 01 21:15:39 2019 +0100
@@ -24,8 +24,6 @@
#include "testutils.h"
-int mpz_lucas_mod (mpz_t, mpz_t, long, mp_bitcnt_t, const mpz_t);
-
#define MAXBITS 100
#define COUNT 1000
diff -r ba431100f429 -r 14649658a790 mini-gmp/tests/testutils.c
--- a/mini-gmp/tests/testutils.c Fri Dec 21 07:01:55 2018 +0100
+++ b/mini-gmp/tests/testutils.c Tue Jan 01 21:15:39 2019 +0100
@@ -172,3 +172,10 @@
abort();
}
}
+
+int
+mpz_lucas_mod (mpz_t V, mpz_t Qk, long Q,
+ mp_bitcnt_t b0, const mpz_t n)
+{
+ return gmp_lucas_mod (V, Qk, Q, b0, n);
+}
diff -r ba431100f429 -r 14649658a790 mini-gmp/tests/testutils.h
--- a/mini-gmp/tests/testutils.h Fri Dec 21 07:01:55 2018 +0100
+++ b/mini-gmp/tests/testutils.h Tue Jan 01 21:15:39 2019 +0100
@@ -36,9 +36,7 @@
void
mpz_set_str_or_abort (mpz_ptr z, const char *str, int base);
-/* Prototype for functions that have one only for the tests. */
-#define __MINI_GMP_TESTING 1
-
+/* Prototype for wrappers to internal functions to be tested. */
int
mpz_lucas_mod (mpz_t V, mpz_t Qk, long Q,
mp_bitcnt_t b0, const mpz_t n);
More information about the gmp-commit
mailing list