summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-08-30 12:37:50 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-08-30 12:37:50 (GMT)
commitb49738ff138e13a39a594458fefc273272acffee (patch)
treef100736555d31d972ada62b12b8a189ba9c2253e
parent1a00939829b0f8551c44af805ffd701f65c2a58b (diff)
downloadtcl-b49738ff138e13a39a594458fefc273272acffee.zip
tcl-b49738ff138e13a39a594458fefc273272acffee.tar.gz
tcl-b49738ff138e13a39a594458fefc273272acffee.tar.bz2
Tweak libtommath building, such that it doesn't depend on uint64_t any more. (handle mp_word in the same way as mp_digit)
-rw-r--r--generic/tcl.h2
-rw-r--r--generic/tclTomMath.h15
-rwxr-xr-xtools/fix_tommath_h.tcl6
3 files changed, 23 insertions, 0 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 6fa26f9..da9b292 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -2263,6 +2263,8 @@ typedef struct mp_int mp_int;
#define MP_INT_DECLARED
typedef unsigned int mp_digit;
#define MP_DIGIT_DECLARED
+typedef unsigned TCL_WIDE_INT_TYPE mp_word;
+#define MP_WORD_DECLARED
/*
*----------------------------------------------------------------------------
diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h
index 87fe756..39132ed 100644
--- a/generic/tclTomMath.h
+++ b/generic/tclTomMath.h
@@ -46,7 +46,10 @@ extern "C" {
typedef uint8_t mp_digit;
#define MP_DIGIT_DECLARED
#endif
+#ifndef MP_WORD_DECLARED
typedef uint16_t mp_word;
+#define MP_WORD_DECLARED
+#endif
#define MP_SIZEOF_MP_DIGIT 1
#ifdef DIGIT_BIT
#error You must not define DIGIT_BIT when using MP_8BIT
@@ -56,7 +59,10 @@ extern "C" {
typedef uint16_t mp_digit;
#define MP_DIGIT_DECLARED
#endif
+#ifndef MP_WORD_DECLARED
typedef uint32_t mp_word;
+#define MP_WORD_DECLARED
+#endif
#define MP_SIZEOF_MP_DIGIT 2
#ifdef DIGIT_BIT
#error You must not define DIGIT_BIT when using MP_16BIT
@@ -68,13 +74,19 @@ extern "C" {
#define MP_DIGIT_DECLARED
#endif
#if defined(_WIN32)
+#ifndef MP_WORD_DECLARED
typedef unsigned __int128 mp_word;
+#define MP_WORD_DECLARED
+#endif
#elif defined(__GNUC__)
typedef unsigned long mp_word __attribute__ ((mode(TI)));
#else
/* it seems you have a problem
* but we assume you can somewhere define your own uint128_t */
+#ifndef MP_WORD_DECLARED
typedef uint128_t mp_word;
+#define MP_WORD_DECLARED
+#endif
#endif
#define DIGIT_BIT 60
@@ -86,7 +98,10 @@ extern "C" {
typedef uint32_t mp_digit;
#define MP_DIGIT_DECLARED
#endif
+#ifndef MP_WORD_DECLARED
typedef uint64_t mp_word;
+#define MP_WORD_DECLARED
+#endif
#ifdef MP_31BIT
/* this is an extension that uses 31-bit digits */
diff --git a/tools/fix_tommath_h.tcl b/tools/fix_tommath_h.tcl
index 61fa4fd..cee29fa 100755
--- a/tools/fix_tommath_h.tcl
+++ b/tools/fix_tommath_h.tcl
@@ -45,6 +45,12 @@ foreach line [split $data \n] {
puts "\#define MP_DIGIT_DECLARED"
puts "\#endif"
}
+ {typedef.*mp_word;} {
+ puts "\#ifndef MP_WORD_DECLARED"
+ puts $line
+ puts "\#define MP_WORD_DECLARED"
+ puts "\#endif"
+ }
{typedef struct} {
puts "\#ifndef MP_INT_DECLARED"
puts "\#define MP_INT_DECLARED"