summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-22 13:26:30 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-22 13:26:30 (GMT)
commit3a1186689ae598d16a020a42844658ff57f62ff0 (patch)
tree16f4ae8dea27397fe9464df3a351983e9af99833
parent9c4252f295a2a05838cd0549ba51150943fab3dd (diff)
parent44bc67ccd6e74dea369f724743f77f047fa12edb (diff)
downloadtcl-3a1186689ae598d16a020a42844658ff57f62ff0.zip
tcl-3a1186689ae598d16a020a42844658ff57f62ff0.tar.gz
tcl-3a1186689ae598d16a020a42844658ff57f62ff0.tar.bz2
Merge 8.7, and update to latest libtommath (support/1.x branch)
-rw-r--r--libtommath/appveyor.yml1
-rw-r--r--libtommath/bn_deprecated.c10
-rw-r--r--libtommath/bn_mp_log_u32.c18
-rw-r--r--libtommath/bn_mp_montgomery_reduce.c4
-rw-r--r--libtommath/bn_mp_mul.c8
-rw-r--r--libtommath/bn_mp_prime_rand.c2
-rw-r--r--libtommath/bn_mp_radix_smap.c2
-rw-r--r--libtommath/bn_mp_root_u32.c4
-rw-r--r--libtommath/bn_mp_set_double.c2
-rw-r--r--libtommath/bn_mp_sqr.c2
-rw-r--r--libtommath/bn_mp_to_ubin.c3
-rw-r--r--libtommath/bn_prime_tab.c16
-rw-r--r--libtommath/bn_s_mp_exptmod_fast.c2
-rw-r--r--libtommath/bn_s_mp_montgomery_reduce_fast.c4
-rw-r--r--libtommath/bn_s_mp_mul_digs.c2
-rw-r--r--libtommath/bn_s_mp_mul_digs_fast.c2
-rw-r--r--libtommath/bn_s_mp_mul_high_digs.c2
-rw-r--r--libtommath/bn_s_mp_mul_high_digs_fast.c6
-rw-r--r--libtommath/bn_s_mp_sqr_fast.c2
-rw-r--r--libtommath/changes.txt2
-rwxr-xr-xlibtommath/helper.pl2
-rw-r--r--libtommath/makefile.mingw4
-rw-r--r--libtommath/makefile_include.mk8
-rw-r--r--libtommath/tommath.h15
-rw-r--r--libtommath/tommath_private.h1
-rw-r--r--tests/cmdMZ.test51
-rw-r--r--win/rules.vc17
27 files changed, 118 insertions, 74 deletions
diff --git a/libtommath/appveyor.yml b/libtommath/appveyor.yml
index 187a09a..08bb013 100644
--- a/libtommath/appveyor.yml
+++ b/libtommath/appveyor.yml
@@ -4,6 +4,7 @@ branches:
- master
- develop
- /^release/
+ - /^support/
- /^travis/
image:
- Visual Studio 2019
diff --git a/libtommath/bn_deprecated.c b/libtommath/bn_deprecated.c
index 873414e..2056b20 100644
--- a/libtommath/bn_deprecated.c
+++ b/libtommath/bn_deprecated.c
@@ -25,7 +25,7 @@ mp_err mp_jacobi(const mp_int *a, const mp_int *n, int *c)
}
#endif
#ifdef BN_MP_PRIME_RANDOM_EX_C
-mp_err mp_prime_random_ex(mp_int *a, int t, int size, int flags, mp_prime_callback cb, void *dat)
+mp_err mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
{
return s_mp_prime_random_ex(a, t, size, flags, cb, dat);
}
@@ -158,14 +158,14 @@ mp_err mp_set_int(mp_int *a, unsigned long b)
#ifdef BN_MP_SET_LONG_C
mp_err mp_set_long(mp_int *a, unsigned long b)
{
- mp_set_ul(a, b);
+ mp_set_u64(a, b);
return MP_OKAY;
}
#endif
#ifdef BN_MP_SET_LONG_LONG_C
mp_err mp_set_long_long(mp_int *a, unsigned long long b)
{
- mp_set_ull(a, b);
+ mp_set_u64(a, b);
return MP_OKAY;
}
#endif
@@ -219,7 +219,7 @@ mp_err mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
if (b > MP_MIN(MP_DIGIT_MAX, UINT32_MAX)) {
return MP_VAL;
}
- return mp_root_u32(a, (unsigned int)b, c);
+ return mp_root_u32(a, (uint32_t)b, c);
}
#endif
#ifdef BN_MP_N_ROOT_C
@@ -228,7 +228,7 @@ mp_err mp_n_root(const mp_int *a, mp_digit b, mp_int *c)
if (b > MP_MIN(MP_DIGIT_MAX, UINT32_MAX)) {
return MP_VAL;
}
- return mp_root_u32(a, (unsigned int)b, c);
+ return mp_root_u32(a, (uint32_t)b, c);
}
#endif
#ifdef BN_MP_UNSIGNED_BIN_SIZE_C
diff --git a/libtommath/bn_mp_log_u32.c b/libtommath/bn_mp_log_u32.c
index f507b1d..b86d789 100644
--- a/libtommath/bn_mp_log_u32.c
+++ b/libtommath/bn_mp_log_u32.c
@@ -6,7 +6,7 @@
/* Compute log_{base}(a) */
static mp_word s_pow(mp_word base, mp_word exponent)
{
- mp_word result = 1;
+ mp_word result = 1u;
while (exponent != 0u) {
if ((exponent & 1u) == 1u) {
result *= base;
@@ -20,8 +20,8 @@ static mp_word s_pow(mp_word base, mp_word exponent)
static mp_digit s_digit_ilogb(mp_digit base, mp_digit n)
{
- mp_word bracket_low = 1, bracket_mid, bracket_high, N;
- mp_digit ret, high = 1uL, low = 0uL, mid;
+ mp_word bracket_low = 1u, bracket_mid, bracket_high, N;
+ mp_digit ret, high = 1u, low = 0uL, mid;
if (n < base) {
return 0uL;
@@ -40,7 +40,7 @@ static mp_digit s_digit_ilogb(mp_digit base, mp_digit n)
bracket_high *= bracket_high;
}
- while (((mp_digit)(high - low)) > 1uL) {
+ while (((mp_digit)(high - low)) > 1u) {
mid = (low + high) >> 1;
bracket_mid = bracket_low * s_pow(base, (mp_word)(mid - low));
@@ -70,11 +70,11 @@ static mp_digit s_digit_ilogb(mp_digit base, mp_digit n)
as is the output of mp_bitcount.
With the same problem: max size is INT_MAX * MP_DIGIT not INT_MAX only!
*/
-mp_err mp_log_u32(const mp_int *a, unsigned int base, unsigned int *c)
+mp_err mp_log_u32(const mp_int *a, uint32_t base, uint32_t *c)
{
mp_err err;
mp_ord cmp;
- unsigned int high, low, mid;
+ uint32_t high, low, mid;
mp_int bracket_low, bracket_high, bracket_mid, t, bi_base;
err = MP_OKAY;
@@ -98,12 +98,12 @@ mp_err mp_log_u32(const mp_int *a, unsigned int base, unsigned int *c)
base >>= 1;
}
bit_count = mp_count_bits(a) - 1;
- *c = (unsigned int)(bit_count/y);
+ *c = (uint32_t)(bit_count/y);
return MP_OKAY;
}
if (a->used == 1) {
- *c = (unsigned int)s_digit_ilogb(base, a->dp[0]);
+ *c = (uint32_t)s_digit_ilogb(base, a->dp[0]);
return err;
}
@@ -146,7 +146,7 @@ mp_err mp_log_u32(const mp_int *a, unsigned int base, unsigned int *c)
while ((high - low) > 1u) {
mid = (high + low) >> 1;
- if ((err = mp_expt_u32(&bi_base, mid - low, &t)) != MP_OKAY) {
+ if ((err = mp_expt_u32(&bi_base, (uint32_t)(mid - low), &t)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_mul(&bracket_low, &t, &bracket_mid)) != MP_OKAY) {
diff --git a/libtommath/bn_mp_montgomery_reduce.c b/libtommath/bn_mp_montgomery_reduce.c
index 3ce1f15..ffe8341 100644
--- a/libtommath/bn_mp_montgomery_reduce.c
+++ b/libtommath/bn_mp_montgomery_reduce.c
@@ -17,8 +17,8 @@ mp_err mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
* are fixed up in the inner loop.
*/
digs = (n->used * 2) + 1;
- if ((digs < PRIVATE_MP_WARRAY) &&
- (x->used <= PRIVATE_MP_WARRAY) &&
+ if ((digs < MP_WARRAY) &&
+ (x->used <= MP_WARRAY) &&
(n->used < MP_MAXFAST)) {
return s_mp_montgomery_reduce_fast(x, n, rho);
}
diff --git a/libtommath/bn_mp_mul.c b/libtommath/bn_mp_mul.c
index c4890c5..91707cd 100644
--- a/libtommath/bn_mp_mul.c
+++ b/libtommath/bn_mp_mul.c
@@ -12,9 +12,7 @@ mp_err mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
digs = a->used + b->used + 1;
mp_sign neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
- if (a == b) {
- return mp_sqr(a,c);
- } else if (MP_HAS(S_MP_BALANCE_MUL) &&
+ if (MP_HAS(S_MP_BALANCE_MUL) &&
/* Check sizes. The smaller one needs to be larger than the Karatsuba cut-off.
* The bigger one needs to be at least about one MP_KARATSUBA_MUL_CUTOFF bigger
* to make some sense, but it depends on architecture, OS, position of the
@@ -37,10 +35,10 @@ mp_err mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
/* can we use the fast multiplier?
*
* The fast multiplier can be used if the output will
- * have less than PRIVATE_MP_WARRAY digits and the number of
+ * have less than MP_WARRAY digits and the number of
* digits won't affect carry propagation
*/
- (digs < PRIVATE_MP_WARRAY) &&
+ (digs < MP_WARRAY) &&
(min_len <= MP_MAXFAST)) {
err = s_mp_mul_digs_fast(a, b, c, digs);
} else if (MP_HAS(S_MP_MUL_DIGS)) {
diff --git a/libtommath/bn_mp_prime_rand.c b/libtommath/bn_mp_prime_rand.c
index af19d76c..4530e9a 100644
--- a/libtommath/bn_mp_prime_rand.c
+++ b/libtommath/bn_mp_prime_rand.c
@@ -18,7 +18,7 @@
*/
/* This is possibly the mother of all prime generation functions, muahahahahaha! */
-mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, mp_prime_callback cb, void *dat)
+mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
{
unsigned char *tmp, maskAND, maskOR_msb, maskOR_lsb;
int bsize, maskOR_msb_offset;
diff --git a/libtommath/bn_mp_radix_smap.c b/libtommath/bn_mp_radix_smap.c
index eb4765a..a16128d 100644
--- a/libtommath/bn_mp_radix_smap.c
+++ b/libtommath/bn_mp_radix_smap.c
@@ -5,7 +5,7 @@
/* chars used in radix conversions */
const char *const mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
-const unsigned char mp_s_rmap_reverse[] = {
+const uint8_t mp_s_rmap_reverse[] = {
0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, /* ()*+,-./ */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 01234567 */
0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 89:;<=>? */
diff --git a/libtommath/bn_mp_root_u32.c b/libtommath/bn_mp_root_u32.c
index b60cf26..ba65549 100644
--- a/libtommath/bn_mp_root_u32.c
+++ b/libtommath/bn_mp_root_u32.c
@@ -12,7 +12,7 @@
* which will find the root in log(N) time where
* each step involves a fair bit.
*/
-mp_err mp_root_u32(const mp_int *a, unsigned int b, mp_int *c)
+mp_err mp_root_u32(const mp_int *a, uint32_t b, mp_int *c)
{
mp_int t1, t2, t3, a_;
mp_ord cmp;
@@ -40,7 +40,7 @@ mp_err mp_root_u32(const mp_int *a, unsigned int b, mp_int *c)
log_2(n) because the bit-length of the "n" is measured
with an int and hence the root is always < 2 (two).
*/
- if (b > (unsigned int)(INT_MAX/2)) {
+ if (b > (uint32_t)(INT_MAX/2)) {
mp_set(c, 1uL);
c->sign = a->sign;
err = MP_OKAY;
diff --git a/libtommath/bn_mp_set_double.c b/libtommath/bn_mp_set_double.c
index 8d76f8c..7f1ab75 100644
--- a/libtommath/bn_mp_set_double.c
+++ b/libtommath/bn_mp_set_double.c
@@ -16,7 +16,7 @@ mp_err mp_set_double(mp_int *a, double b)
cast.dbl = b;
exp = (int)((unsigned)(cast.bits >> 52) & 0x7FFu);
- frac = (cast.bits & ((UINT64_C(1) << 52) - UINT64_C(1))) | (UINT64_C(1) << 52);
+ frac = (cast.bits & (((uint64_t)1 << 52) - (uint64_t)1)) | ((uint64_t)1 << 52);
if (exp == 0x7FF) { /* +-inf, NaN */
return MP_VAL;
diff --git a/libtommath/bn_mp_sqr.c b/libtommath/bn_mp_sqr.c
index 571b25d..e0d0a73 100644
--- a/libtommath/bn_mp_sqr.c
+++ b/libtommath/bn_mp_sqr.c
@@ -14,7 +14,7 @@ mp_err mp_sqr(const mp_int *a, mp_int *b)
(a->used >= MP_KARATSUBA_SQR_CUTOFF)) {
err = s_mp_karatsuba_sqr(a, b);
} else if (MP_HAS(S_MP_SQR_FAST) && /* can we use the fast comba multiplier? */
- (((a->used * 2) + 1) < PRIVATE_MP_WARRAY) &&
+ (((a->used * 2) + 1) < MP_WARRAY) &&
(a->used < (MP_MAXFAST / 2))) {
err = s_mp_sqr_fast(a, b);
} else if (MP_HAS(S_MP_SQR)) {
diff --git a/libtommath/bn_mp_to_ubin.c b/libtommath/bn_mp_to_ubin.c
index 4913c3a..1681ca7 100644
--- a/libtommath/bn_mp_to_ubin.c
+++ b/libtommath/bn_mp_to_ubin.c
@@ -10,8 +10,7 @@ mp_err mp_to_ubin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *wr
mp_err err;
mp_int t;
- size_t size = (size_t)mp_count_bits(a);
- count = (size / 8u) + (((size & 7u) != 0u) ? 1u : 0u);
+ count = mp_ubin_size(a);
if (count > maxlen) {
return MP_BUF;
}
diff --git a/libtommath/bn_prime_tab.c b/libtommath/bn_prime_tab.c
index 6bd53fe..a6c07f8 100644
--- a/libtommath/bn_prime_tab.c
+++ b/libtommath/bn_prime_tab.c
@@ -3,7 +3,7 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-const mp_digit s_mp_prime_tab[] = {
+const mp_digit ltm_prime_tab[] = {
0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013,
0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035,
0x003B, 0x003D, 0x0043, 0x0047, 0x0049, 0x004F, 0x0053, 0x0059,
@@ -44,4 +44,18 @@ const mp_digit s_mp_prime_tab[] = {
#endif
};
+#if defined(__GNUC__) && __GNUC__ >= 4
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+const mp_digit *s_mp_prime_tab = ltm_prime_tab;
+#pragma GCC diagnostic pop
+#elif defined(_MSC_VER) && _MSC_VER >= 1500
+#pragma warning(push)
+#pragma warning(disable: 4996)
+const mp_digit *s_mp_prime_tab = ltm_prime_tab;
+#pragma warning(pop)
+#else
+const mp_digit *s_mp_prime_tab = ltm_prime_tab;
+#endif
+
#endif
diff --git a/libtommath/bn_s_mp_exptmod_fast.c b/libtommath/bn_s_mp_exptmod_fast.c
index 3a0dc5b..682ded8 100644
--- a/libtommath/bn_s_mp_exptmod_fast.c
+++ b/libtommath/bn_s_mp_exptmod_fast.c
@@ -81,7 +81,7 @@ mp_err s_mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_i
/* automatically pick the comba one if available (saves quite a few calls/ifs) */
if (MP_HAS(S_MP_MONTGOMERY_REDUCE_FAST) &&
- (((P->used * 2) + 1) < PRIVATE_MP_WARRAY) &&
+ (((P->used * 2) + 1) < MP_WARRAY) &&
(P->used < MP_MAXFAST)) {
redux = s_mp_montgomery_reduce_fast;
} else if (MP_HAS(MP_MONTGOMERY_REDUCE)) {
diff --git a/libtommath/bn_s_mp_montgomery_reduce_fast.c b/libtommath/bn_s_mp_montgomery_reduce_fast.c
index 8c3fe5e..3f0c672 100644
--- a/libtommath/bn_s_mp_montgomery_reduce_fast.c
+++ b/libtommath/bn_s_mp_montgomery_reduce_fast.c
@@ -15,9 +15,9 @@ mp_err s_mp_montgomery_reduce_fast(mp_int *x, const mp_int *n, mp_digit rho)
{
int ix, olduse;
mp_err err;
- mp_word W[PRIVATE_MP_WARRAY];
+ mp_word W[MP_WARRAY];
- if (x->used > PRIVATE_MP_WARRAY) {
+ if (x->used > MP_WARRAY) {
return MP_VAL;
}
diff --git a/libtommath/bn_s_mp_mul_digs.c b/libtommath/bn_s_mp_mul_digs.c
index 6c1114e..64509d4 100644
--- a/libtommath/bn_s_mp_mul_digs.c
+++ b/libtommath/bn_s_mp_mul_digs.c
@@ -17,7 +17,7 @@ mp_err s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
mp_digit tmpx, *tmpt, *tmpy;
/* can we use the fast multiplier? */
- if ((digs < PRIVATE_MP_WARRAY) &&
+ if ((digs < MP_WARRAY) &&
(MP_MIN(a->used, b->used) < MP_MAXFAST)) {
return s_mp_mul_digs_fast(a, b, c, digs);
}
diff --git a/libtommath/bn_s_mp_mul_digs_fast.c b/libtommath/bn_s_mp_mul_digs_fast.c
index 090a099..b2a287b 100644
--- a/libtommath/bn_s_mp_mul_digs_fast.c
+++ b/libtommath/bn_s_mp_mul_digs_fast.c
@@ -23,7 +23,7 @@ mp_err s_mp_mul_digs_fast(const mp_int *a, const mp_int *b, mp_int *c, int digs)
{
int olduse, pa, ix, iz;
mp_err err;
- mp_digit W[PRIVATE_MP_WARRAY];
+ mp_digit W[MP_WARRAY];
mp_word _W;
/* grow the destination as required */
diff --git a/libtommath/bn_s_mp_mul_high_digs.c b/libtommath/bn_s_mp_mul_high_digs.c
index 5c5d721..2bb2a50 100644
--- a/libtommath/bn_s_mp_mul_high_digs.c
+++ b/libtommath/bn_s_mp_mul_high_digs.c
@@ -17,7 +17,7 @@ mp_err s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
/* can we use the fast multiplier? */
if (MP_HAS(S_MP_MUL_HIGH_DIGS_FAST)
- && ((a->used + b->used + 1) < PRIVATE_MP_WARRAY)
+ && ((a->used + b->used + 1) < MP_WARRAY)
&& (MP_MIN(a->used, b->used) < MP_MAXFAST)) {
return s_mp_mul_high_digs_fast(a, b, c, digs);
}
diff --git a/libtommath/bn_s_mp_mul_high_digs_fast.c b/libtommath/bn_s_mp_mul_high_digs_fast.c
index a74adc6..a0513b4 100644
--- a/libtommath/bn_s_mp_mul_high_digs_fast.c
+++ b/libtommath/bn_s_mp_mul_high_digs_fast.c
@@ -3,8 +3,8 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-/* this is a modified version of fast_s_mul_digs that only produces
- * output digits *above* digs. See the comments for fast_s_mul_digs
+/* this is a modified version of s_mp_mul_digs_fast that only produces
+ * output digits *above* digs. See the comments for s_mp_mul_digs_fast
* to see how it works.
*
* This is used in the Barrett reduction since for one of the multiplications
@@ -16,7 +16,7 @@ mp_err s_mp_mul_high_digs_fast(const mp_int *a, const mp_int *b, mp_int *c, int
{
int olduse, pa, ix, iz;
mp_err err;
- mp_digit W[PRIVATE_MP_WARRAY];
+ mp_digit W[MP_WARRAY];
mp_word _W;
/* grow the destination as required */
diff --git a/libtommath/bn_s_mp_sqr_fast.c b/libtommath/bn_s_mp_sqr_fast.c
index d5090fe..4a8a891 100644
--- a/libtommath/bn_s_mp_sqr_fast.c
+++ b/libtommath/bn_s_mp_sqr_fast.c
@@ -16,7 +16,7 @@ After that loop you do the squares and add them in.
mp_err s_mp_sqr_fast(const mp_int *a, mp_int *b)
{
int olduse, pa, ix, iz;
- mp_digit W[PRIVATE_MP_WARRAY], *tmpx;
+ mp_digit W[MP_WARRAY], *tmpx;
mp_word W1;
mp_err err;
diff --git a/libtommath/changes.txt b/libtommath/changes.txt
index ebf7382..1b3a7a3 100644
--- a/libtommath/changes.txt
+++ b/libtommath/changes.txt
@@ -1,4 +1,4 @@
-XXX XXth, 2019
+Oct 22nd, 2019
v1.2.0
-- A huge refactoring of the library happened - renaming,
deprecating and replacing existing functions by improved API's.
diff --git a/libtommath/helper.pl b/libtommath/helper.pl
index e60c1a7..c624b7c 100755
--- a/libtommath/helper.pl
+++ b/libtommath/helper.pl
@@ -51,7 +51,7 @@ sub check_source {
push @{$troubles->{tab}}, $lineno if $l =~ /\t/ && basename($file) !~ /^makefile/i;
push @{$troubles->{non_ascii_char}}, $lineno if $l =~ /[^[:ascii:]]/;
push @{$troubles->{cpp_comment}}, $lineno if $file =~ /\.(c|h)$/ && ($l =~ /\s\/\// || $l =~ /\/\/\s/);
- # we prefer using XMALLOC, XFREE, XREALLOC, XCALLOC ...
+ # we prefer using MP_MALLOC, MP_FREE, MP_REALLOC, MP_CALLOC ...
push @{$troubles->{unwanted_malloc}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmalloc\s*\(/;
push @{$troubles->{unwanted_realloc}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\brealloc\s*\(/;
push @{$troubles->{unwanted_calloc}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bcalloc\s*\(/;
diff --git a/libtommath/makefile.mingw b/libtommath/makefile.mingw
index d9d17de..7eee57d 100644
--- a/libtommath/makefile.mingw
+++ b/libtommath/makefile.mingw
@@ -11,11 +11,11 @@
#The following can be overridden from command line e.g. make -f makefile.mingw CC=gcc ARFLAGS=rcs
PREFIX = c:\mingw
-CC = i686-w64-mingw32-gcc
+CC = gcc
AR = ar
ARFLAGS = r
RANLIB = ranlib
-STRIP = i686-w64-mingw32-strip
+STRIP = strip
CFLAGS = -O2
LDFLAGS =
diff --git a/libtommath/makefile_include.mk b/libtommath/makefile_include.mk
index 7b025e8..452d37d 100644
--- a/libtommath/makefile_include.mk
+++ b/libtommath/makefile_include.mk
@@ -116,10 +116,10 @@ endif
# adjust coverage set
ifneq ($(filter $(_ARCH), i386 i686 x86_64 amd64 ia64),)
- COVERAGE = test_standalone timing
+ COVERAGE = test timing
COVERAGE_APP = ./test && ./timing
else
- COVERAGE = test_standalone
+ COVERAGE = test
COVERAGE_APP = ./test
endif
@@ -135,6 +135,10 @@ LIBPATH ?= $(PREFIX)/lib
INCPATH ?= $(PREFIX)/include
DATAPATH ?= $(PREFIX)/share/doc/libtommath/pdf
+# build & run test-suite
+check: test
+ ./test
+
#make the code coverage of the library
#
coverage: LTM_CFLAGS += -fprofile-arcs -ftest-coverage -DTIMING_NO_LOGS
diff --git a/libtommath/tommath.h b/libtommath/tommath.h
index 24dab35..a230da2 100644
--- a/libtommath/tommath.h
+++ b/libtommath/tommath.h
@@ -236,13 +236,22 @@ TOOM_SQR_CUTOFF;
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 405)
# define MP_DEPRECATED(x) __attribute__((deprecated("replaced by " #x)))
+#elif defined(_MSC_VER) && _MSC_VER >= 1500
+# define MP_DEPRECATED(x) __declspec(deprecated("replaced by " #x))
+#else
+# define MP_DEPRECATED(x)
+#endif
+
+#ifndef MP_NO_DEPRECATED_PRAGMA
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 301)
# define PRIVATE_MP_DEPRECATED_PRAGMA(s) _Pragma(#s)
# define MP_DEPRECATED_PRAGMA(s) PRIVATE_MP_DEPRECATED_PRAGMA(GCC warning s)
#elif defined(_MSC_VER) && _MSC_VER >= 1500
-# define MP_DEPRECATED(x) __declspec(deprecated("replaced by " #x))
# define MP_DEPRECATED_PRAGMA(s) __pragma(message(s))
-#else
-# define MP_DEPRECATED(s)
+#endif
+#endif
+
+#ifndef MP_DEPRECATED_PRAGMA
# define MP_DEPRECATED_PRAGMA(s)
#endif
diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h
index aa4348b..77de313 100644
--- a/libtommath/tommath_private.h
+++ b/libtommath/tommath_private.h
@@ -13,7 +13,6 @@
#endif
#include "tclTomMath.h"
#include "tommath_class.h"
-#include <limits.h>
/*
* Private symbols
diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test
index a76e8df..43b3703 100644
--- a/tests/cmdMZ.test
+++ b/tests/cmdMZ.test
@@ -344,9 +344,13 @@ test cmdMZ-5.4 {Tcl_TimeObjCmd: nothing happens with negative iteration counts}
test cmdMZ-5.5 {Tcl_TimeObjCmd: result format} -body {
time {format 1}
} -match regexp -result {^\d+ microseconds per iteration}
-test cmdMZ-5.6 {Tcl_TimeObjCmd: slower commands take longer} {
- expr {[lindex [time {_nrt_sleep 0.01}] 0] < [lindex [time {_nrt_sleep 10.0}] 0]}
-} 1
+test cmdMZ-5.6 {Tcl_TimeObjCmd: slower commands take longer} -body {
+ set m1 [lindex [time {_nrt_sleep 0.01}] 0]
+ set m2 [lindex [time {_nrt_sleep 10.0}] 0]
+ list \
+ [expr {$m1 < $m2}] \
+ $m1 $m2; # interesting only in error case.
+} -match glob -result [list 1 *]
test cmdMZ-5.7 {Tcl_TimeObjCmd: errors generate right trace} {
list [catch {time {error foo}} msg] $msg $::errorInfo
} {1 foo {foo
@@ -397,11 +401,10 @@ test cmdMZ-6.5a {Tcl_TimeRateObjCmd: result format and one iteration} {
test cmdMZ-6.5b {Tcl_TimeRateObjCmd: result format without iterations} {
regexp {^0 \ws/# 0 # 0 #/sec 0 net-ms$} [timerate {} 0 0]
} 1
-test cmdMZ-6.6 {Tcl_TimeRateObjCmd: slower commands take longer, but it remains almost the same time of measument} {
- lassign [timerate {_nrt_sleep 0} 50] ovh
- set m1 [timerate -overhead $ovh {_nrt_sleep 0.01} 50]
- set m2 [timerate -overhead $ovh {_nrt_sleep 1.00} 50]
- list \
+test cmdMZ-6.6 {Tcl_TimeRateObjCmd: slower commands take longer, but it remains almost the same time of measument} -body {
+ set m1 [timerate {_nrt_sleep 0.01} 50]
+ set m2 [timerate {_nrt_sleep 1.00} 50]
+ list [list \
[expr {[lindex $m1 0] < [lindex $m2 0]}] \
[expr {[lindex $m1 0] < 100}] \
[expr {[lindex $m2 0] > 100}] \
@@ -410,8 +413,9 @@ test cmdMZ-6.6 {Tcl_TimeRateObjCmd: slower commands take longer, but it remains
[expr {[lindex $m1 4] > 10000}] \
[expr {[lindex $m2 4] < 10000}] \
[expr {[lindex $m1 6] > 5 && [lindex $m1 6] < 100}] \
- [expr {[lindex $m2 6] > 5 && [lindex $m2 6] < 100}]
-} [lrepeat 9 1]
+ [expr {[lindex $m2 6] > 5 && [lindex $m2 6] < 100}] \
+ ] $m1 $m2; # interesting only in error case.
+} -match glob -result [list [lrepeat 9 1] *]
test cmdMZ-6.7 {Tcl_TimeRateObjCmd: errors generate right trace} {
list [catch {timerate {error foo} 1} msg] $msg $::errorInfo
} {1 foo {foo
@@ -424,35 +428,38 @@ test cmdMZ-6.7.1 {Tcl_TimeRateObjCmd: return from timerate} {
proc r1 {} {upvar x x; timerate {incr x; return "r1"; incr x} 1000 10}
list [r1] $x
} {r1 1}
-test cmdMZ-6.8 {Tcl_TimeRateObjCmd: allow (conditional) break from timerate} {
+test cmdMZ-6.8 {Tcl_TimeRateObjCmd: allow (conditional) break from timerate} -body {
set m1 [timerate {break}]
- list \
+ list [list \
[expr {[lindex $m1 0] < 1000}] \
[expr {[lindex $m1 2] == 1}] \
[expr {[lindex $m1 4] > 1000}] \
- [expr {[lindex $m1 6] < 10}]
-} {1 1 1 1}
-test cmdMZ-6.8.1 {Tcl_TimeRateObjCmd: allow (conditional) continue in timerate} {
+ [expr {[lindex $m1 6] < 10}] \
+ ] $m1; # interesting only in error case.
+} -match glob -result [list {1 1 1 1} *]
+test cmdMZ-6.8.1 {Tcl_TimeRateObjCmd: allow (conditional) continue in timerate} -body {
set m1 [timerate {continue; return -code error "unexpected"} 1000 10]
- list \
+ list [list \
[expr {[lindex $m1 0] < 1000}] \
[expr {[lindex $m1 2] == 10}] \
[expr {[lindex $m1 4] > 1000}] \
- [expr {[lindex $m1 6] < 100}]
-} {1 1 1 1}
+ [expr {[lindex $m1 6] < 100}] \
+ ] $m1; # interesting only in error case.
+} -match glob -result [list {1 1 1 1} *]
test cmdMZ-6.9 {Tcl_TimeRateObjCmd: max count of iterations} {
set m1 [timerate {} 1000 5]; # max-count wins
set m2 [timerate {_nrt_sleep 20} 1 5]; # max-time wins
list [lindex $m1 2] [lindex $m2 2]
} {5 1}
-test cmdMZ-6.10 {Tcl_TimeRateObjCmd: huge overhead cause 0us result} {
+test cmdMZ-6.10 {Tcl_TimeRateObjCmd: huge overhead cause 0us result} -body {
set m1 [timerate -overhead 1e6 {_nrt_sleep 10} 100 1]
- list \
+ list [list \
[expr {[lindex $m1 0] == 0.0}] \
[expr {[lindex $m1 2] == 1}] \
[expr {[lindex $m1 4] == 1000000}] \
- [expr {[lindex $m1 6] <= 0.001}]
-} {1 1 1 1}
+ [expr {[lindex $m1 6] <= 0.001}] \
+ ] $m1; # interesting only in error case.
+} -match glob -result [list {1 1 1 1} *]
test cmdMZ-6.11 {Tcl_TimeRateObjCmd: done/continue optimization rollback} {
set m1 {set m2 ok}
if 1 $m1
diff --git a/win/rules.vc b/win/rules.vc
index c325ffe..02b2b71 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -24,7 +24,7 @@ _RULES_VC = 1
# For modifications that are not backward-compatible, you *must* change
# the major version.
RULES_VERSION_MAJOR = 1
-RULES_VERSION_MINOR = 4
+RULES_VERSION_MINOR = 5
# The PROJECT macro must be defined by parent makefile.
!if "$(PROJECT)" == ""
@@ -991,6 +991,19 @@ VERSION = $(DOTVERSION:.=)
!endif # $(DOING_TCL) ... etc.
+# Windows RC files have 3 version components. Ensure this irrespective
+# of how many components the package has specified. Basically, ensure
+# minimum 4 components by appending 4 0's and then pick out the first 4.
+# Also take care of the fact that DOTVERSION may have "a" or "b" instead
+# of "." separating the version components.
+DOTSEPARATED=$(DOTVERSION:a=.)
+DOTSEPARATED=$(DOTSEPARATED:b=.)
+!if [echo RCCOMMAVERSION = \> versions.vc] \
+ || [for /f "tokens=1,2,3,4,5* delims=." %a in ("$(DOTSEPARATED).0.0.0.0") do echo %a,%b,%c,%d >> versions.vc]
+!error *** Could not generate RCCOMMAVERSION ***
+!endif
+!include versions.vc
+
################################################################
# 10. Construct output directory and file paths
# Figure-out how to name our intermediate and output directories.
@@ -1510,7 +1523,7 @@ GUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \
$(TCL_INCLUDES) \
/DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
- /DCOMMAVERSION=$(DOTVERSION:.=,),0 \
+ /DCOMMAVERSION=$(RCCOMMAVERSION) \
/DDOTVERSION=\"$(DOTVERSION)\" \
/DVERSION=\"$(VERSION)\" \
/DSUFX=\"$(SUFX)\" \