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 /libtommath | |
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++
Diffstat (limited to 'libtommath')
-rw-r--r-- | libtommath/bn_mp_mul.c | 6 | ||||
-rw-r--r-- | libtommath/tommath_private.h | 12 |
2 files changed, 16 insertions, 2 deletions
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; \ |