From 4f097ce3654bd023cd0d912107a1671641acd69c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 19 May 2020 15:42:53 +0000 Subject: Possible simple solution for [4663e0636]: If TCL_NO_TOMMATH_H is defined, tclTomMath.h provides its own usable mp_int type (and some more) without the need for --- generic/tclTomMath.h | 33 ++++++++++++++++++++++++++++++++- generic/tclTomMathDecls.h | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h index 0d2d320..b421cde 100644 --- a/generic/tclTomMath.h +++ b/generic/tclTomMath.h @@ -8,7 +8,38 @@ # include "../compat/stdint.h" # endif #endif -#ifndef BN_H_ /* If BN_H_ already defined, don't try to include tommath.h again. */ +#if defined(TCL_NO_TOMMATH_H) + typedef size_t mp_digit; + typedef int mp_sign; +# define MP_ZPOS 0 /* positive integer */ +# define MP_NEG 1 /* negative */ + typedef int mp_ord; +# define MP_LT -1 /* less than */ +# define MP_EQ 0 /* equal to */ +# define MP_GT 1 /* greater than */ + typedef int mp_err; +# define MP_OKAY 0 /* no error */ +# define MP_ERR -1 /* unknown error */ +# define MP_MEM -2 /* out of mem */ +# define MP_VAL -3 /* invalid input */ +# define MP_ITER -4 /* maximum iterations reached */ +# define MP_BUF -5 /* buffer overflow, supplied buffer too small */ +# define MP_WUR /* nothing */ +# define mp_iszero(a) ((a)->used == 0) +# define mp_isneg(a) ((a)->sign != 0) + + /* the infamous mp_int structure */ +# ifndef MP_INT_DECLARED +# define MP_INT_DECLARED + typedef struct mp_int mp_int; +# endif + struct mp_int { + int used, alloc; + mp_sign sign; + mp_digit *dp; +}; + +#elif !defined(BN_H_) /* If BN_H_ already defined, don't try to include tommath.h again. */ # include "tommath.h" #endif #include "tclTomMathDecls.h" diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index 736a640..1427e8b 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -744,7 +744,7 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; #undef mp_iseven #undef mp_isodd #define mp_iseven(a) (!mp_isodd(a)) -#define mp_isodd(a) (((a)->used != 0 && (((a)->dp[0] & 1) != 0)) ? MP_YES : MP_NO) +#define mp_isodd(a) (((a)->used != 0) && (((a)->dp[0] & 1) != 0)) #undef mp_sqr #define mp_sqr(a,b) mp_mul(a,a,b) -- cgit v0.12