diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-10-23 21:35:16 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-10-23 21:35:16 (GMT) |
commit | 35776acac0c0658191156c70b24cc7d16493610b (patch) | |
tree | ea662df00826a90f8bc355ebbe00fdd6e8b3a0a2 /generic | |
parent | 86ee14968935e2a3f55deb2c9271fcf159e060f0 (diff) | |
parent | b7495e42cac1a17bde7a0192d9b5226cd98037f2 (diff) | |
download | tcl-35776acac0c0658191156c70b24cc7d16493610b.zip tcl-35776acac0c0658191156c70b24cc7d16493610b.tar.gz tcl-35776acac0c0658191156c70b24cc7d16493610b.tar.bz2 |
Merge 8.7
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclDisassemble.c | 2 | ||||
-rw-r--r-- | generic/tclInt.h | 8 | ||||
-rw-r--r-- | generic/tclOO.c | 2 | ||||
-rw-r--r-- | generic/tclScan.c | 3 | ||||
-rw-r--r-- | generic/tclTest.c | 4 | ||||
-rw-r--r-- | generic/tclTomMath.h | 93 | ||||
-rw-r--r-- | generic/tclUtil.c | 2 |
7 files changed, 64 insertions, 50 deletions
diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c index a0d1258..6580d59 100644 --- a/generic/tclDisassemble.c +++ b/generic/tclDisassemble.c @@ -1610,7 +1610,7 @@ Tcl_DisassembleObjCmd( "BYTECODE", NULL); return TCL_ERROR; } - if (PTR2INT(clientData)) { + if (clientData) { Tcl_SetObjResult(interp, DisassembleByteCodeAsDicts(interp, codeObjPtr)); } else { diff --git a/generic/tclInt.h b/generic/tclInt.h index 1823c70..abf6c83 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -120,19 +120,19 @@ typedef int ptrdiff_t; #if !defined(INT2PTR) && !defined(PTR2INT) # if defined(HAVE_INTPTR_T) || defined(intptr_t) # define INT2PTR(p) ((void *)(intptr_t)(p)) -# define PTR2INT(p) ((int)(intptr_t)(p)) +# define PTR2INT(p) ((intptr_t)(p)) # else # define INT2PTR(p) ((void *)(p)) -# define PTR2INT(p) ((int)(p)) +# define PTR2INT(p) ((long)(p)) # endif #endif #if !defined(UINT2PTR) && !defined(PTR2UINT) # if defined(HAVE_UINTPTR_T) || defined(uintptr_t) # define UINT2PTR(p) ((void *)(uintptr_t)(p)) -# define PTR2UINT(p) ((unsigned int)(uintptr_t)(p)) +# define PTR2UINT(p) ((uintptr_t)(p)) # else # define UINT2PTR(p) ((void *)(p)) -# define PTR2UINT(p) ((unsigned int)(p)) +# define PTR2UINT(p) ((unsigned long)(p)) # endif #endif diff --git a/generic/tclOO.c b/generic/tclOO.c index 0c18390..2491c2f 100644 --- a/generic/tclOO.c +++ b/generic/tclOO.c @@ -1237,7 +1237,7 @@ ObjectNamespaceDeleted( /* * Because an object can be a class that is an instance of itself, the * class object's class structure should only be cleaned after most of - * the cleanup on the object is done. + * the cleanup on the object is done. * * The class of objects needs some special care; if it is deleted (and * we're not killing the whole interpreter) we force the delete of the diff --git a/generic/tclScan.c b/generic/tclScan.c index 733409e..6a1311f 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -932,8 +932,7 @@ Tcl_ScanObjCmd( } } if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) { - sprintf(buf, "%" TCL_LL_MODIFIER "u", - (Tcl_WideUInt)wideValue); + sprintf(buf, "%" TCL_LL_MODIFIER "u", wideValue); Tcl_SetStringObj(objPtr, buf, -1); } else { TclSetIntObj(objPtr, wideValue); diff --git a/generic/tclTest.c b/generic/tclTest.c index d9cd9bf..09c74cd 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -2396,7 +2396,7 @@ ExitProcOdd( char buf[16 + TCL_INTEGER_SPACE]; size_t len; - sprintf(buf, "odd %d\n", PTR2INT(clientData)); + sprintf(buf, "odd %" TCL_Z_MODIFIER "d\n", (size_t)PTR2INT(clientData)); len = strlen(buf); if (len != (size_t) write(1, buf, len)) { Tcl_Panic("ExitProcOdd: unable to write to stdout"); @@ -2410,7 +2410,7 @@ ExitProcEven( char buf[16 + TCL_INTEGER_SPACE]; size_t len; - sprintf(buf, "even %d\n", PTR2INT(clientData)); + sprintf(buf, "even %" TCL_Z_MODIFIER "d\n", (size_t)PTR2INT(clientData)); len = strlen(buf); if (len != (size_t) write(1, buf, len)) { Tcl_Panic("ExitProcEven: unable to write to stdout"); diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h index e0f8497..fbf0d35 100644 --- a/generic/tclTomMath.h +++ b/generic/tclTomMath.h @@ -9,8 +9,6 @@ * * The library is free for all purposes without any express * guarantee it works. - * - * Tom St Denis, tstdenis82@gmail.com, http://math.libtomcrypt.com */ #ifndef BN_H_ #define BN_H_ @@ -27,14 +25,20 @@ 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(_MSC_VER) || defined(__LLP64__) +#if defined(_MSC_VER) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__) # define MP_32BIT #endif /* detect 64-bit mode if possible */ #if defined(NEVER) -# if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT) || defined(_MSC_VER)) -# define MP_64BIT +# if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT)) +# if defined(__GNUC__) +/* we support 128bit integers only via: __attribute__((mode(TI))) */ +# define MP_64BIT +# else +/* otherwise we fall back to MP_32BIT even on 64bit platforms */ +# define MP_32BIT +# endif # endif #endif @@ -48,11 +52,11 @@ extern "C" { */ #ifdef MP_8BIT #ifndef MP_DIGIT_DECLARED -typedef uint8_t mp_digit; +typedef unsigned char mp_digit; #define MP_DIGIT_DECLARED #endif #ifndef MP_WORD_DECLARED -typedef uint16_t mp_word; +typedef unsigned short mp_word; #define MP_WORD_DECLARED #endif # define MP_SIZEOF_MP_DIGIT 1 @@ -61,11 +65,11 @@ typedef uint16_t mp_word; # endif #elif defined(MP_16BIT) #ifndef MP_DIGIT_DECLARED -typedef uint16_t mp_digit; +typedef unsigned short mp_digit; #define MP_DIGIT_DECLARED #endif #ifndef MP_WORD_DECLARED -typedef uint32_t mp_word; +typedef unsigned int mp_word; #define MP_WORD_DECLARED #endif # define MP_SIZEOF_MP_DIGIT 2 @@ -75,31 +79,21 @@ typedef uint32_t mp_word; #elif defined(MP_64BIT) /* for GCC only on supported platforms */ #ifndef MP_DIGIT_DECLARED -typedef uint64_t mp_digit; +typedef unsigned long long mp_digit; #define MP_DIGIT_DECLARED #endif -# if 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 #else /* this is the default case, 28-bit digits */ /* this is to make porting into LibTomCrypt easier :-) */ #ifndef MP_DIGIT_DECLARED -typedef uint32_t mp_digit; +typedef unsigned int mp_digit; #define MP_DIGIT_DECLARED #endif #ifndef MP_WORD_DECLARED -typedef uint64_t mp_word; +typedef unsigned long long mp_word; #define MP_WORD_DECLARED #endif @@ -116,23 +110,11 @@ typedef uint64_t mp_word; /* 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 */ -typedef uint_least32_t mp_min_u32; +typedef unsigned long mp_min_u32; #else typedef mp_digit mp_min_u32; #endif -/* use arc4random on platforms that support it */ -#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) -# define MP_GEN_RANDOM() arc4random() -# define MP_GEN_RANDOM_MAX 0xffffffffu -#endif - -/* use rand() as fall-back if there's no better rand function */ -#ifndef MP_GEN_RANDOM -# define MP_GEN_RANDOM() rand() -# define MP_GEN_RANDOM_MAX RAND_MAX -#endif - #define MP_DIGIT_BIT DIGIT_BIT #define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1)) #define MP_DIGIT_MAX MP_MASK @@ -271,9 +253,9 @@ int mp_set_int(mp_int *a, unsigned long b); int mp_set_long(mp_int *a, unsigned long b); */ -/* set a platform dependent Tcl_WideUInt value */ +/* set a platform dependent unsigned long long value */ /* -int mp_set_long_long(mp_int *a, Tcl_WideUInt b); +int mp_set_long_long(mp_int *a, unsigned long long b); */ /* get a 32-bit value */ @@ -286,9 +268,9 @@ unsigned long mp_get_int(const mp_int *a); unsigned long mp_get_long(const mp_int *a); */ -/* get a platform dependent Tcl_WideUInt value */ +/* get a platform dependent unsigned long long value */ /* -Tcl_WideUInt mp_get_long_long(const mp_int *a); +unsigned long long mp_get_long_long(const mp_int *a); */ /* initialize and set a digit */ @@ -380,6 +362,14 @@ int mp_cnt_lsb(const mp_int *a); int mp_rand(mp_int *a, int digits); */ +#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 */ +extern unsigned long (*ltm_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void)); +extern void (*ltm_rng_callback)(void); +#endif + /* ---> binary operations <--- */ /* c = a XOR b */ /* @@ -396,8 +386,33 @@ int mp_or(const mp_int *a, const mp_int *b, mp_int *c); int mp_and(const mp_int *a, const mp_int *b, mp_int *c); */ +/* c = a XOR b (two complement) */ +/* +int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c); +*/ + +/* c = a OR b (two complement) */ +/* +int mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c); +*/ + +/* c = a AND b (two complement) */ +/* +int mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c); +*/ + +/* right shift (two complement) */ +/* +int mp_tc_div_2d(const mp_int *a, int b, mp_int *c); +*/ + /* ---> Basic arithmetic <--- */ +/* b = ~a */ +/* +int mp_complement(const mp_int *a, mp_int *b); +*/ + /* b = -a */ /* int mp_neg(const mp_int *a, mp_int *b); diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 4ea9c2e..385bdd3 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3660,7 +3660,7 @@ TclFormatInt( * GetWideForIndex -- * * This function produces a wide integer value corresponding to the - * list index held in *objPtr. The parsing supports all values + * list index held in *objPtr. The parsing supports all values * recognized as any size of integer, and the syntaxes end[-+]$integer * and $integer[-+]$integer. The argument endValue is used to give * the meaning of the literal index value "end". |