summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-04-06 20:41:21 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-04-06 20:41:21 (GMT)
commit4865914200b6c412220d621f3cce4f355ad38554 (patch)
tree76d6405fee06a522e3177592647fc657870fd21e
parent889e874282cb68715c4fa329df827d6fe0ebc84d (diff)
parent00c94ffc5dfad15395a32fc93d6d171aa4b47759 (diff)
downloadtcl-4865914200b6c412220d621f3cce4f355ad38554.zip
tcl-4865914200b6c412220d621f3cce4f355ad38554.tar.gz
tcl-4865914200b6c412220d621f3cce4f355ad38554.tar.bz2
Merge 8.7. Add checks for libtommath library to configure script (experimental)
-rw-r--r--generic/tclTomMath.h25
-rw-r--r--generic/tclTomMathDecls.h17
-rw-r--r--libtommath/bn_mp_clear.c2
-rw-r--r--libtommath/bn_mp_fwrite.c8
-rw-r--r--libtommath/bn_mp_get_double.c6
-rw-r--r--libtommath/bn_mp_get_long.c10
-rw-r--r--libtommath/bn_mp_get_long_long.c8
-rw-r--r--libtommath/bn_mp_grow.c4
-rw-r--r--libtommath/bn_mp_init.c2
-rw-r--r--libtommath/bn_mp_init_size.c2
-rw-r--r--libtommath/bn_mp_is_square.c5
-rw-r--r--libtommath/bn_mp_prime_random_ex.c10
-rw-r--r--libtommath/bn_mp_read_radix.c4
-rw-r--r--libtommath/bn_mp_set_double.c4
-rw-r--r--libtommath/bn_mp_shrink.c4
-rw-r--r--libtommath/tommath_private.h65
-rw-r--r--tests/socket.test6
-rwxr-xr-xunix/configure112
-rw-r--r--unix/configure.ac17
19 files changed, 223 insertions, 88 deletions
diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h
index 180de77..bf541d8 100644
--- a/generic/tclTomMath.h
+++ b/generic/tclTomMath.h
@@ -105,6 +105,7 @@ typedef unsigned int mp_digit;
#define MP_MEM -2 /* out of mem */
#define MP_VAL -3 /* invalid input */
#define MP_RANGE MP_VAL
+#define MP_ITER -4 /* Max. iterations reached */
#define MP_YES 1 /* yes response */
#define MP_NO 0 /* no response */
@@ -320,15 +321,20 @@ int mp_cnt_lsb(const mp_int *a);
/* I Love Earth! */
-/* makes a pseudo-random int of a given size */
+/* makes a pseudo-random mp_int of a given size */
/*
int mp_rand(mp_int *a, int digits);
*/
+/* makes a pseudo-random small int of a given size */
+/*
+int mp_rand_digit(mp_digit *r);
+*/
#ifdef MP_PRNG_ENABLE_LTM_RNG
-/* as last resort we will fall back to libtomcrypt's rng_get_bytes()
- * in case you don't use libtomcrypt or use it w/o rng_get_bytes()
- * you have to implement it somewhere else, as it's required */
+/* A last resort to provide random data on systems without any of the other
+ * implemented ways to gather entropy.
+ * It is compatible with `rng_get_bytes()` from libtomcrypt so you could
+ * provide that one and then set `ltm_rng = rng_get_bytes;` */
extern unsigned long (*ltm_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
extern void (*ltm_rng_callback)(void);
#endif
@@ -665,10 +671,17 @@ int mp_prime_miller_rabin(const mp_int *a, const mp_int *b, int *result);
int mp_prime_rabin_miller_trials(int size);
*/
-/* performs t rounds of Miller-Rabin on "a" using the first
- * t prime bases. Also performs an initial sieve of trial
+/* performs t random rounds of Miller-Rabin on "a" additional to
+ * bases 2 and 3. Also performs an initial sieve of trial
* division. Determines if "a" is prime with probability
* of error no more than (1/4)**t.
+ * Both a strong Lucas-Selfridge to complete the BPSW test
+ * and a separate Frobenius test are available at compile time.
+ * With t<0 a deterministic test is run for primes up to
+ * 318665857834031151167461. With t<13 (abs(t)-13) additional
+ * tests with sequential small primes are run starting at 43.
+ * Is Fips 186.4 compliant if called with t as computed by
+ * mp_prime_rabin_miller_trials();
*
* Sets result to 1 if probably prime, 0 otherwise
*/
diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h
index 52ab26f..165e3b7 100644
--- a/generic/tclTomMathDecls.h
+++ b/generic/tclTomMathDecls.h
@@ -30,12 +30,17 @@
/* Define custom memory allocation for libtommath */
-/* MODULE_SCOPE void* XMALLOC( size_t ); */
-#define XMALLOC(s) ((void*)ckalloc((size_t)(s)))
-/* MODULE_SCOPE void* XREALLOC( void*, size_t ); */
-#define XREALLOC(x,s) ((void*)ckrealloc((char*)(x),(size_t)(s)))
-/* MODULE_SCOPE void XFREE( void* ); */
-#define XFREE(x) (ckfree((char*)(x)))
+/* MODULE_SCOPE void* TclBNAlloc( size_t ); */
+#define TclBNAlloc(s) ((void*)ckalloc((size_t)(s)))
+/* MODULE_SCOPE void* TclBNRealloc( void*, size_t ); */
+#define TclBNRealloc(x,s) ((void*)ckrealloc((char*)(x),(size_t)(s)))
+/* MODULE_SCOPE void TclBNFree( void* ); */
+#define TclBNFree(x) (ckfree((char*)(x)))
+
+#define XMALLOC(size) TclBNAlloc(size)
+#define XFREE(mem, size) TclBNFree(mem)
+#define XREALLOC(mem, oldsize, newsize) TclBNRealloc(mem, newsize)
+
/* Rename the global symbols in libtommath to avoid linkage conflicts */
diff --git a/libtommath/bn_mp_clear.c b/libtommath/bn_mp_clear.c
index 1f360b2..b8e724c 100644
--- a/libtommath/bn_mp_clear.c
+++ b/libtommath/bn_mp_clear.c
@@ -25,7 +25,7 @@ void mp_clear(mp_int *a)
}
/* free ram */
- XFREE(a->dp);
+ XFREE(a->dp, sizeof (mp_digit) * (size_t)a->alloc);
/* reset members to make debugging easier */
a->dp = NULL;
diff --git a/libtommath/bn_mp_fwrite.c b/libtommath/bn_mp_fwrite.c
index 9f0c3df..85a942f 100644
--- a/libtommath/bn_mp_fwrite.c
+++ b/libtommath/bn_mp_fwrite.c
@@ -22,24 +22,24 @@ int mp_fwrite(const mp_int *a, int radix, FILE *stream)
return err;
}
- buf = OPT_CAST(char) XMALLOC((size_t)len);
+ buf = (char *) XMALLOC((size_t)len);
if (buf == NULL) {
return MP_MEM;
}
if ((err = mp_toradix(a, buf, radix)) != MP_OKAY) {
- XFREE(buf);
+ XFREE(buf, len);
return err;
}
for (x = 0; x < len; x++) {
if (fputc((int)buf[x], stream) == EOF) {
- XFREE(buf);
+ XFREE(buf, len);
return MP_VAL;
}
}
- XFREE(buf);
+ XFREE(buf, len);
return MP_OKAY;
}
#endif
diff --git a/libtommath/bn_mp_get_double.c b/libtommath/bn_mp_get_double.c
index 3ed5a71..629eae3 100644
--- a/libtommath/bn_mp_get_double.c
+++ b/libtommath/bn_mp_get_double.c
@@ -19,10 +19,10 @@ double mp_get_double(const mp_int *a)
for (i = 0; i < DIGIT_BIT; ++i) {
fac *= 2.0;
}
- for (i = USED(a); i --> 0;) {
- d = (d * fac) + (double)DIGIT(a, i);
+ for (i = a->used; i --> 0;) {
+ d = (d * fac) + (double)a->dp[i];
}
- return (mp_isneg(a) != MP_NO) ? -d : d;
+ return (a->sign == MP_NEG) ? -d : d;
}
#endif
diff --git a/libtommath/bn_mp_get_long.c b/libtommath/bn_mp_get_long.c
index a4d05d6..b95bb8a 100644
--- a/libtommath/bn_mp_get_long.c
+++ b/libtommath/bn_mp_get_long.c
@@ -18,19 +18,19 @@ unsigned long mp_get_long(const mp_int *a)
int i;
unsigned long res;
- if (a->used == 0) {
+ if (IS_ZERO(a)) {
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;
+ i = MIN(a->used, (((CHAR_BIT * (int)sizeof(unsigned long)) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
/* get most significant digit of result */
- res = DIGIT(a, i);
+ res = (unsigned long)a->dp[i];
-#if (ULONG_MAX != 0xffffffffuL) || (DIGIT_BIT < 32)
+#if (ULONG_MAX != 0xFFFFFFFFUL) || (DIGIT_BIT < 32)
while (--i >= 0) {
- res = (res << DIGIT_BIT) | DIGIT(a, i);
+ res = (res << DIGIT_BIT) | (unsigned long)a->dp[i];
}
#endif
return res;
diff --git a/libtommath/bn_mp_get_long_long.c b/libtommath/bn_mp_get_long_long.c
index 61d16ea..49a0208 100644
--- a/libtommath/bn_mp_get_long_long.c
+++ b/libtommath/bn_mp_get_long_long.c
@@ -18,19 +18,19 @@ Tcl_WideUInt mp_get_long_long(const mp_int *a)
int i;
Tcl_WideUInt res;
- if (a->used == 0) {
+ if (IS_ZERO(a)) {
return 0;
}
/* get number of digits of the lsb we have to read */
- i = MIN(a->used, ((((int)sizeof(Tcl_WideUInt) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
+ i = MIN(a->used, (((CHAR_BIT * (int)sizeof(Tcl_WideUInt)) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
/* get most significant digit of result */
- res = DIGIT(a, i);
+ res = (unsigned long long)a->dp[i];
#if DIGIT_BIT < 64
while (--i >= 0) {
- res = (res << DIGIT_BIT) | DIGIT(a, i);
+ res = (res << DIGIT_BIT) | (unsigned long long)a->dp[i];
}
#endif
return res;
diff --git a/libtommath/bn_mp_grow.c b/libtommath/bn_mp_grow.c
index 1d92b29..b120194 100644
--- a/libtommath/bn_mp_grow.c
+++ b/libtommath/bn_mp_grow.c
@@ -29,7 +29,9 @@ int mp_grow(mp_int *a, int size)
* in case the operation failed we don't want
* to overwrite the dp member of a.
*/
- tmp = OPT_CAST(mp_digit) XREALLOC(a->dp, sizeof(mp_digit) * (size_t)size);
+ tmp = (mp_digit *) XREALLOC(a->dp,
+ (size_t)a->alloc * sizeof (mp_digit),
+ (size_t)size * sizeof(mp_digit));
if (tmp == NULL) {
/* reallocation failed but "a" is still valid [can be freed] */
return MP_MEM;
diff --git a/libtommath/bn_mp_init.c b/libtommath/bn_mp_init.c
index 7520089..3c0c489 100644
--- a/libtommath/bn_mp_init.c
+++ b/libtommath/bn_mp_init.c
@@ -18,7 +18,7 @@ int mp_init(mp_int *a)
int i;
/* allocate memory required and clear it */
- a->dp = OPT_CAST(mp_digit) XMALLOC(sizeof(mp_digit) * (size_t)MP_PREC);
+ a->dp = (mp_digit *) XMALLOC(MP_PREC * sizeof(mp_digit));
if (a->dp == NULL) {
return MP_MEM;
}
diff --git a/libtommath/bn_mp_init_size.c b/libtommath/bn_mp_init_size.c
index 9b933fb..1becb23 100644
--- a/libtommath/bn_mp_init_size.c
+++ b/libtommath/bn_mp_init_size.c
@@ -21,7 +21,7 @@ int mp_init_size(mp_int *a, int size)
size += (MP_PREC * 2) - (size % MP_PREC);
/* alloc mem */
- a->dp = OPT_CAST(mp_digit) XMALLOC(sizeof(mp_digit) * (size_t)size);
+ a->dp = (mp_digit *) XMALLOC((size_t)size * sizeof(mp_digit));
if (a->dp == NULL) {
return MP_MEM;
}
diff --git a/libtommath/bn_mp_is_square.c b/libtommath/bn_mp_is_square.c
index 5363a47..1dd1d6c 100644
--- a/libtommath/bn_mp_is_square.c
+++ b/libtommath/bn_mp_is_square.c
@@ -49,13 +49,12 @@ int mp_is_square(const mp_int *arg, int *ret)
return MP_VAL;
}
- /* digits used? (TSD) */
- if (arg->used == 0) {
+ if (IS_ZERO(arg)) {
return MP_OKAY;
}
/* First check mod 128 (suppose that DIGIT_BIT is at least 7) */
- if (rem_128[127u & DIGIT(arg, 0)] == (char)1) {
+ if (rem_128[127u & arg->dp[0]] == (char)1) {
return MP_OKAY;
}
diff --git a/libtommath/bn_mp_prime_random_ex.c b/libtommath/bn_mp_prime_random_ex.c
index b0b4632..0ca29ec 100644
--- a/libtommath/bn_mp_prime_random_ex.c
+++ b/libtommath/bn_mp_prime_random_ex.c
@@ -46,19 +46,19 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
bsize = (size>>3) + ((size&7)?1:0);
/* we need a buffer of bsize bytes */
- tmp = OPT_CAST(unsigned char) XMALLOC((size_t)bsize);
+ tmp = (unsigned char *) XMALLOC((size_t)bsize);
if (tmp == NULL) {
return MP_MEM;
}
/* calc the maskAND value for the MSbyte*/
- maskAND = ((size&7) == 0) ? 0xFF : (0xFF >> (8 - (size & 7)));
+ maskAND = ((size&7) == 0) ? 0xFF : (unsigned char)(0xFF >> (8 - (size & 7)));
/* calc the maskOR_msb */
maskOR_msb = 0;
maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0;
if ((flags & LTM_PRIME_2MSB_ON) != 0) {
- maskOR_msb |= 0x80 >> ((9 - size) & 7);
+ maskOR_msb |= (unsigned char)(0x80 >> ((9 - size) & 7));
}
/* get the maskOR_lsb */
@@ -76,7 +76,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
/* work over the MSbyte */
tmp[0] &= maskAND;
- tmp[0] |= 1 << ((size - 1) & 7);
+ tmp[0] |= (unsigned char)(1 << ((size - 1) & 7));
/* mix in the maskORs */
tmp[maskOR_msb_offset] |= maskOR_msb;
@@ -123,7 +123,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
err = MP_OKAY;
error:
- XFREE(tmp);
+ XFREE(tmp, bsize);
return err;
}
diff --git a/libtommath/bn_mp_read_radix.c b/libtommath/bn_mp_read_radix.c
index 200601e..a8723b7 100644
--- a/libtommath/bn_mp_read_radix.c
+++ b/libtommath/bn_mp_read_radix.c
@@ -12,6 +12,8 @@
* SPDX-License-Identifier: Unlicense
*/
+#define MP_TOUPPER(c) ((((c) >= 'a') && ((c) <= 'z')) ? (((c) + 'A') - 'a') : (c))
+
/* read a string [ASCII] in a given radix */
int mp_read_radix(mp_int *a, const char *str, int radix)
{
@@ -46,7 +48,7 @@ int mp_read_radix(mp_int *a, const char *str, int radix)
* this allows numbers like 1AB and 1ab to represent the same value
* [e.g. in hex]
*/
- ch = (radix <= 36) ? (char)toupper((int)*str) : *str;
+ ch = (radix <= 36) ? (char)MP_TOUPPER((int)*str) : *str;
pos = (unsigned)(ch - '(');
if (mp_s_rmap_reverse_sz < pos) {
break;
diff --git a/libtommath/bn_mp_set_double.c b/libtommath/bn_mp_set_double.c
index 76f6293..c96a3b3 100644
--- a/libtommath/bn_mp_set_double.c
+++ b/libtommath/bn_mp_set_double.c
@@ -41,8 +41,8 @@ int mp_set_double(mp_int *a, double b)
return res;
}
- if (((cast.bits >> 63) != 0ULL) && (mp_iszero(a) == MP_NO)) {
- SIGN(a) = MP_NEG;
+ if (((cast.bits >> 63) != 0ULL) && !IS_ZERO(a)) {
+ a->sign = MP_NEG;
}
return MP_OKAY;
diff --git a/libtommath/bn_mp_shrink.c b/libtommath/bn_mp_shrink.c
index ff7905f..fa30184 100644
--- a/libtommath/bn_mp_shrink.c
+++ b/libtommath/bn_mp_shrink.c
@@ -23,7 +23,9 @@ int mp_shrink(mp_int *a)
}
if (a->alloc != used) {
- if ((tmp = OPT_CAST(mp_digit) XREALLOC(a->dp, sizeof(mp_digit) * (size_t)used)) == NULL) {
+ if ((tmp = (mp_digit *) XREALLOC(a->dp,
+ (size_t)a->alloc * sizeof (mp_digit),
+ (size_t)used * sizeof(mp_digit))) == NULL) {
return MP_MEM;
}
a->dp = tmp;
diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h
index faecb9f..91fab4a 100644
--- a/libtommath/tommath_private.h
+++ b/libtommath/tommath_private.h
@@ -13,7 +13,6 @@
#define TOMMATH_PRIV_H_
#include <tommath.h>
-#include <ctype.h>
#ifndef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
@@ -25,28 +24,19 @@
#ifdef __cplusplus
extern "C" {
-
-/* C++ compilers don't like assigning void * to mp_digit * */
-#define OPT_CAST(x) (x *)
-
-#else
-
-/* C on the other hand doesn't care */
-#define OPT_CAST(x)
-
#endif
/* define heap macros */
#ifndef XMALLOC
/* default to libc stuff */
-# define XMALLOC malloc
-# define XFREE free
-# define XREALLOC realloc
+# define XMALLOC(size) malloc(size)
+# define XFREE(mem, size) free(mem)
+# define XREALLOC(mem, oldsize, newsize) realloc(mem, newsize)
#elif 0
/* prototypes for our heap functions */
-extern void *XMALLOC(size_t n);
-extern void *XREALLOC(void *p, size_t n);
-extern void XFREE(void *p);
+extern void *XMALLOC(size_t size);
+extern void *XREALLOC(void *mem, size_t oldsize, size_t newsize);
+extern void XFREE(void *mem, size_t size);
#endif
#if defined(MP_8BIT)
@@ -71,6 +61,11 @@ typedef unsigned long long mp_word;
/* 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))
+/* ---> Basic Manipulations <--- */
+#define IS_ZERO(a) ((a)->used == 0)
+#define IS_EVEN(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
+#define IS_ODD(a) (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u))
+
/* 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);
@@ -98,36 +93,26 @@ extern const size_t mp_s_rmap_reverse_sz;
/* Fancy macro to set an MPI from another type.
* There are several things assumed:
- * x is the counter and unsigned
+ * x is the counter
* a is the pointer to the MPI
* b is the original value that should be set in the MPI.
*/
#define MP_SET_XLONG(func_name, type) \
int func_name (mp_int * a, type b) \
{ \
- unsigned int x; \
- int res; \
- \
- mp_zero (a); \
- \
- /* set four bits at a time */ \
- for (x = 0; x < (sizeof(type) * 2u); x++) { \
- /* shift the number up four bits */ \
- if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) { \
- return res; \
- } \
- \
- /* OR in the top four bits of the source */ \
- a->dp[0] |= (mp_digit)(b >> ((sizeof(type) * 8u) - 4u)) & 15uL;\
- \
- /* shift the source up to the next four bits */ \
- b <<= 4; \
- \
- /* ensure that digits are not clamped off */ \
- a->used += 1; \
- } \
- mp_clamp (a); \
- return MP_OKAY; \
+ int x = 0; \
+ int new_size = (((CHAR_BIT * sizeof(type)) + DIGIT_BIT) - 1) / DIGIT_BIT; \
+ int res = mp_grow(a, new_size); \
+ if (res == MP_OKAY) { \
+ mp_zero(a); \
+ while (b != 0u) { \
+ a->dp[x++] = ((mp_digit)b & MP_MASK); \
+ if ((CHAR_BIT * sizeof (b)) <= DIGIT_BIT) { break; } \
+ b >>= ((CHAR_BIT * sizeof (b)) <= DIGIT_BIT ? 0 : DIGIT_BIT); \
+ } \
+ a->used = x; \
+ } \
+ return res; \
}
#ifdef __cplusplus
diff --git a/tests/socket.test b/tests/socket.test
index 1d202f3..b91668e 100644
--- a/tests/socket.test
+++ b/tests/socket.test
@@ -129,9 +129,9 @@ catch {socket 127.0.0.1 [randport]}
set t2 [clock milliseconds]
set lat2 [expr {($t2-$t1)*3}]
-# Use the maximum of the two latency calculations, but at least 100ms
+# Use the maximum of the two latency calculations, but at least 200ms
set latency [expr {$lat1 > $lat2 ? $lat1 : $lat2}]
-set latency [expr {$latency > 100 ? $latency : 1000}]
+set latency [expr {$latency > 200 ? $latency : 200}]
unset t1 t2 s1 s2 lat1 lat2 server
# If remoteServerIP or remoteServerPort are not set, check in the environment
@@ -672,7 +672,7 @@ test socket_$af-2.11 {detecting new data} -constraints [list socket supported_$a
vwait sock
puts $s2 one
flush $s2
- after idle {set x 1}
+ after $latency {set x 1}; # Spurious failures in Travis CI, if we do [after idle]
vwait x
fconfigure $sock -blocking 0
set result a:[gets $sock]
diff --git a/unix/configure b/unix/configure
index ea26c4f..8dc11f5 100755
--- a/unix/configure
+++ b/unix/configure
@@ -705,6 +705,9 @@ TCL_LIBS
LIBOBJS
AR
RANLIB
+LIBTOMMATH_INCLUDE
+LIBTOMMATH_SRCS
+LIBTOMMATH_OBJS
ZLIB_INCLUDE
ZLIB_SRCS
ZLIB_OBJS
@@ -740,6 +743,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -828,6 +832,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1080,6 +1085,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1217,7 +1231,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1370,6 +1384,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -4657,6 +4672,101 @@ fi
$as_echo "#define HAVE_ZLIB 1" >>confdefs.h
+#------------------------------------------------------------------------
+# Add stuff for libtommath
+
+libtommath_ok=yes
+ac_fn_c_check_header_mongrel "$LINENO" "tommath.h" "ac_cv_header_tommath_h" "$ac_includes_default"
+if test "x$ac_cv_header_tommath_h" = xyes; then :
+
+ ac_fn_c_check_type "$LINENO" "mp_int" "ac_cv_type_mp_int" "#include <tommath.h>
+"
+if test "x$ac_cv_type_mp_int" = xyes; then :
+
+else
+ libtommath_ok=no
+fi
+
+else
+
+ libtommath_ok=no
+fi
+
+
+if test $libtommath_ok = yes; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing mp_add" >&5
+$as_echo_n "checking for library containing mp_add... " >&6; }
+if ${ac_cv_search_mp_add+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char mp_add ();
+int
+main ()
+{
+return mp_add ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' tommath; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_mp_add=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_mp_add+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_mp_add+:} false; then :
+
+else
+ ac_cv_search_mp_add=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_mp_add" >&5
+$as_echo "$ac_cv_search_mp_add" >&6; }
+ac_res=$ac_cv_search_mp_add
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+else
+
+ libtommath_ok=no
+
+fi
+
+fi
+if test $libtommath_ok = no; then :
+
+ LIBTOMMATH_OBJS=\${LIBTOMMATH_OBJS}
+
+ LIBTOMMATH_SRCS=\${LIBTOMMATH_SRCS}
+
+ LIBTOMMATH_INCLUDE=-I\${LIBTOMMATH_DIR}
+
+
+fi
+
#--------------------------------------------------------------------
# The statements below define a collection of compile flags. This
# macro depends on the value of SHARED_BUILD, and should be called
diff --git a/unix/configure.ac b/unix/configure.ac
index f34091f..9c4135b 100644
--- a/unix/configure.ac
+++ b/unix/configure.ac
@@ -167,6 +167,23 @@ AS_IF([test $zlib_ok = no], [
])
AC_DEFINE(HAVE_ZLIB, 1, [Is there an installed zlib?])
+#------------------------------------------------------------------------
+# Add stuff for libtommath
+
+libtommath_ok=yes
+AC_CHECK_HEADER([tommath.h],[
+ AC_CHECK_TYPE([mp_int],[],[libtommath_ok=no],[#include <tommath.h>])],[
+ libtommath_ok=no])
+AS_IF([test $libtommath_ok = yes], [
+ AC_SEARCH_LIBS([mp_add],[tommath],[],[
+ libtommath_ok=no
+ ])])
+AS_IF([test $libtommath_ok = no], [
+ AC_SUBST(LIBTOMMATH_OBJS,[\${LIBTOMMATH_OBJS}])
+ AC_SUBST(LIBTOMMATH_SRCS,[\${LIBTOMMATH_SRCS}])
+ AC_SUBST(LIBTOMMATH_INCLUDE,[-I\${LIBTOMMATH_DIR}])
+])
+
#--------------------------------------------------------------------
# The statements below define a collection of compile flags. This
# macro depends on the value of SHARED_BUILD, and should be called