summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-08 14:15:13 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-08 14:15:13 (GMT)
commit72cd4c6a0763c30b3f3a4fceb1ed78ad63711cb5 (patch)
treecdcbe1f7914fe91fdc459bb357195d82514df01c /generic
parent86eedd9ac8aa6c202c941fe08d1ec6fd255f422f (diff)
downloadtcl-72cd4c6a0763c30b3f3a4fceb1ed78ad63711cb5.zip
tcl-72cd4c6a0763c30b3f3a4fceb1ed78ad63711cb5.tar.gz
tcl-72cd4c6a0763c30b3f3a4fceb1ed78ad63711cb5.tar.bz2
Add some more functions from libtommath for availability within Tcl (mainly the 'long long' variants). Add more 'const' keywords there too.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclStubInit.c2
-rw-r--r--generic/tclTomMath.decls11
-rw-r--r--generic/tclTomMath.h4
-rw-r--r--generic/tclTomMathDecls.h21
4 files changed, 30 insertions, 8 deletions
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index 8cc21aa..a2f1ed3 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -859,6 +859,8 @@ const TclTomMathStubs tclTomMathStubs = {
TclBNInitBignumFromWideInt, /* 65 */
TclBNInitBignumFromWideUInt, /* 66 */
TclBN_mp_expt_d_ex, /* 67 */
+ TclBN_mp_set_long_long, /* 68 */
+ TclBN_mp_get_long_long, /* 69 */
};
static const TclStubHooks tclStubHooks = {
diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls
index 74ccefc..c4299d0 100644
--- a/generic/tclTomMath.decls
+++ b/generic/tclTomMath.decls
@@ -69,7 +69,7 @@ declare 14 {
int TclBN_mp_div_d(mp_int *a, mp_digit b, mp_int *q, mp_digit *r)
}
declare 15 {
- int TclBN_mp_div_2(mp_int *a, mp_int *q)
+ int TclBN_mp_div_2(const mp_int *a, mp_int *q)
}
declare 16 {
int TclBN_mp_div_2d(const mp_int *a, int b, mp_int *q, mp_int *r)
@@ -117,7 +117,7 @@ declare 30 {
int TclBN_mp_mul_d(mp_int *a, mp_digit b, mp_int *p)
}
declare 31 {
- int TclBN_mp_mul_2(mp_int *a, mp_int *p)
+ int TclBN_mp_mul_2(const mp_int *a, mp_int *p)
}
declare 32 {
int TclBN_mp_mul_2d(const mp_int *a, int d, mp_int *p)
@@ -237,6 +237,13 @@ declare 66 {
declare 67 {
int TclBN_mp_expt_d_ex(mp_int *a, mp_digit b, mp_int *c, int fast)
}
+# Added in libtommath 1.0.1
+declare 68 {
+ int TclBN_mp_set_long_long(mp_int *a, Tcl_WideUInt i)
+}
+declare 69 {
+ Tcl_WideUInt TclBN_mp_get_long_long(const mp_int *a)
+}
# Local Variables:
# mode: tcl
diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h
index 508fadd..7e3c29e 100644
--- a/generic/tclTomMath.h
+++ b/generic/tclTomMath.h
@@ -273,7 +273,7 @@ int mp_set_long(mp_int *a, unsigned long b);
/* set a platform dependent unsigned long long value */
/*
-int mp_set_long_long(mp_int *a, unsigned long long b);
+int mp_set_long_long(mp_int *a, Tcl_WideUInt b);
*/
/* get a 32-bit value */
@@ -288,7 +288,7 @@ unsigned long mp_get_long(const mp_int * a);
/* get a platform dependent unsigned long long value */
/*
-unsigned long long mp_get_long_long(const mp_int * a);
+Tcl_WideUInt mp_get_long_long(const mp_int * a);
*/
/* initialize and set a digit */
diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h
index 209c486..70de3b1 100644
--- a/generic/tclTomMathDecls.h
+++ b/generic/tclTomMathDecls.h
@@ -74,6 +74,8 @@
#define mp_exch TclBN_mp_exch
#define mp_expt_d TclBN_mp_expt_d
#define mp_expt_d_ex TclBN_mp_expt_d_ex
+#define mp_get_int TclBN_mp_get_int
+#define mp_get_long_long TclBN_mp_get_long_long
#define mp_grow TclBN_mp_grow
#define mp_init TclBN_mp_init
#define mp_init_copy TclBN_mp_init_copy
@@ -98,6 +100,7 @@
#define mp_s_rmap TclBNMpSRmap
#define mp_set TclBN_mp_set
#define mp_set_int TclBN_mp_set_int
+#define mp_set_long_long TclBN_mp_set_long_long
#define mp_shrink TclBN_mp_shrink
#define mp_sqr TclBN_mp_sqr
#define mp_sqrt TclBN_mp_sqrt
@@ -176,7 +179,7 @@ EXTERN int TclBN_mp_div(mp_int *a, mp_int *b, mp_int *q,
EXTERN int TclBN_mp_div_d(mp_int *a, mp_digit b, mp_int *q,
mp_digit *r);
/* 15 */
-EXTERN int TclBN_mp_div_2(mp_int *a, mp_int *q);
+EXTERN int TclBN_mp_div_2(const mp_int *a, mp_int *q);
/* 16 */
EXTERN int TclBN_mp_div_2d(const mp_int *a, int b, mp_int *q,
mp_int *r);
@@ -209,7 +212,7 @@ EXTERN int TclBN_mp_mul(mp_int *a, mp_int *b, mp_int *p);
/* 30 */
EXTERN int TclBN_mp_mul_d(mp_int *a, mp_digit b, mp_int *p);
/* 31 */
-EXTERN int TclBN_mp_mul_2(mp_int *a, mp_int *p);
+EXTERN int TclBN_mp_mul_2(const mp_int *a, mp_int *p);
/* 32 */
EXTERN int TclBN_mp_mul_2d(const mp_int *a, int d, mp_int *p);
/* 33 */
@@ -292,6 +295,10 @@ EXTERN void TclBNInitBignumFromWideUInt(mp_int *bignum,
/* 67 */
EXTERN int TclBN_mp_expt_d_ex(mp_int *a, mp_digit b, mp_int *c,
int fast);
+/* 68 */
+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);
typedef struct TclTomMathStubs {
int magic;
@@ -312,7 +319,7 @@ typedef struct TclTomMathStubs {
int (*tclBN_mp_count_bits) (const mp_int *a); /* 12 */
int (*tclBN_mp_div) (mp_int *a, mp_int *b, mp_int *q, mp_int *r); /* 13 */
int (*tclBN_mp_div_d) (mp_int *a, mp_digit b, mp_int *q, mp_digit *r); /* 14 */
- int (*tclBN_mp_div_2) (mp_int *a, mp_int *q); /* 15 */
+ int (*tclBN_mp_div_2) (const mp_int *a, mp_int *q); /* 15 */
int (*tclBN_mp_div_2d) (const mp_int *a, int b, mp_int *q, mp_int *r); /* 16 */
int (*tclBN_mp_div_3) (mp_int *a, mp_int *q, mp_digit *r); /* 17 */
void (*tclBN_mp_exch) (mp_int *a, mp_int *b); /* 18 */
@@ -328,7 +335,7 @@ typedef struct TclTomMathStubs {
int (*tclBN_mp_mod_2d) (const mp_int *a, int b, mp_int *r); /* 28 */
int (*tclBN_mp_mul) (mp_int *a, mp_int *b, mp_int *p); /* 29 */
int (*tclBN_mp_mul_d) (mp_int *a, mp_digit b, mp_int *p); /* 30 */
- int (*tclBN_mp_mul_2) (mp_int *a, mp_int *p); /* 31 */
+ int (*tclBN_mp_mul_2) (const mp_int *a, mp_int *p); /* 31 */
int (*tclBN_mp_mul_2d) (const mp_int *a, int d, mp_int *p); /* 32 */
int (*tclBN_mp_neg) (const mp_int *a, mp_int *b); /* 33 */
int (*tclBN_mp_or) (mp_int *a, mp_int *b, mp_int *c); /* 34 */
@@ -365,6 +372,8 @@ typedef struct TclTomMathStubs {
void (*tclBNInitBignumFromWideInt) (mp_int *bignum, Tcl_WideInt initVal); /* 65 */
void (*tclBNInitBignumFromWideUInt) (mp_int *bignum, Tcl_WideUInt initVal); /* 66 */
int (*tclBN_mp_expt_d_ex) (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 */
} TclTomMathStubs;
extern const TclTomMathStubs *tclTomMathStubsPtr;
@@ -515,6 +524,10 @@ extern const TclTomMathStubs *tclTomMathStubsPtr;
(tclTomMathStubsPtr->tclBNInitBignumFromWideUInt) /* 66 */
#define TclBN_mp_expt_d_ex \
(tclTomMathStubsPtr->tclBN_mp_expt_d_ex) /* 67 */
+#define TclBN_mp_set_long_long \
+ (tclTomMathStubsPtr->tclBN_mp_set_long_long) /* 68 */
+#define TclBN_mp_get_long_long \
+ (tclTomMathStubsPtr->tclBN_mp_get_long_long) /* 69 */
#endif /* defined(USE_TCL_STUBS) */