summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-03-28 21:24:59 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-03-28 21:24:59 (GMT)
commit3cd9927e9bf6f937e8cd932675df66c01011c8ed (patch)
treebb17601f96bde8080d5bc3d609ce1cedfb2ffc7c
parent41236ea8033ed10835d429f98a2c1128236c633e (diff)
parent0817b5a4ef4f44daedf4a1c82e5f63c0641be1c3 (diff)
downloadtcl-3cd9927e9bf6f937e8cd932675df66c01011c8ed.zip
tcl-3cd9927e9bf6f937e8cd932675df66c01011c8ed.tar.gz
tcl-3cd9927e9bf6f937e8cd932675df66c01011c8ed.tar.bz2
Merge 8.7
-rw-r--r--generic/tclTomMath.h13
-rw-r--r--generic/tclTomMathDecls.h5
-rw-r--r--libtommath/bn_mp_get_bit.c12
-rw-r--r--libtommath/bn_mp_get_int.c19
-rw-r--r--libtommath/tommath.h25
-rw-r--r--libtommath/tommath_private.h11
-rw-r--r--macosx/Tcl.xcode/project.pbxproj4
-rw-r--r--macosx/Tcl.xcodeproj/project.pbxproj4
-rw-r--r--unix/Makefile.in6
-rw-r--r--win/Makefile.in1
-rw-r--r--win/makefile.vc1
11 files changed, 14 insertions, 87 deletions
diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h
index 0541ad8..3f23fd6 100644
--- a/generic/tclTomMath.h
+++ b/generic/tclTomMath.h
@@ -25,7 +25,7 @@ extern "C" {
#endif
/* MS Visual C++ doesn't have a 128bit type for words, so fall back to 32bit MPI's (where words are 64bit) */
-#if defined(_MSC_VER) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)
+#if defined(_WIN32) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)
# define MP_32BIT
#endif
@@ -110,9 +110,6 @@ typedef unsigned long long mp_word;
/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
#ifndef DIGIT_BIT
# define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
-typedef unsigned long mp_min_u32;
-#else
-typedef mp_digit mp_min_u32;
#endif
#define MP_DIGIT_BIT DIGIT_BIT
@@ -142,14 +139,6 @@ typedef mp_digit mp_min_u32;
typedef int mp_err;
-/* you'll have to tune these... */
-#if defined(BUILD_tcl) || !defined(_WIN32)
-MODULE_SCOPE int KARATSUBA_MUL_CUTOFF,
- KARATSUBA_SQR_CUTOFF,
- TOOM_MUL_CUTOFF,
- TOOM_SQR_CUTOFF;
-#endif
-
/* define this to use lower memory usage routines (exptmods mostly) */
/* #define MP_LOW_MEM */
diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h
index 6cabe85..e61fb3a 100644
--- a/generic/tclTomMathDecls.h
+++ b/generic/tclTomMathDecls.h
@@ -46,11 +46,6 @@
/* Rename the global symbols in libtommath to avoid linkage conflicts */
-#define KARATSUBA_MUL_CUTOFF TclBNKaratsubaMulCutoff
-#define KARATSUBA_SQR_CUTOFF TclBNKaratsubaSqrCutoff
-#define TOOM_MUL_CUTOFF TclBNToomMulCutoff
-#define TOOM_SQR_CUTOFF TclBNToomSqrCutoff
-
#define bn_reverse TclBN_reverse
#define fast_s_mp_mul_digs TclBN_fast_s_mp_mul_digs
#define fast_s_mp_sqr TclBN_fast_s_mp_sqr
diff --git a/libtommath/bn_mp_get_bit.c b/libtommath/bn_mp_get_bit.c
index ab732c4..f5d2450 100644
--- a/libtommath/bn_mp_get_bit.c
+++ b/libtommath/bn_mp_get_bit.c
@@ -27,18 +27,8 @@ int mp_get_bit(const mp_int *a, int b)
limb = b / DIGIT_BIT;
- /*
- * Zero is a special value with the member "used" set to zero.
- * Needs to be tested before the check for the upper boundary
- * otherwise (limb >= a->used) would be true for a = 0
- */
-
- if (mp_iszero(a) != MP_NO) {
- return MP_NO;
- }
-
if (limb >= a->used) {
- return MP_VAL;
+ return MP_NO;
}
bit = (mp_digit)(1) << (b % DIGIT_BIT);
diff --git a/libtommath/bn_mp_get_int.c b/libtommath/bn_mp_get_int.c
index 13eddbf..d9c7a11 100644
--- a/libtommath/bn_mp_get_int.c
+++ b/libtommath/bn_mp_get_int.c
@@ -15,25 +15,8 @@
/* get the lower 32-bits of an mp_int */
unsigned long mp_get_int(const mp_int *a)
{
- int i;
- mp_min_u32 res;
-
- if (a->used == 0) {
- return 0;
- }
-
- /* get number of digits of the lsb we have to read */
- i = MIN(a->used, ((((int)sizeof(unsigned long) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
-
- /* get most significant digit of result */
- res = DIGIT(a, i);
-
- while (--i >= 0) {
- res = (res << DIGIT_BIT) | DIGIT(a, i);
- }
-
/* force result to 32-bits always so it is consistent on non 32-bit platforms */
- return res & 0xFFFFFFFFUL;
+ return mp_get_long(a) & 0xFFFFFFFFUL;
}
#endif
diff --git a/libtommath/tommath.h b/libtommath/tommath.h
index 236d3e5..b5faf8c 100644
--- a/libtommath/tommath.h
+++ b/libtommath/tommath.h
@@ -23,7 +23,7 @@ extern "C" {
#endif
/* MS Visual C++ doesn't have a 128bit type for words, so fall back to 32bit MPI's (where words are 64bit) */
-#if defined(_MSC_VER) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)
+#if defined(_WIN32) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)
# define MP_32BIT
#endif
@@ -91,17 +91,7 @@ typedef unsigned long long mp_word;
# endif
#endif
-/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
-#ifndef DIGIT_BIT
-# define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
-typedef unsigned long mp_min_u32;
-#else
-typedef mp_digit mp_min_u32;
-#endif
-
-#define MP_DIGIT_BIT DIGIT_BIT
#define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
-#define MP_DIGIT_MAX MP_MASK
/* equalities */
#define MP_LT -1 /* less than */
@@ -127,12 +117,6 @@ typedef mp_digit mp_min_u32;
typedef int mp_err;
-/* you'll have to tune these... */
-extern int KARATSUBA_MUL_CUTOFF,
- KARATSUBA_SQR_CUTOFF,
- TOOM_MUL_CUTOFF,
- TOOM_SQR_CUTOFF;
-
/* define this to use lower memory usage routines (exptmods mostly) */
/* #define MP_LOW_MEM */
@@ -145,9 +129,6 @@ extern int KARATSUBA_MUL_CUTOFF,
# endif
#endif
-/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
-#define MP_WARRAY (1u << (((sizeof(mp_word) * CHAR_BIT) - (2 * DIGIT_BIT)) + 1))
-
/* the infamous mp_int structure */
typedef struct {
int used, alloc, sign;
@@ -158,10 +139,6 @@ typedef struct {
typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
-#define USED(m) ((m)->used)
-#define DIGIT(m, k) ((m)->dp[(k)])
-#define SIGN(m) ((m)->sign)
-
/* error code to char* string */
const char *mp_error_to_string(int code);
diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h
index 8fc3442..2096f77 100644
--- a/libtommath/tommath_private.h
+++ b/libtommath/tommath_private.h
@@ -42,15 +42,22 @@ extern "C" {
# define XMALLOC malloc
# define XFREE free
# define XREALLOC realloc
-# define XCALLOC calloc
#elif 0
/* prototypes for our heap functions */
extern void *XMALLOC(size_t n);
extern void *XREALLOC(void *p, size_t n);
-extern void *XCALLOC(size_t n, size_t s);
extern void XFREE(void *p);
#endif
+/* you'll have to tune these... */
+#define KARATSUBA_MUL_CUTOFF 80 /* Min. number of digits before Karatsuba multiplication is used. */
+#define KARATSUBA_SQR_CUTOFF 120 /* Min. number of digits before Karatsuba squaring is used. */
+#define TOOM_MUL_CUTOFF 350 /* no optimal values of these are known yet so set em high */
+#define TOOM_SQR_CUTOFF 400
+
+/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
+#define MP_WARRAY (1u << (((sizeof(mp_word) * CHAR_BIT) - (2 * DIGIT_BIT)) + 1))
+
/* lowlevel functions, do not call! */
int s_mp_add(const mp_int *a, const mp_int *b, mp_int *c);
int s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c);
diff --git a/macosx/Tcl.xcode/project.pbxproj b/macosx/Tcl.xcode/project.pbxproj
index d06a1a8..dac7f32 100644
--- a/macosx/Tcl.xcode/project.pbxproj
+++ b/macosx/Tcl.xcode/project.pbxproj
@@ -145,7 +145,6 @@
F96D495108F272C3004A47F5 /* bn_s_mp_mul_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D308F272B3004A47F5 /* bn_s_mp_mul_digs.c */; };
F96D495308F272C3004A47F5 /* bn_s_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D508F272B3004A47F5 /* bn_s_mp_sqr.c */; };
F96D495408F272C3004A47F5 /* bn_s_mp_sub.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D608F272B3004A47F5 /* bn_s_mp_sub.c */; };
- F96D495508F272C3004A47F5 /* bncore.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D708F272B3004A47F5 /* bncore.c */; };
F96D49A908F272C4004A47F5 /* tclMacOSXBundle.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433908F272B5004A47F5 /* tclMacOSXBundle.c */; };
F96D49AD08F272C4004A47F5 /* tclMacOSXFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433D08F272B5004A47F5 /* tclMacOSXFCmd.c */; };
F96D49AE08F272C4004A47F5 /* tclMacOSXNotify.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433E08F272B5004A47F5 /* tclMacOSXNotify.c */; };
@@ -620,7 +619,6 @@
F96D42D308F272B3004A47F5 /* bn_s_mp_mul_digs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_mul_digs.c; sourceTree = "<group>"; };
F96D42D508F272B3004A47F5 /* bn_s_mp_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_sqr.c; sourceTree = "<group>"; };
F96D42D608F272B3004A47F5 /* bn_s_mp_sub.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_sub.c; sourceTree = "<group>"; };
- F96D42D708F272B3004A47F5 /* bncore.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bncore.c; sourceTree = "<group>"; };
F96D432908F272B4004A47F5 /* tommath_class.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tommath_class.h; sourceTree = "<group>"; };
F96D432A08F272B4004A47F5 /* tommath_superclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tommath_superclass.h; sourceTree = "<group>"; };
F96D432B08F272B4004A47F5 /* license.terms */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = license.terms; sourceTree = "<group>"; };
@@ -1472,7 +1470,6 @@
F96D42D308F272B3004A47F5 /* bn_s_mp_mul_digs.c */,
F96D42D508F272B3004A47F5 /* bn_s_mp_sqr.c */,
F96D42D608F272B3004A47F5 /* bn_s_mp_sub.c */,
- F96D42D708F272B3004A47F5 /* bncore.c */,
F96D432908F272B4004A47F5 /* tommath_class.h */,
F96D432A08F272B4004A47F5 /* tommath_superclass.h */,
);
@@ -2104,7 +2101,6 @@
F96D495108F272C3004A47F5 /* bn_s_mp_mul_digs.c in Sources */,
F96D495308F272C3004A47F5 /* bn_s_mp_sqr.c in Sources */,
F96D495408F272C3004A47F5 /* bn_s_mp_sub.c in Sources */,
- F96D495508F272C3004A47F5 /* bncore.c in Sources */,
F96D49A908F272C4004A47F5 /* tclMacOSXBundle.c in Sources */,
F96D49AD08F272C4004A47F5 /* tclMacOSXFCmd.c in Sources */,
F96D49AE08F272C4004A47F5 /* tclMacOSXNotify.c in Sources */,
diff --git a/macosx/Tcl.xcodeproj/project.pbxproj b/macosx/Tcl.xcodeproj/project.pbxproj
index 928d231..fb120b0 100644
--- a/macosx/Tcl.xcodeproj/project.pbxproj
+++ b/macosx/Tcl.xcodeproj/project.pbxproj
@@ -145,7 +145,6 @@
F96D495108F272C3004A47F5 /* bn_s_mp_mul_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D308F272B3004A47F5 /* bn_s_mp_mul_digs.c */; };
F96D495308F272C3004A47F5 /* bn_s_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D508F272B3004A47F5 /* bn_s_mp_sqr.c */; };
F96D495408F272C3004A47F5 /* bn_s_mp_sub.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D608F272B3004A47F5 /* bn_s_mp_sub.c */; };
- F96D495508F272C3004A47F5 /* bncore.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D708F272B3004A47F5 /* bncore.c */; };
F96D49A908F272C4004A47F5 /* tclMacOSXBundle.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433908F272B5004A47F5 /* tclMacOSXBundle.c */; };
F96D49AD08F272C4004A47F5 /* tclMacOSXFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433D08F272B5004A47F5 /* tclMacOSXFCmd.c */; };
F96D49AE08F272C4004A47F5 /* tclMacOSXNotify.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433E08F272B5004A47F5 /* tclMacOSXNotify.c */; };
@@ -621,7 +620,6 @@
F96D42D308F272B3004A47F5 /* bn_s_mp_mul_digs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_mul_digs.c; sourceTree = "<group>"; };
F96D42D508F272B3004A47F5 /* bn_s_mp_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_sqr.c; sourceTree = "<group>"; };
F96D42D608F272B3004A47F5 /* bn_s_mp_sub.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_sub.c; sourceTree = "<group>"; };
- F96D42D708F272B3004A47F5 /* bncore.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bncore.c; sourceTree = "<group>"; };
F96D432908F272B4004A47F5 /* tommath_class.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tommath_class.h; sourceTree = "<group>"; };
F96D432A08F272B4004A47F5 /* tommath_superclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tommath_superclass.h; sourceTree = "<group>"; };
F96D432B08F272B4004A47F5 /* license.terms */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = license.terms; sourceTree = "<group>"; };
@@ -1473,7 +1471,6 @@
F96D42D308F272B3004A47F5 /* bn_s_mp_mul_digs.c */,
F96D42D508F272B3004A47F5 /* bn_s_mp_sqr.c */,
F96D42D608F272B3004A47F5 /* bn_s_mp_sub.c */,
- F96D42D708F272B3004A47F5 /* bncore.c */,
F96D432908F272B4004A47F5 /* tommath_class.h */,
F96D432A08F272B4004A47F5 /* tommath_superclass.h */,
);
@@ -2105,7 +2102,6 @@
F96D495108F272C3004A47F5 /* bn_s_mp_mul_digs.c in Sources */,
F96D495308F272C3004A47F5 /* bn_s_mp_sqr.c in Sources */,
F96D495408F272C3004A47F5 /* bn_s_mp_sub.c in Sources */,
- F96D495508F272C3004A47F5 /* bncore.c in Sources */,
F96D49A908F272C4004A47F5 /* tclMacOSXBundle.c in Sources */,
F96D49AD08F272C4004A47F5 /* tclMacOSXFCmd.c in Sources */,
F96D49AE08F272C4004A47F5 /* tclMacOSXNotify.c in Sources */,
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 21c41de..7dfca29 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -319,7 +319,7 @@ GENERIC_OBJS = regcomp.o regexec.o regfree.o regerror.o tclAlloc.o \
OO_OBJS = tclOO.o tclOOBasic.o tclOOCall.o tclOODefineCmds.o tclOOInfo.o \
tclOOMethod.o tclOOStubInit.o
-TOMMATH_OBJS = bncore.o bn_reverse.o bn_fast_s_mp_mul_digs.o \
+TOMMATH_OBJS = bn_reverse.o bn_fast_s_mp_mul_digs.o \
bn_fast_s_mp_sqr.o bn_mp_add.o bn_mp_and.o \
bn_mp_add_d.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o \
bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \
@@ -490,7 +490,6 @@ STUB_SRCS = \
$(GENERIC_DIR)/tclOOStubLib.c
TOMMATH_SRCS = \
- $(TOMMATH_DIR)/bncore.c \
$(TOMMATH_DIR)/bn_reverse.c \
$(TOMMATH_DIR)/bn_fast_s_mp_mul_digs.c \
$(TOMMATH_DIR)/bn_fast_s_mp_sqr.c \
@@ -1460,9 +1459,6 @@ tclThreadTest.o: $(GENERIC_DIR)/tclThreadTest.c
tclTomMathInterface.o: $(GENERIC_DIR)/tclTomMathInterface.c $(MATHHDRS)
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclTomMathInterface.c
-bncore.o: $(TOMMATH_DIR)/bncore.c $(MATHHDRS)
- $(CC) -c $(CC_SWITCHES) $(TOMMATH_DIR)/bncore.c
-
bn_reverse.o: $(TOMMATH_DIR)/bn_reverse.c $(MATHHDRS)
$(CC) -c $(CC_SWITCHES) $(TOMMATH_DIR)/bn_reverse.c
diff --git a/win/Makefile.in b/win/Makefile.in
index 3a25b44..888b19e 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -360,7 +360,6 @@ GENERIC_OBJS = \
tclZlib.$(OBJEXT)
TOMMATH_OBJS = \
- bncore.${OBJEXT} \
bn_reverse.${OBJEXT} \
bn_fast_s_mp_mul_digs.${OBJEXT} \
bn_fast_s_mp_sqr.${OBJEXT} \
diff --git a/win/makefile.vc b/win/makefile.vc
index 8535227..c61d846 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -252,7 +252,6 @@ ZLIBOBJS = \
$(TMP_DIR)\zutil.obj
TOMMATHOBJS = \
- $(TMP_DIR)\bncore.obj \
$(TMP_DIR)\bn_reverse.obj \
$(TMP_DIR)\bn_fast_s_mp_mul_digs.obj \
$(TMP_DIR)\bn_fast_s_mp_sqr.obj \