[Gmp-commit] /var/hg/gmp: 2 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Sun May 6 20:13:19 CEST 2012
details: /var/hg/gmp/rev/7a2b8f13d310
changeset: 14946:7a2b8f13d310
user: Torbjorn Granlund <tege at gmplib.org>
date: Sun May 06 19:32:33 2012 +0200
description:
Simplify n=4 code.
details: /var/hg/gmp/rev/da0a8f4c316a
changeset: 14947:da0a8f4c316a
user: Torbjorn Granlund <tege at gmplib.org>
date: Sun May 06 20:13:17 2012 +0200
description:
Put untested mini-gmp functions under ENABLE_UNTESTED_FUNCTIONS.
diffstat:
ChangeLog | 7 +
mini-gmp/mini-gmp.c | 192 +++++++++++++++++++++++++++++++++++--------
mpn/arm/v6/sqr_basecase.asm | 16 +--
3 files changed, 169 insertions(+), 46 deletions(-)
diffs (truncated from 794 to 300 lines):
diff -r 0e37be20dfcf -r da0a8f4c316a ChangeLog
--- a/ChangeLog Sat May 05 18:07:56 2012 +0200
+++ b/ChangeLog Sun May 06 20:13:17 2012 +0200
@@ -1,3 +1,10 @@
+2012-05-06 Torbjorn Granlund <tege at gmplib.org>
+
+ * mini-gmp/mini-gmp.c: Put untested functions under
+ ENABLE_UNTESTED_FUNCTIONS.
+
+ * mpn/arm/v6/sqr_basecase.asm: Simplify n=4 code.
+
2012-05-05 Marco Bodrato <bodrato at mail.dm.unipi.it>
* mpn/generic/invert.c: Mark a branch UNLIKELY.
diff -r 0e37be20dfcf -r da0a8f4c316a mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c Sat May 05 18:07:56 2012 +0200
+++ b/mini-gmp/mini-gmp.c Sun May 06 20:13:17 2012 +0200
@@ -21,17 +21,22 @@
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-/* NOTE: All functions in this file which are not declared in
- mini-gmp.h are internal, and are not intended to be compatible
- neither with GMP nor with future versions of mini-gmp. */
+/* NOTE: All functions in this file which are not declared in mini-gmp.h are
+ internal, and are not intended to be compatible neither with GMP nor with
+ future versions of mini-gmp. */
/* Much of the material copied from GMP files, including: gmp-impl.h,
longlong.h, mpn/generic/add_n.c, mpn/generic/addmul_1.c,
- mpn/generic/lshift.c, mpn/generic/mul_1.c,
- mpn/generic/mul_basecase.c, mpn/generic/rshift.c,
- mpn/generic/sbpi1_div_qr.c, mpn/generic/sub_n.c,
+ mpn/generic/lshift.c, mpn/generic/mul_1.c, mpn/generic/mul_basecase.c,
+ mpn/generic/rshift.c, mpn/generic/sbpi1_div_qr.c, mpn/generic/sub_n.c,
mpn/generic/submul_1.c. */
+/* CAUTION: Many functions herein are not covered by the testsuite, or else
+ covered poorly, and are therefore not unlikely to have bugs or to be
+ miscompiled without detection. To enable untested functions, define
+ ENABLE_UNTESTED_FUNCTIONS to 1. Please contribute better testing of
+ mini-gmp! */
+
#include <assert.h>
#include <ctype.h>
#include <limits.h>
@@ -569,11 +574,13 @@
return rp[un - 1];
}
+#if ENABLE_UNTESTED_FUNCTIONS
void
mpn_mul_n (mp_ptr rp, mp_srcptr ap, mp_srcptr bp, mp_size_t n)
{
mpn_mul (rp, ap, n, bp, n);
}
+#endif
void
mpn_sqr (mp_ptr rp, mp_srcptr ap, mp_size_t n)
@@ -1180,6 +1187,7 @@
return sn;
}
+#if ENABLE_UNTESTED_FUNCTIONS
size_t
mpn_get_str (unsigned char *sp, int base, mp_ptr up, mp_size_t un)
{
@@ -1199,7 +1207,9 @@
return mpn_get_str_other (sp, base, &info, up, un);
}
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
static mp_size_t
mpn_set_str_bits (mp_ptr rp, const unsigned char *sp, size_t sn,
unsigned bits)
@@ -1230,7 +1240,9 @@
rn = mpn_normalized_size (rp, rn);
return rn;
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
static mp_size_t
mpn_set_str_other (mp_ptr rp, const unsigned char *sp, size_t sn,
mp_limb_t b, const struct mpn_base_info *info)
@@ -1267,7 +1279,9 @@
return rn;
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
mp_size_t
mpn_set_str (mp_ptr rp, const unsigned char *sp, size_t sn, int base)
{
@@ -1287,7 +1301,7 @@
return mpn_set_str_other (rp, sp, sn, base, &info);
}
}
-
+#endif
/* MPZ interface */
void
@@ -1386,12 +1400,14 @@
}
}
+#if ENABLE_UNTESTED_FUNCTIONS
void
mpz_init_set_si (mpz_t r, signed long int x)
{
mpz_init (r);
mpz_set_si (r, x);
}
+#endif
void
mpz_init_set_ui (mpz_t r, unsigned long int x)
@@ -1407,6 +1423,7 @@
mpz_set (r, x);
}
+#if ENABLE_UNTESTED_FUNCTIONS
int
mpz_fits_slong_p (const mpz_t u)
{
@@ -1421,7 +1438,9 @@
else
return 0;
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
int
mpz_fits_ulong_p (const mpz_t u)
{
@@ -1429,7 +1448,9 @@
return us == 0 || us == 1;
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
long int
mpz_get_si (const mpz_t u)
{
@@ -1442,19 +1463,25 @@
else
return 0;
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
unsigned long int
mpz_get_ui (const mpz_t u)
{
return u->_mp_size == 0 ? 0 : u->_mp_d[0];
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
size_t
mpz_size (const mpz_t u)
{
return GMP_ABS (u->_mp_size);
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
mp_limb_t
mpz_getlimbn (const mpz_t u, mp_size_t n)
{
@@ -1463,8 +1490,10 @@
else
return 0;
}
+#endif
+#if ENABLE_UNTESTED_FUNCTIONS
/* Conversions and comparison to double. */
void
mpz_set_d (mpz_t r, double x)
@@ -1519,14 +1548,18 @@
r->_mp_size = sign ? - rn : rn;
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
void
mpz_init_set_d (mpz_t r, double x)
{
mpz_init (r);
mpz_set_d (r, x);
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
double
mpz_get_d (const mpz_t u)
{
@@ -1548,7 +1581,9 @@
return x;
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
int
mpz_cmp_d (const mpz_t x, double d)
{
@@ -1608,6 +1643,7 @@
else
return 0;
}
+#endif
/* MPN comparisons and the like. */
@@ -1821,6 +1857,7 @@
r->_mp_size = mpz_abs_sub_ui (r, a, b);
}
+#if ENABLE_UNTESTED_FUNCTIONS
void
mpz_ui_sub (mpz_t r, unsigned long a, const mpz_t b)
{
@@ -1829,6 +1866,7 @@
else
r->_mp_size = -mpz_abs_sub_ui (r, b, a);
}
+#endif
static mp_size_t
mpz_abs_add (mpz_t r, const mpz_t a, const mpz_t b)
@@ -1904,6 +1942,7 @@
/* MPZ multiplication */
+#if ENABLE_UNTESTED_FUNCTIONS
void
mpz_mul_si (mpz_t r, const mpz_t u, long int v)
{
@@ -1932,6 +1971,8 @@
mpz_swap (r, t);
mpz_clear (t);
}
+#endif
+
void
mpz_mul_ui (mpz_t r, const mpz_t u, unsigned long int v)
@@ -2151,17 +2192,21 @@
}
}
+#if ENABLE_UNTESTED_FUNCTIONS
void
mpz_cdiv_qr (mpz_t q, mpz_t r, const mpz_t n, const mpz_t d)
{
mpz_div_qr (q, r, n, d, DIV_CEIL);
}
-
+#endif
+
+#if ENABLE_UNTESTED_FUNCTIONS
void
mpz_fdiv_qr (mpz_t q, mpz_t r, const mpz_t n, const mpz_t d)
{
mpz_div_qr (q, r, n, d, DIV_FLOOR);
}
+#endif
void
mpz_tdiv_qr (mpz_t q, mpz_t r, const mpz_t n, const mpz_t d)
@@ -2169,17 +2214,21 @@
mpz_div_qr (q, r, n, d, DIV_TRUNC);
}
+#if ENABLE_UNTESTED_FUNCTIONS
void
mpz_cdiv_q (mpz_t q, const mpz_t n, const mpz_t d)
{
mpz_div_qr (q, NULL, n, d, DIV_CEIL);
More information about the gmp-commit
mailing list