diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-09-15 13:08:31 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-09-15 13:08:31 (GMT) |
commit | 0faaca01de4e9fa2039c7fdd34f60b138f665249 (patch) | |
tree | dfc95748319b9285f975bf6225313dfb5686f16c /generic | |
parent | 130ba65bbe11f114680bbd9f9d45ec3b5de0caef (diff) | |
download | tcl-0faaca01de4e9fa2039c7fdd34f60b138f665249.zip tcl-0faaca01de4e9fa2039c7fdd34f60b138f665249.tar.gz tcl-0faaca01de4e9fa2039c7fdd34f60b138f665249.tar.bz2 |
'const'ify more libtommath functions. All functions in generic/tclTomMath.decls (used by Tcl) are done now.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclStubInit.c | 2 | ||||
-rw-r--r-- | generic/tclTomMath.decls | 12 | ||||
-rw-r--r-- | generic/tclTomMath.h | 16 | ||||
-rw-r--r-- | generic/tclTomMathDecls.h | 43 |
4 files changed, 44 insertions, 29 deletions
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 2845441..ebd2086 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -867,6 +867,8 @@ const TclTomMathStubs tclTomMathStubs = { TclBN_mp_expt_d_ex, /* 67 */ TclBN_mp_set_long_long, /* 68 */ TclBN_mp_get_long_long, /* 69 */ + TclBN_mp_set_long, /* 70 */ + TclBN_mp_get_long, /* 71 */ }; static const TclStubHooks tclStubHooks = { diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls index d628cfe..10df919 100644 --- a/generic/tclTomMath.decls +++ b/generic/tclTomMath.decls @@ -33,7 +33,7 @@ declare 2 { int TclBN_mp_add(const mp_int *a, const mp_int *b, mp_int *c) } declare 3 { - int TclBN_mp_add_d(mp_int *a, mp_digit b, mp_int *c) + int TclBN_mp_add_d(const mp_int *a, mp_digit b, mp_int *c) } declare 4 { int TclBN_mp_and(const mp_int *a, const mp_int *b, mp_int *c) @@ -153,20 +153,20 @@ declare 42 { int TclBN_mp_sub(const mp_int *a, const mp_int *b, mp_int *c) } declare 43 { - int TclBN_mp_sub_d(mp_int *a, mp_digit b, mp_int *c) + int TclBN_mp_sub_d(const mp_int *a, mp_digit b, mp_int *c) } declare 44 { - int TclBN_mp_to_unsigned_bin(mp_int *a, unsigned char *b) + int TclBN_mp_to_unsigned_bin(const mp_int *a, unsigned char *b) } declare 45 { - int TclBN_mp_to_unsigned_bin_n(mp_int *a, unsigned char *b, + int TclBN_mp_to_unsigned_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen) } declare 46 { - int TclBN_mp_toradix_n(mp_int *a, char *str, int radix, int maxlen) + int TclBN_mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen) } declare 47 { - int TclBN_mp_unsigned_bin_size(mp_int *a) + int TclBN_mp_unsigned_bin_size(const mp_int *a) } declare 48 { int TclBN_mp_xor(const mp_int *a, const mp_int *b, mp_int *c) diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h index f110490..34ac1bb 100644 --- a/generic/tclTomMath.h +++ b/generic/tclTomMath.h @@ -747,33 +747,33 @@ int mp_unsigned_bin_size(mp_int *a); int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c); */ /* -int mp_to_unsigned_bin(mp_int *a, unsigned char *b); +int mp_to_unsigned_bin(const mp_int *a, unsigned char *b); */ /* -int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen); +int mp_to_unsigned_bin_n (const mp_int * a, unsigned char *b, unsigned long *outlen); */ /* -int mp_signed_bin_size(mp_int *a); +int mp_signed_bin_size(const mp_int *a); */ /* int mp_read_signed_bin(mp_int *a, const unsigned char *b, int c); */ /* -int mp_to_signed_bin(mp_int *a, unsigned char *b); +int mp_to_signed_bin(const mp_int *a, unsigned char *b); */ /* -int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen); +int mp_to_signed_bin_n (const mp_int * a, unsigned char *b, unsigned long *outlen); */ /* int mp_read_radix(mp_int *a, const char *str, int radix); */ /* -int mp_toradix(mp_int *a, char *str, int radix); +int mp_toradix(const mp_int *a, char *str, int radix); */ /* -int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen); +int mp_toradix_n(const mp_int * a, char *str, int radix, int maxlen); */ /* int mp_radix_size(const mp_int *a, int radix, int *size); @@ -784,7 +784,7 @@ int mp_radix_size(const mp_int *a, int radix, int *size); int mp_fread(mp_int *a, int radix, FILE *stream); */ /* -int mp_fwrite(mp_int *a, int radix, FILE *stream); +int mp_fwrite(const mp_int *a, int radix, FILE *stream); */ #endif diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index 03f383f..f3145d7 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -156,7 +156,8 @@ EXTERN int TclBN_revision(void); EXTERN int TclBN_mp_add(const mp_int *a, const mp_int *b, mp_int *c); /* 3 */ -EXTERN int TclBN_mp_add_d(mp_int *a, mp_digit b, mp_int *c); +EXTERN int TclBN_mp_add_d(const mp_int *a, mp_digit b, + mp_int *c); /* 4 */ EXTERN int TclBN_mp_and(const mp_int *a, const mp_int *b, mp_int *c); @@ -249,17 +250,19 @@ EXTERN int TclBN_mp_sqrt(const mp_int *a, mp_int *b); EXTERN int TclBN_mp_sub(const mp_int *a, const mp_int *b, mp_int *c); /* 43 */ -EXTERN int TclBN_mp_sub_d(mp_int *a, mp_digit b, mp_int *c); +EXTERN int TclBN_mp_sub_d(const mp_int *a, mp_digit b, + mp_int *c); /* 44 */ -EXTERN int TclBN_mp_to_unsigned_bin(mp_int *a, unsigned char *b); +EXTERN int TclBN_mp_to_unsigned_bin(const mp_int *a, + unsigned char *b); /* 45 */ -EXTERN int TclBN_mp_to_unsigned_bin_n(mp_int *a, +EXTERN int TclBN_mp_to_unsigned_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen); /* 46 */ -EXTERN int TclBN_mp_toradix_n(mp_int *a, char *str, int radix, - int maxlen); +EXTERN int TclBN_mp_toradix_n(const mp_int *a, char *str, + int radix, int maxlen); /* 47 */ -EXTERN int TclBN_mp_unsigned_bin_size(mp_int *a); +EXTERN int TclBN_mp_unsigned_bin_size(const mp_int *a); /* 48 */ EXTERN int TclBN_mp_xor(const mp_int *a, const mp_int *b, mp_int *c); @@ -300,7 +303,7 @@ EXTERN int TclBN_mp_set_int(mp_int *a, unsigned long i); /* 63 */ EXTERN int TclBN_mp_cnt_lsb(const mp_int *a); /* 64 */ -TCL_DEPRECATED("Use mp_init() + mp_set_long() or mp_set_long_long()") +TCL_DEPRECATED("Use mp_init() + mp_set_long_long()") void TclBNInitBignumFromLong(mp_int *bignum, long initVal); /* 65 */ TCL_DEPRECATED("Use mp_init() + mp_set_long_long()") @@ -317,6 +320,10 @@ EXTERN int TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, EXTERN int TclBN_mp_set_long_long(mp_int *a, Tcl_WideUInt i); /* 69 */ EXTERN Tcl_WideUInt TclBN_mp_get_long_long(const mp_int *a); +/* 70 */ +EXTERN int TclBN_mp_set_long(mp_int *a, unsigned long i); +/* 71 */ +EXTERN unsigned long TclBN_mp_get_long(const mp_int *a); typedef struct TclTomMathStubs { int magic; @@ -325,7 +332,7 @@ typedef struct TclTomMathStubs { int (*tclBN_epoch) (void); /* 0 */ int (*tclBN_revision) (void); /* 1 */ int (*tclBN_mp_add) (const mp_int *a, const mp_int *b, mp_int *c); /* 2 */ - int (*tclBN_mp_add_d) (mp_int *a, mp_digit b, mp_int *c); /* 3 */ + int (*tclBN_mp_add_d) (const mp_int *a, mp_digit b, mp_int *c); /* 3 */ int (*tclBN_mp_and) (const mp_int *a, const mp_int *b, mp_int *c); /* 4 */ void (*tclBN_mp_clamp) (mp_int *a); /* 5 */ void (*tclBN_mp_clear) (mp_int *a); /* 6 */ @@ -365,11 +372,11 @@ typedef struct TclTomMathStubs { int (*tclBN_mp_sqr) (const mp_int *a, mp_int *b); /* 40 */ int (*tclBN_mp_sqrt) (const mp_int *a, mp_int *b); /* 41 */ int (*tclBN_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c); /* 42 */ - int (*tclBN_mp_sub_d) (mp_int *a, mp_digit b, mp_int *c); /* 43 */ - int (*tclBN_mp_to_unsigned_bin) (mp_int *a, unsigned char *b); /* 44 */ - int (*tclBN_mp_to_unsigned_bin_n) (mp_int *a, unsigned char *b, unsigned long *outlen); /* 45 */ - int (*tclBN_mp_toradix_n) (mp_int *a, char *str, int radix, int maxlen); /* 46 */ - int (*tclBN_mp_unsigned_bin_size) (mp_int *a); /* 47 */ + int (*tclBN_mp_sub_d) (const mp_int *a, mp_digit b, mp_int *c); /* 43 */ + int (*tclBN_mp_to_unsigned_bin) (const mp_int *a, unsigned char *b); /* 44 */ + int (*tclBN_mp_to_unsigned_bin_n) (const mp_int *a, unsigned char *b, unsigned long *outlen); /* 45 */ + int (*tclBN_mp_toradix_n) (const mp_int *a, char *str, int radix, int maxlen); /* 46 */ + int (*tclBN_mp_unsigned_bin_size) (const mp_int *a); /* 47 */ int (*tclBN_mp_xor) (const mp_int *a, const mp_int *b, mp_int *c); /* 48 */ void (*tclBN_mp_zero) (mp_int *a); /* 49 */ void (*tclBN_reverse) (unsigned char *s, int len); /* 50 */ @@ -386,12 +393,14 @@ typedef struct TclTomMathStubs { int (*tclBN_mp_init_set_int) (mp_int *a, unsigned long i); /* 61 */ int (*tclBN_mp_set_int) (mp_int *a, unsigned long i); /* 62 */ int (*tclBN_mp_cnt_lsb) (const mp_int *a); /* 63 */ - TCL_DEPRECATED_API("Use mp_init() + mp_set_long() or mp_set_long_long()") void (*tclBNInitBignumFromLong) (mp_int *bignum, long initVal); /* 64 */ + TCL_DEPRECATED_API("Use mp_init() + mp_set_long_long()") void (*tclBNInitBignumFromLong) (mp_int *bignum, long initVal); /* 64 */ TCL_DEPRECATED_API("Use mp_init() + mp_set_long_long()") void (*tclBNInitBignumFromWideInt) (mp_int *bignum, Tcl_WideInt initVal); /* 65 */ TCL_DEPRECATED_API("Use mp_init() + mp_set_long_long()") void (*tclBNInitBignumFromWideUInt) (mp_int *bignum, Tcl_WideUInt initVal); /* 66 */ int (*tclBN_mp_expt_d_ex) (const mp_int *a, mp_digit b, mp_int *c, int fast); /* 67 */ int (*tclBN_mp_set_long_long) (mp_int *a, Tcl_WideUInt i); /* 68 */ Tcl_WideUInt (*tclBN_mp_get_long_long) (const mp_int *a); /* 69 */ + int (*tclBN_mp_set_long) (mp_int *a, unsigned long i); /* 70 */ + unsigned long (*tclBN_mp_get_long) (const mp_int *a); /* 71 */ } TclTomMathStubs; extern const TclTomMathStubs *tclTomMathStubsPtr; @@ -546,6 +555,10 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; (tclTomMathStubsPtr->tclBN_mp_set_long_long) /* 68 */ #define TclBN_mp_get_long_long \ (tclTomMathStubsPtr->tclBN_mp_get_long_long) /* 69 */ +#define TclBN_mp_set_long \ + (tclTomMathStubsPtr->tclBN_mp_set_long) /* 70 */ +#define TclBN_mp_get_long \ + (tclTomMathStubsPtr->tclBN_mp_get_long) /* 71 */ #endif /* defined(USE_TCL_STUBS) */ |