diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-12-13 22:12:32 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-12-13 22:12:32 (GMT) |
commit | 89e6e17872e245d31d1d294fa72930cc3da79b81 (patch) | |
tree | 34e403aa3d62a1000f4c99e69dcd662a5313ea68 | |
parent | e43882908292c514bc01b2ca0c63ce6d0611c692 (diff) | |
parent | de326e5c5ed447c99c7be6991f76cc9d5e774698 (diff) | |
download | tcl-89e6e17872e245d31d1d294fa72930cc3da79b81.zip tcl-89e6e17872e245d31d1d294fa72930cc3da79b81.tar.gz tcl-89e6e17872e245d31d1d294fa72930cc3da79b81.tar.bz2 |
Merge 8.7 and (hopefully) fix Travis build with C++
-rw-r--r-- | generic/tclTomMathDecls.h | 10 | ||||
-rw-r--r-- | libtommath/bn_mp_mul.c | 6 | ||||
-rw-r--r-- | libtommath/tommath_private.h | 12 | ||||
-rw-r--r-- | win/tclAppInit.c | 4 |
4 files changed, 28 insertions, 4 deletions
diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index f199a2a..736a640 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -56,6 +56,9 @@ # define MODULE_SCOPE extern #endif +#ifdef __cplusplus +extern "C" { +#endif MODULE_SCOPE mp_err TclBN_s_mp_add_d(const mp_int *a, mp_digit b, mp_int *c); MODULE_SCOPE mp_ord TclBN_s_mp_cmp_d(const mp_int *a, mp_digit b); MODULE_SCOPE mp_err TclBN_s_mp_div_d(const mp_int *a, mp_digit b, mp_int *c, mp_digit *d); @@ -66,7 +69,9 @@ MODULE_SCOPE mp_err TclBN_s_mp_mul_d(const mp_int *a, mp_digit b, mp_int *c); MODULE_SCOPE void TclBN_s_mp_reverse(unsigned char *s, size_t len); MODULE_SCOPE void TclBN_s_mp_set(mp_int *a, mp_digit b); MODULE_SCOPE mp_err TclBN_s_mp_sub_d(const mp_int *a, mp_digit b, mp_int *c); - +#ifdef __cplusplus +} +#endif /* Rename the global symbols in libtommath to avoid linkage conflicts */ @@ -740,6 +745,9 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; #undef mp_isodd #define mp_iseven(a) (!mp_isodd(a)) #define mp_isodd(a) (((a)->used != 0 && (((a)->dp[0] & 1) != 0)) ? MP_YES : MP_NO) +#undef mp_sqr +#define mp_sqr(a,b) mp_mul(a,a,b) + #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT diff --git a/libtommath/bn_mp_mul.c b/libtommath/bn_mp_mul.c index 91707cd..b00334d 100644 --- a/libtommath/bn_mp_mul.c +++ b/libtommath/bn_mp_mul.c @@ -12,12 +12,14 @@ 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 (MP_HAS(S_MP_BALANCE_MUL) && + if (a == b) { + return mp_sqr(a,c); + } else 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 * stars... so YMMV. - * Using it to cut the input into slices small enough for s_mp_mul_digs_fast + * Using it to cut the input into slices small enough for fast_s_mp_mul_digs * was actually slower on the author's machine, but YMMV. */ (min_len >= MP_KARATSUBA_MUL_CUTOFF) && diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h index 7cef443..d076934 100644 --- a/libtommath/tommath_private.h +++ b/libtommath/tommath_private.h @@ -194,6 +194,9 @@ MP_STATIC_ASSERT(prec_geq_min_prec, MP_PREC >= MP_MIN_PREC) /* random number source */ extern MP_PRIVATE mp_err(*s_mp_rand_source)(void *out, size_t size); +#ifdef __cplusplus +extern "C" { +#endif /* lowlevel functions, do not call! */ MP_PRIVATE mp_bool s_mp_get_bit(const mp_int *a, unsigned int b); MP_PRIVATE mp_err s_mp_add(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; @@ -249,6 +252,15 @@ MP_DEPRECATED(s_mp_toom_mul) mp_err mp_toom_mul(const mp_int *a, const mp_int *b MP_DEPRECATED(s_mp_toom_sqr) mp_err mp_toom_sqr(const mp_int *a, mp_int *b); MP_DEPRECATED(s_mp_reverse) void bn_reverse(unsigned char *s, int len); +#ifdef __cplusplus +} +#endif + +#ifndef TCL_WITH_EXTERNAL_TOMMATH +#undef mp_sqr +#define mp_sqr TclBN_mp_sqr +#endif + #define MP_GET_ENDIANNESS(x) \ do{\ int16_t n = 0x1; \ diff --git a/win/tclAppInit.c b/win/tclAppInit.c index 17625d3..0a47000 100644 --- a/win/tclAppInit.c +++ b/win/tclAppInit.c @@ -90,14 +90,16 @@ main( char *dummy[]) /* Not used. */ { TCHAR **argv; + TCHAR *p; + (void)dummy; #else int _tmain( int argc, /* Number of command-line arguments. */ TCHAR *argv[]) /* Values of command-line arguments. */ { -#endif TCHAR *p; +#endif /* * Set up the default locale to be standard "C" locale so parsing is |