summaryrefslogtreecommitdiffstats
path: root/libtommath
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-03-28 21:44:39 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-03-28 21:44:39 (GMT)
commitb3664a2eaad315a7b01931c974f24503ab1290cd (patch)
tree29623dd7a42f6b6d9e978ecaa4a4006d123f8f5f /libtommath
parent0817b5a4ef4f44daedf4a1c82e5f63c0641be1c3 (diff)
downloadtcl-b3664a2eaad315a7b01931c974f24503ab1290cd.zip
tcl-b3664a2eaad315a7b01931c974f24503ab1290cd.tar.gz
tcl-b3664a2eaad315a7b01931c974f24503ab1290cd.tar.bz2
Experiment: On platforms which support it (gcc), compiled libtommath with DIGIT_BIT=60
Diffstat (limited to 'libtommath')
-rw-r--r--libtommath/tommath.h5
-rw-r--r--libtommath/tommath_private.h9
2 files changed, 9 insertions, 5 deletions
diff --git a/libtommath/tommath.h b/libtommath/tommath.h
index b5faf8c..66e2d8c 100644
--- a/libtommath/tommath.h
+++ b/libtommath/tommath.h
@@ -50,21 +50,18 @@ typedef unsigned long long Tcl_WideUInt;
/* some default configurations.
*
* A "mp_digit" must be able to hold DIGIT_BIT + 1 bits
- * A "mp_word" must be able to hold 2*DIGIT_BIT + 1 bits
*
* At the very least a mp_digit must be able to hold 7 bits
* [any size beyond that is ok provided it doesn't overflow the data type]
*/
#ifdef MP_8BIT
typedef unsigned char mp_digit;
-typedef unsigned short mp_word;
# define MP_SIZEOF_MP_DIGIT 1
# ifdef DIGIT_BIT
# error You must not define DIGIT_BIT when using MP_8BIT
# endif
#elif defined(MP_16BIT)
typedef unsigned short mp_digit;
-typedef unsigned int mp_word;
# define MP_SIZEOF_MP_DIGIT 2
# ifdef DIGIT_BIT
# error You must not define DIGIT_BIT when using MP_16BIT
@@ -72,14 +69,12 @@ typedef unsigned int mp_word;
#elif defined(MP_64BIT)
/* for GCC only on supported platforms */
typedef unsigned long long mp_digit;
-typedef unsigned long mp_word __attribute__((mode(TI)));
# define DIGIT_BIT 60
#else
/* this is the default case, 28-bit digits */
/* this is to make porting into LibTomCrypt easier :-) */
typedef unsigned int mp_digit;
-typedef unsigned long long mp_word;
# ifdef MP_31BIT
/* this is an extension that uses 31-bit digits */
diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h
index 2096f77..e1ad45d 100644
--- a/libtommath/tommath_private.h
+++ b/libtommath/tommath_private.h
@@ -49,6 +49,15 @@ extern void *XREALLOC(void *p, size_t n);
extern void XFREE(void *p);
#endif
+#if defined(MP_64BIT)
+/* for GCC only on supported platforms */
+typedef unsigned long mp_word __attribute__((mode(TI)));
+#elif _WIN32
+typedef __int64 mp_word;
+#else
+typedef unsigned long long mp_word;
+#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. */