summaryrefslogtreecommitdiffstats
path: root/libtommath
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-04-08 19:06:57 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-04-08 19:06:57 (GMT)
commitbb3ef949858f5fa0190e37b1b7642dc29369e152 (patch)
treec5a4adb58d37c94899c477464aba5e5ad1ba6c6f /libtommath
parent4865914200b6c412220d621f3cce4f355ad38554 (diff)
parent0305f67f8865a7b2e60d80e0dd4bfb2b4d30e024 (diff)
downloadtcl-bb3ef949858f5fa0190e37b1b7642dc29369e152.zip
tcl-bb3ef949858f5fa0190e37b1b7642dc29369e152.tar.gz
tcl-bb3ef949858f5fa0190e37b1b7642dc29369e152.tar.bz2
Merge 8.7. Intended operation completed for mingw-w64 (but not yet for other compilers/platforms)
Diffstat (limited to 'libtommath')
-rw-r--r--libtommath/bn_mp_get_long_long.c4
-rw-r--r--libtommath/bn_mp_prime_strong_lucas_selfridge.c2
-rw-r--r--libtommath/bn_mp_set_double.c4
-rw-r--r--libtommath/makefile.mingw6
-rw-r--r--libtommath/tommath.h29
-rwxr-xr-xlibtommath/win32/libtommath.dllbin0 -> 66560 bytes
-rw-r--r--libtommath/win32/tommath.libbin0 -> 88136 bytes
-rwxr-xr-xlibtommath/win64/libtommath.dllbin0 -> 75264 bytes
-rw-r--r--libtommath/win64/libtommath.dll.abin0 -> 86060 bytes
9 files changed, 29 insertions, 16 deletions
diff --git a/libtommath/bn_mp_get_long_long.c b/libtommath/bn_mp_get_long_long.c
index 49a0208..333c6d1 100644
--- a/libtommath/bn_mp_get_long_long.c
+++ b/libtommath/bn_mp_get_long_long.c
@@ -26,11 +26,11 @@ Tcl_WideUInt mp_get_long_long(const mp_int *a)
i = MIN(a->used, (((CHAR_BIT * (int)sizeof(Tcl_WideUInt)) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
/* get most significant digit of result */
- res = (unsigned long long)a->dp[i];
+ res = (Tcl_WideUInt)a->dp[i];
#if DIGIT_BIT < 64
while (--i >= 0) {
- res = (res << DIGIT_BIT) | (unsigned long long)a->dp[i];
+ res = (res << DIGIT_BIT) | (Tcl_WideUInt)a->dp[i];
}
#endif
return res;
diff --git a/libtommath/bn_mp_prime_strong_lucas_selfridge.c b/libtommath/bn_mp_prime_strong_lucas_selfridge.c
index 5a94f8e..d20b4d7 100644
--- a/libtommath/bn_mp_prime_strong_lucas_selfridge.c
+++ b/libtommath/bn_mp_prime_strong_lucas_selfridge.c
@@ -80,7 +80,7 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
/* CZ TODO: choose better variable names! */
mp_int Dz, gcd, Np1, Uz, Vz, U2mz, V2mz, Qmz, Q2mz, Qkdz, T1z, T2z, T3z, T4z, Q2kdz;
/* CZ TODO: Some of them need the full 32 bit, hence the (temporary) exclusion of MP_8BIT */
- int32_t D, Ds, J, sign, P, Q, r, s, u, Nbits;
+ int D, Ds, J, sign, P, Q, r, s, u, Nbits;
int e;
int isset, oddness;
diff --git a/libtommath/bn_mp_set_double.c b/libtommath/bn_mp_set_double.c
index c96a3b3..51badbe 100644
--- a/libtommath/bn_mp_set_double.c
+++ b/libtommath/bn_mp_set_double.c
@@ -15,11 +15,11 @@
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559)
int mp_set_double(mp_int *a, double b)
{
- uint64_t frac;
+ Tcl_WideUInt frac;
int exp, res;
union {
double dbl;
- uint64_t bits;
+ Tcl_WideUInt bits;
} cast;
cast.dbl = b;
diff --git a/libtommath/makefile.mingw b/libtommath/makefile.mingw
index ec0de2b..222b1b6 100644
--- a/libtommath/makefile.mingw
+++ b/libtommath/makefile.mingw
@@ -11,7 +11,7 @@
#The following can be overridden from command line e.g. make -f makefile.mingw CC=gcc ARFLAGS=rcs
PREFIX = c:\mingw
-CC = gcc
+CC = i686-w64-mingw32-gcc
AR = ar
ARFLAGS = r
RANLIB = ranlib
@@ -21,7 +21,7 @@ LDFLAGS =
#Compilation flags
LTM_CFLAGS = -I. $(CFLAGS)
-LTM_LDFLAGS = $(LDFLAGS)
+LTM_LDFLAGS = $(LDFLAGS) -static-libgcc
#Libraries to be created
LIBMAIN_S =libtommath.a
@@ -54,7 +54,7 @@ bn_mp_sub_d.o bn_mp_submod.o bn_mp_tc_and.o bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_m
bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o \
bn_mp_toom_mul.o bn_mp_toom_sqr.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o \
bn_mp_zero.o bn_prime_tab.o bn_reverse.o bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o \
-bn_s_mp_mul_high_digs.o bn_s_mp_sqr.o bn_s_mp_sub.o bncore.o
+bn_s_mp_mul_high_digs.o bn_s_mp_sqr.o bn_s_mp_sub.o
HEADERS_PUB=tommath.h tommath_class.h tommath_superclass.h
diff --git a/libtommath/tommath.h b/libtommath/tommath.h
index 66e2d8c..5c0a186 100644
--- a/libtommath/tommath.h
+++ b/libtommath/tommath.h
@@ -12,10 +12,13 @@
#ifndef BN_H_
#define BN_H_
-#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
+#ifndef LTM_NO_FILE
+# include <stdio.h>
+#endif
+
#include "tommath_class.h"
#ifdef __cplusplus
@@ -23,7 +26,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(_WIN32) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)
+#if (defined(_MSC_VER) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)) && !defined(MP_64BIT)
# define MP_32BIT
#endif
@@ -34,7 +37,7 @@ extern "C" {
defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \
defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \
defined(__LP64__) || defined(_LP64) || defined(__64BIT__)
-# if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
+# if !(defined(MP_64BIT) || defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
# if defined(__GNUC__)
/* we support 128bit integers only via: __attribute__((mode(TI))) */
# define MP_64BIT
@@ -45,8 +48,6 @@ extern "C" {
# endif
#endif
-typedef unsigned long long Tcl_WideUInt;
-
/* some default configurations.
*
* A "mp_digit" must be able to hold DIGIT_BIT + 1 bits
@@ -67,8 +68,11 @@ typedef unsigned short mp_digit;
# error You must not define DIGIT_BIT when using MP_16BIT
# endif
#elif defined(MP_64BIT)
-/* for GCC only on supported platforms */
+# ifdef _WIN32
+typedef unsigned __int64 mp_digit;
+# else
typedef unsigned long long mp_digit;
+# endif
# define DIGIT_BIT 60
#else
/* this is the default case, 28-bit digits */
@@ -86,6 +90,11 @@ typedef unsigned int mp_digit;
# 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 */
+#endif
+
#define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
/* equalities */
@@ -125,10 +134,14 @@ typedef int mp_err;
#endif
/* the infamous mp_int structure */
-typedef struct {
+#ifndef MP_INT_DECLARED
+#define MP_INT_DECLARED
+typedef struct mp_int mp_int;
+#endif
+struct mp_int {
int used, alloc, sign;
mp_digit *dp;
-} mp_int;
+};
/* callback for mp_prime_random, should fill dst with random bytes and return how many read [upto len] */
typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
diff --git a/libtommath/win32/libtommath.dll b/libtommath/win32/libtommath.dll
new file mode 100755
index 0000000..4497517
--- /dev/null
+++ b/libtommath/win32/libtommath.dll
Binary files differ
diff --git a/libtommath/win32/tommath.lib b/libtommath/win32/tommath.lib
new file mode 100644
index 0000000..8628471
--- /dev/null
+++ b/libtommath/win32/tommath.lib
Binary files differ
diff --git a/libtommath/win64/libtommath.dll b/libtommath/win64/libtommath.dll
new file mode 100755
index 0000000..77d685b
--- /dev/null
+++ b/libtommath/win64/libtommath.dll
Binary files differ
diff --git a/libtommath/win64/libtommath.dll.a b/libtommath/win64/libtommath.dll.a
new file mode 100644
index 0000000..54a76d7
--- /dev/null
+++ b/libtommath/win64/libtommath.dll.a
Binary files differ