diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-10-23 09:16:37 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-10-23 09:16:37 (GMT) |
commit | 2df6f12a996d019b78a31c15f5875e2609fb28b2 (patch) | |
tree | 55a9f72791801290593f4cec9b4bb2359aab54dc /generic | |
parent | 481c3a3fd52f111e7c645ea5b959fc128fe1d377 (diff) | |
download | tcl-2df6f12a996d019b78a31c15f5875e2609fb28b2.zip tcl-2df6f12a996d019b78a31c15f5875e2609fb28b2.tar.gz tcl-2df6f12a996d019b78a31c15f5875e2609fb28b2.tar.bz2 |
Extend libtommath stub table, so extension writers can move away from deprecated libtommath functions.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclInt.h | 3 | ||||
-rw-r--r-- | generic/tclStubInit.c | 5 | ||||
-rw-r--r-- | generic/tclTomMath.decls | 15 | ||||
-rw-r--r-- | generic/tclTomMath.h | 8 | ||||
-rw-r--r-- | generic/tclTomMathDecls.h | 30 |
5 files changed, 51 insertions, 10 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h index a0955c9..cb18889 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4039,9 +4039,6 @@ MODULE_SCOPE int TclIndexEncode(Tcl_Interp *interp, Tcl_Obj *objPtr, int before, int after, int *indexPtr); MODULE_SCOPE int TclIndexDecode(int encoded, int endValue); -MODULE_SCOPE int TclBN_mp_to_ubin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written); -MODULE_SCOPE size_t TclBN_mp_ubin_size(const mp_int *a); -MODULE_SCOPE int TclBN_mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, int radix); MODULE_SCOPE void TclBN_int_reverse(unsigned char *s, size_t len); /* Constants used in index value encoding routines. */ diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 2df2aae..ce389bf 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -924,12 +924,15 @@ const TclTomMathStubs tclTomMathStubs = { 0, /* 69 */ TclBN_mp_set_long, /* 70 */ 0, /* 71 */ - 0, /* 72 */ + TclBN_mp_isodd, /* 72 */ TclBN_mp_tc_and, /* 73 */ TclBN_mp_tc_or, /* 74 */ TclBN_mp_tc_xor, /* 75 */ TclBN_mp_signed_rsh, /* 76 */ TclBN_mp_get_bit, /* 77 */ + TclBN_mp_to_ubin, /* 78 */ + TclBN_mp_ubin_size, /* 79 */ + TclBN_mp_to_radix, /* 80 */ }; static const TclStubHooks tclStubHooks = { diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls index 1ac1cb9..01df31b 100644 --- a/generic/tclTomMath.decls +++ b/generic/tclTomMath.decls @@ -240,6 +240,9 @@ declare 67 { declare 70 { mp_err TclBN_mp_set_long(mp_int *a, unsigned long i) } +declare 72 { + mp_bool TclBN_mp_isodd(const mp_int *a) +} # Added in libtommath 1.1.0 declare 73 { @@ -254,11 +257,21 @@ declare 75 { declare 76 { mp_err TclBN_mp_signed_rsh(const mp_int *a, int b, mp_int *c) } - declare 77 { mp_bool TclBN_mp_get_bit(const mp_int *a, unsigned int b) } +# Added in libtommath 1.2.0 +declare 78 { + int TclBN_mp_to_ubin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written) +} +declare 79 { + size_t TclBN_mp_ubin_size(const mp_int *a) +} +declare 80 { + int TclBN_mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, int radix) +} + # Local Variables: # mode: tcl diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h index 83a31d6..7b720e9 100644 --- a/generic/tclTomMath.h +++ b/generic/tclTomMath.h @@ -323,8 +323,12 @@ mp_err mp_init_size(mp_int *a, int size) MP_WUR; /* ---> Basic Manipulations <--- */ #define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO) -#define mp_iseven(a) (((a)->used == 0 || (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO) -#define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO) +/* +mp_bool mp_iseven(const mp_int *a) MP_WUR; +*/ +/* +mp_bool mp_isodd(const mp_int *a) MP_WUR; +*/ #define mp_isneg(a) (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO) /* set to zero */ diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index be9d28e..a4c7e02 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -90,6 +90,7 @@ #define s_mp_karatsuba_mul TclBN_mp_karatsuba_mul #define mp_karatsuba_sqr TclBN_mp_karatsuba_sqr #define s_mp_karatsuba_sqr TclBN_mp_karatsuba_sqr +#define mp_isodd TclBN_mp_isodd #define mp_lshd TclBN_mp_lshd #define mp_mod TclBN_mp_mod #define mp_mod_2d TclBN_mp_mod_2d @@ -331,7 +332,8 @@ EXTERN mp_err TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, /* 70 */ EXTERN mp_err TclBN_mp_set_long(mp_int *a, unsigned long i); /* Slot 71 is reserved */ -/* Slot 72 is reserved */ +/* 72 */ +EXTERN mp_bool TclBN_mp_isodd(const mp_int *a); /* 73 */ EXTERN mp_err TclBN_mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c); @@ -346,6 +348,14 @@ EXTERN mp_err TclBN_mp_signed_rsh(const mp_int *a, int b, mp_int *c); /* 77 */ EXTERN mp_bool TclBN_mp_get_bit(const mp_int *a, unsigned int b); +/* 78 */ +EXTERN int TclBN_mp_to_ubin(const mp_int *a, unsigned char *buf, + size_t maxlen, size_t *written); +/* 79 */ +EXTERN size_t TclBN_mp_ubin_size(const mp_int *a); +/* 80 */ +EXTERN int TclBN_mp_to_radix(const mp_int *a, char *str, + size_t maxlen, size_t *written, int radix); typedef struct TclTomMathStubs { int magic; @@ -423,12 +433,15 @@ typedef struct TclTomMathStubs { void (*reserved69)(void); mp_err (*tclBN_mp_set_long) (mp_int *a, unsigned long i); /* 70 */ void (*reserved71)(void); - void (*reserved72)(void); + mp_bool (*tclBN_mp_isodd) (const mp_int *a); /* 72 */ mp_err (*tclBN_mp_tc_and) (const mp_int *a, const mp_int *b, mp_int *c); /* 73 */ mp_err (*tclBN_mp_tc_or) (const mp_int *a, const mp_int *b, mp_int *c); /* 74 */ mp_err (*tclBN_mp_tc_xor) (const mp_int *a, const mp_int *b, mp_int *c); /* 75 */ mp_err (*tclBN_mp_signed_rsh) (const mp_int *a, int b, mp_int *c); /* 76 */ mp_bool (*tclBN_mp_get_bit) (const mp_int *a, unsigned int b); /* 77 */ + int (*tclBN_mp_to_ubin) (const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written); /* 78 */ + size_t (*tclBN_mp_ubin_size) (const mp_int *a); /* 79 */ + int (*tclBN_mp_to_radix) (const mp_int *a, char *str, size_t maxlen, size_t *written, int radix); /* 80 */ } TclTomMathStubs; extern const TclTomMathStubs *tclTomMathStubsPtr; @@ -584,7 +597,8 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; #define TclBN_mp_set_long \ (tclTomMathStubsPtr->tclBN_mp_set_long) /* 70 */ /* Slot 71 is reserved */ -/* Slot 72 is reserved */ +#define TclBN_mp_isodd \ + (tclTomMathStubsPtr->tclBN_mp_isodd) /* 72 */ #define TclBN_mp_tc_and \ (tclTomMathStubsPtr->tclBN_mp_tc_and) /* 73 */ #define TclBN_mp_tc_or \ @@ -595,11 +609,21 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; (tclTomMathStubsPtr->tclBN_mp_signed_rsh) /* 76 */ #define TclBN_mp_get_bit \ (tclTomMathStubsPtr->tclBN_mp_get_bit) /* 77 */ +#define TclBN_mp_to_ubin \ + (tclTomMathStubsPtr->tclBN_mp_to_ubin) /* 78 */ +#define TclBN_mp_ubin_size \ + (tclTomMathStubsPtr->tclBN_mp_ubin_size) /* 79 */ +#define TclBN_mp_to_radix \ + (tclTomMathStubsPtr->tclBN_mp_to_radix) /* 80 */ #endif /* defined(USE_TCL_STUBS) */ /* !END!: Do not edit above this line. */ +#undef mp_isodd +#define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO) +#define mp_iseven(a) (((a)->used == 0 || (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO) + #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT |