comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/tclTomMathDecls.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
comparison
equal deleted inserted replaced
67:0e9998148a16 69:33d812a61356
1 /*
2 *----------------------------------------------------------------------
3 *
4 * tclTomMathDecls.h --
5 *
6 * This file contains the declarations for the 'libtommath'
7 * functions that are exported by the Tcl library.
8 *
9 * Copyright (c) 2005 by Kevin B. Kenny. All rights reserved.
10 *
11 * See the file "license.terms" for information on usage and redistribution
12 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 */
14
15 #ifndef _TCLTOMMATHDECLS
16 #define _TCLTOMMATHDECLS
17
18 #include "tcl.h"
19 #ifndef BN_H_
20 #include "tclTomMath.h"
21 #endif
22
23 /*
24 * Define the version of the Stubs table that's exported for tommath
25 */
26
27 #define TCLTOMMATH_EPOCH 0
28 #define TCLTOMMATH_REVISION 0
29
30 #define Tcl_TomMath_InitStubs(interp,version) \
31 (TclTomMathInitializeStubs((interp),(version),\
32 TCLTOMMATH_EPOCH,TCLTOMMATH_REVISION))
33
34 /* Define custom memory allocation for libtommath */
35
36 /* MODULE_SCOPE void* TclBNAlloc( size_t ); */
37 #define TclBNAlloc(s) ((void*)ckalloc((size_t)(s)))
38 /* MODULE_SCOPE void* TclBNCalloc( size_t, size_t ); */
39 #define TclBNCalloc(m,s) memset(ckalloc((size_t)(m)*(size_t)(s)),0,(size_t)(m)*(size_t)(s))
40 /* MODULE_SCOPE void* TclBNRealloc( void*, size_t ); */
41 #define TclBNRealloc(x,s) ((void*)ckrealloc((char*)(x),(size_t)(s)))
42 /* MODULE_SCOPE void TclBNFree( void* ); */
43 #define TclBNFree(x) (ckfree((char*)(x)))
44
45 #define MP_MALLOC(size) TclBNAlloc(size)
46 #define MP_CALLOC(nmemb, size) TclBNCalloc(nmemb, size)
47 #define MP_REALLOC(mem, oldsize, newsize) TclBNRealloc(mem, newsize)
48 #define MP_FREE(mem, size) TclBNFree(mem)
49
50
51 /* Rename the global symbols in libtommath to avoid linkage conflicts */
52
53 #define bn_reverse TclBN_reverse
54 #define mp_add TclBN_mp_add
55 #define mp_add_d TclBN_mp_add_d
56 #define mp_and TclBN_mp_and
57 #define mp_clamp TclBN_mp_clamp
58 #define mp_clear TclBN_mp_clear
59 #define mp_clear_multi TclBN_mp_clear_multi
60 #define mp_cmp TclBN_mp_cmp
61 #define mp_cmp_d TclBN_mp_cmp_d
62 #define mp_cmp_mag TclBN_mp_cmp_mag
63 #define mp_cnt_lsb TclBN_mp_cnt_lsb
64 #define mp_copy TclBN_mp_copy
65 #define mp_count_bits TclBN_mp_count_bits
66 #define mp_div TclBN_mp_div
67 #define mp_div_2 TclBN_mp_div_2
68 #define mp_div_2d TclBN_mp_div_2d
69 #define mp_div_3 TclBN_mp_div_3
70 #define mp_div_d TclBN_mp_div_d
71 #define mp_exch TclBN_mp_exch
72 #define mp_expt_d TclBN_mp_expt_d
73 #define mp_expt_d_ex TclBN_mp_expt_d_ex
74 #define mp_expt_u32 TclBN_mp_expt_d
75 #define mp_get_mag_ull TclBN_mp_get_mag_ull
76 #define mp_grow TclBN_mp_grow
77 #define mp_init TclBN_mp_init
78 #define mp_init_copy TclBN_mp_init_copy
79 #define mp_init_multi TclBN_mp_init_multi
80 #define mp_init_set TclBN_mp_init_set
81 #define mp_init_set_int TclBN_mp_init_set_int
82 #define mp_init_size TclBN_mp_init_size
83 #define mp_lshd TclBN_mp_lshd
84 #define mp_mod TclBN_mp_mod
85 #define mp_mod_2d TclBN_mp_mod_2d
86 #define mp_mul TclBN_mp_mul
87 #define mp_mul_2 TclBN_mp_mul_2
88 #define mp_mul_2d TclBN_mp_mul_2d
89 #define mp_mul_d TclBN_mp_mul_d
90 #define mp_neg TclBN_mp_neg
91 #define mp_or TclBN_mp_or
92 #define mp_radix_size TclBN_mp_radix_size
93 #define mp_read_radix TclBN_mp_read_radix
94 #define mp_rshd TclBN_mp_rshd
95 #define mp_set TclBN_mp_set
96 #define mp_set_int(a,b) (TclBN_mp_set_int(a,(unsigned int)(b)),MP_OKAY)
97 #define mp_set_ll TclBN_mp_set_ll
98 #define mp_set_long(a,b) (TclBN_mp_set_int(a,b),MP_OKAY)
99 #define mp_set_ul(a,b) (void)TclBN_mp_set_int(a,b)
100 #define mp_set_ull TclBN_mp_set_ull
101 #define mp_set_u64 TclBN_mp_set_ull
102 #define mp_shrink TclBN_mp_shrink
103 #define mp_sqr TclBN_mp_sqr
104 #define mp_sqrt TclBN_mp_sqrt
105 #define mp_sub TclBN_mp_sub
106 #define mp_sub_d TclBN_mp_sub_d
107 #define mp_signed_rsh TclBN_mp_signed_rsh
108 #define mp_tc_and TclBN_mp_and
109 #define mp_tc_div_2d TclBN_mp_signed_rsh
110 #define mp_tc_or TclBN_mp_or
111 #define mp_tc_xor TclBN_mp_xor
112 #define mp_to_unsigned_bin TclBN_mp_to_unsigned_bin
113 #define mp_to_unsigned_bin_n TclBN_mp_to_unsigned_bin_n
114 #define mp_toradix_n TclBN_mp_toradix_n
115 #define mp_to_radix TclBN_mp_to_radix
116 #define mp_to_ubin TclBN_mp_to_ubin
117 #define mp_ubin_size TclBN_mp_unsigned_bin_size
118 #define mp_unsigned_bin_size(a) ((int)TclBN_mp_unsigned_bin_size(a))
119 #define mp_xor TclBN_mp_xor
120 #define mp_zero TclBN_mp_zero
121 #define s_mp_add TclBN_s_mp_add
122 #define s_mp_balance_mul TclBN_mp_balance_mul
123 #define s_mp_karatsuba_mul TclBN_mp_karatsuba_mul
124 #define s_mp_karatsuba_sqr TclBN_mp_karatsuba_sqr
125 #define s_mp_mul_digs TclBN_s_mp_mul_digs
126 #define s_mp_mul_digs_fast TclBN_fast_s_mp_mul_digs
127 #define s_mp_reverse TclBN_s_mp_reverse
128 #define s_mp_sqr TclBN_s_mp_sqr
129 #define s_mp_sqr_fast TclBN_fast_s_mp_sqr
130 #define s_mp_sub TclBN_s_mp_sub
131 #define s_mp_toom_mul TclBN_mp_toom_mul
132 #define s_mp_toom_sqr TclBN_mp_toom_sqr
133
134 #undef TCL_STORAGE_CLASS
135 #ifdef BUILD_tcl
136 # define TCL_STORAGE_CLASS DLLEXPORT
137 #else
138 # ifdef USE_TCL_STUBS
139 # define TCL_STORAGE_CLASS
140 # else
141 # define TCL_STORAGE_CLASS DLLIMPORT
142 # endif
143 #endif
144
145 /*
146 * WARNING: This file is automatically generated by the tools/genStubs.tcl
147 * script. Any modifications to the function declarations below should be made
148 * in the generic/tclInt.decls script.
149 */
150
151 /* !BEGIN!: Do not edit below this line. */
152
153 #ifdef __cplusplus
154 extern "C" {
155 #endif
156
157 /*
158 * Exported function declarations:
159 */
160
161 /* 0 */
162 EXTERN int TclBN_epoch(void);
163 /* 1 */
164 EXTERN int TclBN_revision(void);
165 /* 2 */
166 EXTERN mp_err TclBN_mp_add(const mp_int *a, const mp_int *b,
167 mp_int *c);
168 /* 3 */
169 EXTERN mp_err TclBN_mp_add_d(const mp_int *a, mp_digit b,
170 mp_int *c);
171 /* 4 */
172 EXTERN mp_err TclBN_mp_and(const mp_int *a, const mp_int *b,
173 mp_int *c);
174 /* 5 */
175 EXTERN void TclBN_mp_clamp(mp_int *a);
176 /* 6 */
177 EXTERN void TclBN_mp_clear(mp_int *a);
178 /* 7 */
179 EXTERN void TclBN_mp_clear_multi(mp_int *a, ...);
180 /* 8 */
181 EXTERN mp_ord TclBN_mp_cmp(const mp_int *a, const mp_int *b);
182 /* 9 */
183 EXTERN mp_ord TclBN_mp_cmp_d(const mp_int *a, mp_digit b);
184 /* 10 */
185 EXTERN mp_ord TclBN_mp_cmp_mag(const mp_int *a, const mp_int *b);
186 /* 11 */
187 EXTERN mp_err TclBN_mp_copy(const mp_int *a, mp_int *b);
188 /* 12 */
189 EXTERN int TclBN_mp_count_bits(const mp_int *a);
190 /* 13 */
191 EXTERN mp_err TclBN_mp_div(const mp_int *a, const mp_int *b,
192 mp_int *q, mp_int *r);
193 /* 14 */
194 EXTERN mp_err TclBN_mp_div_d(const mp_int *a, mp_digit b,
195 mp_int *q, mp_digit *r);
196 /* 15 */
197 EXTERN mp_err TclBN_mp_div_2(const mp_int *a, mp_int *q);
198 /* 16 */
199 EXTERN mp_err TclBN_mp_div_2d(const mp_int *a, int b, mp_int *q,
200 mp_int *r);
201 /* 17 */
202 EXTERN mp_err TclBN_mp_div_3(const mp_int *a, mp_int *q,
203 mp_digit *r);
204 /* 18 */
205 EXTERN void TclBN_mp_exch(mp_int *a, mp_int *b);
206 /* 19 */
207 EXTERN mp_err TclBN_mp_expt_d(const mp_int *a, unsigned int b,
208 mp_int *c);
209 /* 20 */
210 EXTERN mp_err TclBN_mp_grow(mp_int *a, int size);
211 /* 21 */
212 EXTERN mp_err TclBN_mp_init(mp_int *a);
213 /* 22 */
214 EXTERN mp_err TclBN_mp_init_copy(mp_int *a, const mp_int *b);
215 /* 23 */
216 EXTERN mp_err TclBN_mp_init_multi(mp_int *a, ...);
217 /* 24 */
218 EXTERN mp_err TclBN_mp_init_set(mp_int *a, mp_digit b);
219 /* 25 */
220 EXTERN mp_err TclBN_mp_init_size(mp_int *a, int size);
221 /* 26 */
222 EXTERN mp_err TclBN_mp_lshd(mp_int *a, int shift);
223 /* 27 */
224 EXTERN mp_err TclBN_mp_mod(const mp_int *a, const mp_int *b,
225 mp_int *r);
226 /* 28 */
227 EXTERN mp_err TclBN_mp_mod_2d(const mp_int *a, int b, mp_int *r);
228 /* 29 */
229 EXTERN mp_err TclBN_mp_mul(const mp_int *a, const mp_int *b,
230 mp_int *p);
231 /* 30 */
232 EXTERN mp_err TclBN_mp_mul_d(const mp_int *a, mp_digit b,
233 mp_int *p);
234 /* 31 */
235 EXTERN mp_err TclBN_mp_mul_2(const mp_int *a, mp_int *p);
236 /* 32 */
237 EXTERN mp_err TclBN_mp_mul_2d(const mp_int *a, int d, mp_int *p);
238 /* 33 */
239 EXTERN mp_err TclBN_mp_neg(const mp_int *a, mp_int *b);
240 /* 34 */
241 EXTERN mp_err TclBN_mp_or(const mp_int *a, const mp_int *b,
242 mp_int *c);
243 /* 35 */
244 EXTERN mp_err TclBN_mp_radix_size(const mp_int *a, int radix,
245 int *size);
246 /* 36 */
247 EXTERN mp_err TclBN_mp_read_radix(mp_int *a, const char *str,
248 int radix);
249 /* 37 */
250 EXTERN void TclBN_mp_rshd(mp_int *a, int shift);
251 /* 38 */
252 EXTERN mp_err TclBN_mp_shrink(mp_int *a);
253 /* 39 */
254 EXTERN void TclBN_mp_set(mp_int *a, mp_digit b);
255 /* 40 */
256 EXTERN mp_err TclBN_mp_sqr(const mp_int *a, mp_int *b);
257 /* 41 */
258 EXTERN mp_err TclBN_mp_sqrt(const mp_int *a, mp_int *b);
259 /* 42 */
260 EXTERN mp_err TclBN_mp_sub(const mp_int *a, const mp_int *b,
261 mp_int *c);
262 /* 43 */
263 EXTERN mp_err TclBN_mp_sub_d(const mp_int *a, mp_digit b,
264 mp_int *c);
265 /* 44 */
266 EXTERN mp_err TclBN_mp_to_unsigned_bin(const mp_int *a,
267 unsigned char *b);
268 /* 45 */
269 EXTERN mp_err TclBN_mp_to_unsigned_bin_n(const mp_int *a,
270 unsigned char *b, unsigned long *outlen);
271 /* 46 */
272 EXTERN mp_err TclBN_mp_toradix_n(const mp_int *a, char *str,
273 int radix, int maxlen);
274 /* 47 */
275 EXTERN size_t TclBN_mp_unsigned_bin_size(const mp_int *a);
276 /* 48 */
277 EXTERN mp_err TclBN_mp_xor(const mp_int *a, const mp_int *b,
278 mp_int *c);
279 /* 49 */
280 EXTERN void TclBN_mp_zero(mp_int *a);
281 /* 50 */
282 EXTERN void TclBN_reverse(unsigned char *s, int len);
283 /* 51 */
284 EXTERN mp_err TclBN_fast_s_mp_mul_digs(const mp_int *a,
285 const mp_int *b, mp_int *c, int digs);
286 /* 52 */
287 EXTERN mp_err TclBN_fast_s_mp_sqr(const mp_int *a, mp_int *b);
288 /* 53 */
289 EXTERN mp_err TclBN_mp_karatsuba_mul(const mp_int *a,
290 const mp_int *b, mp_int *c);
291 /* 54 */
292 EXTERN mp_err TclBN_mp_karatsuba_sqr(const mp_int *a, mp_int *b);
293 /* 55 */
294 EXTERN mp_err TclBN_mp_toom_mul(const mp_int *a, const mp_int *b,
295 mp_int *c);
296 /* 56 */
297 EXTERN mp_err TclBN_mp_toom_sqr(const mp_int *a, mp_int *b);
298 /* 57 */
299 EXTERN mp_err TclBN_s_mp_add(const mp_int *a, const mp_int *b,
300 mp_int *c);
301 /* 58 */
302 EXTERN mp_err TclBN_s_mp_mul_digs(const mp_int *a, const mp_int *b,
303 mp_int *c, int digs);
304 /* 59 */
305 EXTERN mp_err TclBN_s_mp_sqr(const mp_int *a, mp_int *b);
306 /* 60 */
307 EXTERN mp_err TclBN_s_mp_sub(const mp_int *a, const mp_int *b,
308 mp_int *c);
309 /* 61 */
310 EXTERN mp_err TclBN_mp_init_set_int(mp_int *a, unsigned long i);
311 /* 62 */
312 EXTERN mp_err TclBN_mp_set_int(mp_int *a, unsigned long i);
313 /* 63 */
314 EXTERN int TclBN_mp_cnt_lsb(const mp_int *a);
315 /* 64 */
316 EXTERN int TclBNInitBignumFromLong(mp_int *bignum, long initVal);
317 /* 65 */
318 EXTERN int TclBNInitBignumFromWideInt(mp_int *bignum,
319 Tcl_WideInt initVal);
320 /* 66 */
321 EXTERN int TclBNInitBignumFromWideUInt(mp_int *bignum,
322 Tcl_WideUInt initVal);
323 /* 67 */
324 EXTERN mp_err TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b,
325 mp_int *c, int fast);
326 /* 68 */
327 EXTERN void TclBN_mp_set_ull(mp_int *a, Tcl_WideUInt i);
328 /* 69 */
329 EXTERN Tcl_WideUInt TclBN_mp_get_mag_ull(const mp_int *a);
330 /* 70 */
331 EXTERN void TclBN_mp_set_ll(mp_int *a, Tcl_WideInt i);
332 /* Slot 71 is reserved */
333 /* Slot 72 is reserved */
334 /* 73 */
335 EXTERN mp_err TclBN_mp_tc_and(const mp_int *a, const mp_int *b,
336 mp_int *c);
337 /* 74 */
338 EXTERN mp_err TclBN_mp_tc_or(const mp_int *a, const mp_int *b,
339 mp_int *c);
340 /* 75 */
341 EXTERN mp_err TclBN_mp_tc_xor(const mp_int *a, const mp_int *b,
342 mp_int *c);
343 /* 76 */
344 EXTERN mp_err TclBN_mp_signed_rsh(const mp_int *a, int b,
345 mp_int *c);
346 /* Slot 77 is reserved */
347 /* 78 */
348 EXTERN int TclBN_mp_to_ubin(const mp_int *a, unsigned char *buf,
349 size_t maxlen, size_t *written);
350 /* 79 */
351 EXTERN mp_err TclBN_mp_div_ld(const mp_int *a, Tcl_WideUInt b,
352 mp_int *q, Tcl_WideUInt *r);
353 /* 80 */
354 EXTERN int TclBN_mp_to_radix(const mp_int *a, char *str,
355 size_t maxlen, size_t *written, int radix);
356
357 typedef struct TclTomMathStubs {
358 int magic;
359 void *hooks;
360
361 int (*tclBN_epoch) (void); /* 0 */
362 int (*tclBN_revision) (void); /* 1 */
363 mp_err (*tclBN_mp_add) (const mp_int *a, const mp_int *b, mp_int *c); /* 2 */
364 mp_err (*tclBN_mp_add_d) (const mp_int *a, mp_digit b, mp_int *c); /* 3 */
365 mp_err (*tclBN_mp_and) (const mp_int *a, const mp_int *b, mp_int *c); /* 4 */
366 void (*tclBN_mp_clamp) (mp_int *a); /* 5 */
367 void (*tclBN_mp_clear) (mp_int *a); /* 6 */
368 void (*tclBN_mp_clear_multi) (mp_int *a, ...); /* 7 */
369 mp_ord (*tclBN_mp_cmp) (const mp_int *a, const mp_int *b); /* 8 */
370 mp_ord (*tclBN_mp_cmp_d) (const mp_int *a, mp_digit b); /* 9 */
371 mp_ord (*tclBN_mp_cmp_mag) (const mp_int *a, const mp_int *b); /* 10 */
372 mp_err (*tclBN_mp_copy) (const mp_int *a, mp_int *b); /* 11 */
373 int (*tclBN_mp_count_bits) (const mp_int *a); /* 12 */
374 mp_err (*tclBN_mp_div) (const mp_int *a, const mp_int *b, mp_int *q, mp_int *r); /* 13 */
375 mp_err (*tclBN_mp_div_d) (const mp_int *a, mp_digit b, mp_int *q, mp_digit *r); /* 14 */
376 mp_err (*tclBN_mp_div_2) (const mp_int *a, mp_int *q); /* 15 */
377 mp_err (*tclBN_mp_div_2d) (const mp_int *a, int b, mp_int *q, mp_int *r); /* 16 */
378 mp_err (*tclBN_mp_div_3) (const mp_int *a, mp_int *q, mp_digit *r); /* 17 */
379 void (*tclBN_mp_exch) (mp_int *a, mp_int *b); /* 18 */
380 mp_err (*tclBN_mp_expt_d) (const mp_int *a, unsigned int b, mp_int *c); /* 19 */
381 mp_err (*tclBN_mp_grow) (mp_int *a, int size); /* 20 */
382 mp_err (*tclBN_mp_init) (mp_int *a); /* 21 */
383 mp_err (*tclBN_mp_init_copy) (mp_int *a, const mp_int *b); /* 22 */
384 mp_err (*tclBN_mp_init_multi) (mp_int *a, ...); /* 23 */
385 mp_err (*tclBN_mp_init_set) (mp_int *a, mp_digit b); /* 24 */
386 mp_err (*tclBN_mp_init_size) (mp_int *a, int size); /* 25 */
387 mp_err (*tclBN_mp_lshd) (mp_int *a, int shift); /* 26 */
388 mp_err (*tclBN_mp_mod) (const mp_int *a, const mp_int *b, mp_int *r); /* 27 */
389 mp_err (*tclBN_mp_mod_2d) (const mp_int *a, int b, mp_int *r); /* 28 */
390 mp_err (*tclBN_mp_mul) (const mp_int *a, const mp_int *b, mp_int *p); /* 29 */
391 mp_err (*tclBN_mp_mul_d) (const mp_int *a, mp_digit b, mp_int *p); /* 30 */
392 mp_err (*tclBN_mp_mul_2) (const mp_int *a, mp_int *p); /* 31 */
393 mp_err (*tclBN_mp_mul_2d) (const mp_int *a, int d, mp_int *p); /* 32 */
394 mp_err (*tclBN_mp_neg) (const mp_int *a, mp_int *b); /* 33 */
395 mp_err (*tclBN_mp_or) (const mp_int *a, const mp_int *b, mp_int *c); /* 34 */
396 mp_err (*tclBN_mp_radix_size) (const mp_int *a, int radix, int *size); /* 35 */
397 mp_err (*tclBN_mp_read_radix) (mp_int *a, const char *str, int radix); /* 36 */
398 void (*tclBN_mp_rshd) (mp_int *a, int shift); /* 37 */
399 mp_err (*tclBN_mp_shrink) (mp_int *a); /* 38 */
400 void (*tclBN_mp_set) (mp_int *a, mp_digit b); /* 39 */
401 mp_err (*tclBN_mp_sqr) (const mp_int *a, mp_int *b); /* 40 */
402 mp_err (*tclBN_mp_sqrt) (const mp_int *a, mp_int *b); /* 41 */
403 mp_err (*tclBN_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c); /* 42 */
404 mp_err (*tclBN_mp_sub_d) (const mp_int *a, mp_digit b, mp_int *c); /* 43 */
405 mp_err (*tclBN_mp_to_unsigned_bin) (const mp_int *a, unsigned char *b); /* 44 */
406 mp_err (*tclBN_mp_to_unsigned_bin_n) (const mp_int *a, unsigned char *b, unsigned long *outlen); /* 45 */
407 mp_err (*tclBN_mp_toradix_n) (const mp_int *a, char *str, int radix, int maxlen); /* 46 */
408 size_t (*tclBN_mp_unsigned_bin_size) (const mp_int *a); /* 47 */
409 mp_err (*tclBN_mp_xor) (const mp_int *a, const mp_int *b, mp_int *c); /* 48 */
410 void (*tclBN_mp_zero) (mp_int *a); /* 49 */
411 void (*tclBN_reverse) (unsigned char *s, int len); /* 50 */
412 mp_err (*tclBN_fast_s_mp_mul_digs) (const mp_int *a, const mp_int *b, mp_int *c, int digs); /* 51 */
413 mp_err (*tclBN_fast_s_mp_sqr) (const mp_int *a, mp_int *b); /* 52 */
414 mp_err (*tclBN_mp_karatsuba_mul) (const mp_int *a, const mp_int *b, mp_int *c); /* 53 */
415 mp_err (*tclBN_mp_karatsuba_sqr) (const mp_int *a, mp_int *b); /* 54 */
416 mp_err (*tclBN_mp_toom_mul) (const mp_int *a, const mp_int *b, mp_int *c); /* 55 */
417 mp_err (*tclBN_mp_toom_sqr) (const mp_int *a, mp_int *b); /* 56 */
418 mp_err (*tclBN_s_mp_add) (const mp_int *a, const mp_int *b, mp_int *c); /* 57 */
419 mp_err (*tclBN_s_mp_mul_digs) (const mp_int *a, const mp_int *b, mp_int *c, int digs); /* 58 */
420 mp_err (*tclBN_s_mp_sqr) (const mp_int *a, mp_int *b); /* 59 */
421 mp_err (*tclBN_s_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c); /* 60 */
422 mp_err (*tclBN_mp_init_set_int) (mp_int *a, unsigned long i); /* 61 */
423 mp_err (*tclBN_mp_set_int) (mp_int *a, unsigned long i); /* 62 */
424 int (*tclBN_mp_cnt_lsb) (const mp_int *a); /* 63 */
425 int (*tclBNInitBignumFromLong) (mp_int *bignum, long initVal); /* 64 */
426 int (*tclBNInitBignumFromWideInt) (mp_int *bignum, Tcl_WideInt initVal); /* 65 */
427 int (*tclBNInitBignumFromWideUInt) (mp_int *bignum, Tcl_WideUInt initVal); /* 66 */
428 mp_err (*tclBN_mp_expt_d_ex) (const mp_int *a, mp_digit b, mp_int *c, int fast); /* 67 */
429 void (*tclBN_mp_set_ull) (mp_int *a, Tcl_WideUInt i); /* 68 */
430 Tcl_WideUInt (*tclBN_mp_get_mag_ull) (const mp_int *a); /* 69 */
431 void (*tclBN_mp_set_ll) (mp_int *a, Tcl_WideInt i); /* 70 */
432 void (*reserved71)(void);
433 void (*reserved72)(void);
434 mp_err (*tclBN_mp_tc_and) (const mp_int *a, const mp_int *b, mp_int *c); /* 73 */
435 mp_err (*tclBN_mp_tc_or) (const mp_int *a, const mp_int *b, mp_int *c); /* 74 */
436 mp_err (*tclBN_mp_tc_xor) (const mp_int *a, const mp_int *b, mp_int *c); /* 75 */
437 mp_err (*tclBN_mp_signed_rsh) (const mp_int *a, int b, mp_int *c); /* 76 */
438 void (*reserved77)(void);
439 int (*tclBN_mp_to_ubin) (const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written); /* 78 */
440 mp_err (*tclBN_mp_div_ld) (const mp_int *a, Tcl_WideUInt b, mp_int *q, Tcl_WideUInt *r); /* 79 */
441 int (*tclBN_mp_to_radix) (const mp_int *a, char *str, size_t maxlen, size_t *written, int radix); /* 80 */
442 } TclTomMathStubs;
443
444 extern const TclTomMathStubs *tclTomMathStubsPtr;
445
446 #ifdef __cplusplus
447 }
448 #endif
449
450 #if defined(USE_TCL_STUBS)
451
452 /*
453 * Inline function declarations:
454 */
455
456 #define TclBN_epoch \
457 (tclTomMathStubsPtr->tclBN_epoch) /* 0 */
458 #define TclBN_revision \
459 (tclTomMathStubsPtr->tclBN_revision) /* 1 */
460 #define TclBN_mp_add \
461 (tclTomMathStubsPtr->tclBN_mp_add) /* 2 */
462 #define TclBN_mp_add_d \
463 (tclTomMathStubsPtr->tclBN_mp_add_d) /* 3 */
464 #define TclBN_mp_and \
465 (tclTomMathStubsPtr->tclBN_mp_and) /* 4 */
466 #define TclBN_mp_clamp \
467 (tclTomMathStubsPtr->tclBN_mp_clamp) /* 5 */
468 #define TclBN_mp_clear \
469 (tclTomMathStubsPtr->tclBN_mp_clear) /* 6 */
470 #define TclBN_mp_clear_multi \
471 (tclTomMathStubsPtr->tclBN_mp_clear_multi) /* 7 */
472 #define TclBN_mp_cmp \
473 (tclTomMathStubsPtr->tclBN_mp_cmp) /* 8 */
474 #define TclBN_mp_cmp_d \
475 (tclTomMathStubsPtr->tclBN_mp_cmp_d) /* 9 */
476 #define TclBN_mp_cmp_mag \
477 (tclTomMathStubsPtr->tclBN_mp_cmp_mag) /* 10 */
478 #define TclBN_mp_copy \
479 (tclTomMathStubsPtr->tclBN_mp_copy) /* 11 */
480 #define TclBN_mp_count_bits \
481 (tclTomMathStubsPtr->tclBN_mp_count_bits) /* 12 */
482 #define TclBN_mp_div \
483 (tclTomMathStubsPtr->tclBN_mp_div) /* 13 */
484 #define TclBN_mp_div_d \
485 (tclTomMathStubsPtr->tclBN_mp_div_d) /* 14 */
486 #define TclBN_mp_div_2 \
487 (tclTomMathStubsPtr->tclBN_mp_div_2) /* 15 */
488 #define TclBN_mp_div_2d \
489 (tclTomMathStubsPtr->tclBN_mp_div_2d) /* 16 */
490 #define TclBN_mp_div_3 \
491 (tclTomMathStubsPtr->tclBN_mp_div_3) /* 17 */
492 #define TclBN_mp_exch \
493 (tclTomMathStubsPtr->tclBN_mp_exch) /* 18 */
494 #define TclBN_mp_expt_d \
495 (tclTomMathStubsPtr->tclBN_mp_expt_d) /* 19 */
496 #define TclBN_mp_grow \
497 (tclTomMathStubsPtr->tclBN_mp_grow) /* 20 */
498 #define TclBN_mp_init \
499 (tclTomMathStubsPtr->tclBN_mp_init) /* 21 */
500 #define TclBN_mp_init_copy \
501 (tclTomMathStubsPtr->tclBN_mp_init_copy) /* 22 */
502 #define TclBN_mp_init_multi \
503 (tclTomMathStubsPtr->tclBN_mp_init_multi) /* 23 */
504 #define TclBN_mp_init_set \
505 (tclTomMathStubsPtr->tclBN_mp_init_set) /* 24 */
506 #define TclBN_mp_init_size \
507 (tclTomMathStubsPtr->tclBN_mp_init_size) /* 25 */
508 #define TclBN_mp_lshd \
509 (tclTomMathStubsPtr->tclBN_mp_lshd) /* 26 */
510 #define TclBN_mp_mod \
511 (tclTomMathStubsPtr->tclBN_mp_mod) /* 27 */
512 #define TclBN_mp_mod_2d \
513 (tclTomMathStubsPtr->tclBN_mp_mod_2d) /* 28 */
514 #define TclBN_mp_mul \
515 (tclTomMathStubsPtr->tclBN_mp_mul) /* 29 */
516 #define TclBN_mp_mul_d \
517 (tclTomMathStubsPtr->tclBN_mp_mul_d) /* 30 */
518 #define TclBN_mp_mul_2 \
519 (tclTomMathStubsPtr->tclBN_mp_mul_2) /* 31 */
520 #define TclBN_mp_mul_2d \
521 (tclTomMathStubsPtr->tclBN_mp_mul_2d) /* 32 */
522 #define TclBN_mp_neg \
523 (tclTomMathStubsPtr->tclBN_mp_neg) /* 33 */
524 #define TclBN_mp_or \
525 (tclTomMathStubsPtr->tclBN_mp_or) /* 34 */
526 #define TclBN_mp_radix_size \
527 (tclTomMathStubsPtr->tclBN_mp_radix_size) /* 35 */
528 #define TclBN_mp_read_radix \
529 (tclTomMathStubsPtr->tclBN_mp_read_radix) /* 36 */
530 #define TclBN_mp_rshd \
531 (tclTomMathStubsPtr->tclBN_mp_rshd) /* 37 */
532 #define TclBN_mp_shrink \
533 (tclTomMathStubsPtr->tclBN_mp_shrink) /* 38 */
534 #define TclBN_mp_set \
535 (tclTomMathStubsPtr->tclBN_mp_set) /* 39 */
536 #define TclBN_mp_sqr \
537 (tclTomMathStubsPtr->tclBN_mp_sqr) /* 40 */
538 #define TclBN_mp_sqrt \
539 (tclTomMathStubsPtr->tclBN_mp_sqrt) /* 41 */
540 #define TclBN_mp_sub \
541 (tclTomMathStubsPtr->tclBN_mp_sub) /* 42 */
542 #define TclBN_mp_sub_d \
543 (tclTomMathStubsPtr->tclBN_mp_sub_d) /* 43 */
544 #define TclBN_mp_to_unsigned_bin \
545 (tclTomMathStubsPtr->tclBN_mp_to_unsigned_bin) /* 44 */
546 #define TclBN_mp_to_unsigned_bin_n \
547 (tclTomMathStubsPtr->tclBN_mp_to_unsigned_bin_n) /* 45 */
548 #define TclBN_mp_toradix_n \
549 (tclTomMathStubsPtr->tclBN_mp_toradix_n) /* 46 */
550 #define TclBN_mp_unsigned_bin_size \
551 (tclTomMathStubsPtr->tclBN_mp_unsigned_bin_size) /* 47 */
552 #define TclBN_mp_xor \
553 (tclTomMathStubsPtr->tclBN_mp_xor) /* 48 */
554 #define TclBN_mp_zero \
555 (tclTomMathStubsPtr->tclBN_mp_zero) /* 49 */
556 #define TclBN_reverse \
557 (tclTomMathStubsPtr->tclBN_reverse) /* 50 */
558 #define TclBN_fast_s_mp_mul_digs \
559 (tclTomMathStubsPtr->tclBN_fast_s_mp_mul_digs) /* 51 */
560 #define TclBN_fast_s_mp_sqr \
561 (tclTomMathStubsPtr->tclBN_fast_s_mp_sqr) /* 52 */
562 #define TclBN_mp_karatsuba_mul \
563 (tclTomMathStubsPtr->tclBN_mp_karatsuba_mul) /* 53 */
564 #define TclBN_mp_karatsuba_sqr \
565 (tclTomMathStubsPtr->tclBN_mp_karatsuba_sqr) /* 54 */
566 #define TclBN_mp_toom_mul \
567 (tclTomMathStubsPtr->tclBN_mp_toom_mul) /* 55 */
568 #define TclBN_mp_toom_sqr \
569 (tclTomMathStubsPtr->tclBN_mp_toom_sqr) /* 56 */
570 #define TclBN_s_mp_add \
571 (tclTomMathStubsPtr->tclBN_s_mp_add) /* 57 */
572 #define TclBN_s_mp_mul_digs \
573 (tclTomMathStubsPtr->tclBN_s_mp_mul_digs) /* 58 */
574 #define TclBN_s_mp_sqr \
575 (tclTomMathStubsPtr->tclBN_s_mp_sqr) /* 59 */
576 #define TclBN_s_mp_sub \
577 (tclTomMathStubsPtr->tclBN_s_mp_sub) /* 60 */
578 #define TclBN_mp_init_set_int \
579 (tclTomMathStubsPtr->tclBN_mp_init_set_int) /* 61 */
580 #define TclBN_mp_set_int \
581 (tclTomMathStubsPtr->tclBN_mp_set_int) /* 62 */
582 #define TclBN_mp_cnt_lsb \
583 (tclTomMathStubsPtr->tclBN_mp_cnt_lsb) /* 63 */
584 #define TclBNInitBignumFromLong \
585 (tclTomMathStubsPtr->tclBNInitBignumFromLong) /* 64 */
586 #define TclBNInitBignumFromWideInt \
587 (tclTomMathStubsPtr->tclBNInitBignumFromWideInt) /* 65 */
588 #define TclBNInitBignumFromWideUInt \
589 (tclTomMathStubsPtr->tclBNInitBignumFromWideUInt) /* 66 */
590 #define TclBN_mp_expt_d_ex \
591 (tclTomMathStubsPtr->tclBN_mp_expt_d_ex) /* 67 */
592 #define TclBN_mp_set_ull \
593 (tclTomMathStubsPtr->tclBN_mp_set_ull) /* 68 */
594 #define TclBN_mp_get_mag_ull \
595 (tclTomMathStubsPtr->tclBN_mp_get_mag_ull) /* 69 */
596 #define TclBN_mp_set_ll \
597 (tclTomMathStubsPtr->tclBN_mp_set_ll) /* 70 */
598 /* Slot 71 is reserved */
599 /* Slot 72 is reserved */
600 #define TclBN_mp_tc_and \
601 (tclTomMathStubsPtr->tclBN_mp_tc_and) /* 73 */
602 #define TclBN_mp_tc_or \
603 (tclTomMathStubsPtr->tclBN_mp_tc_or) /* 74 */
604 #define TclBN_mp_tc_xor \
605 (tclTomMathStubsPtr->tclBN_mp_tc_xor) /* 75 */
606 #define TclBN_mp_signed_rsh \
607 (tclTomMathStubsPtr->tclBN_mp_signed_rsh) /* 76 */
608 /* Slot 77 is reserved */
609 #define TclBN_mp_to_ubin \
610 (tclTomMathStubsPtr->tclBN_mp_to_ubin) /* 78 */
611 #define TclBN_mp_div_ld \
612 (tclTomMathStubsPtr->tclBN_mp_div_ld) /* 79 */
613 #define TclBN_mp_to_radix \
614 (tclTomMathStubsPtr->tclBN_mp_to_radix) /* 80 */
615
616 #endif /* defined(USE_TCL_STUBS) */
617
618 /* !END!: Do not edit above this line. */
619
620 #undef TCL_STORAGE_CLASS
621 #define TCL_STORAGE_CLASS DLLIMPORT
622
623 #ifdef USE_TCL_STUBS
624 #undef TclBNInitBignumFromLong
625 #define TclBNInitBignumFromLong(a,b) \
626 do { \
627 (a)->dp = NULL; \
628 (void)tclTomMathStubsPtr->tclBNInitBignumFromLong((a),(b)); \
629 if ((a)->dp == NULL) { \
630 Tcl_Panic("initialization failure in TclBNInitBignumFromLong"); \
631 } \
632 } while (0)
633 #undef TclBNInitBignumFromWideInt
634 #define TclBNInitBignumFromWideInt(a,b) \
635 do { \
636 (a)->dp = NULL; \
637 (void)tclTomMathStubsPtr->tclBNInitBignumFromWideInt((a),(b)); \
638 if ((a)->dp == NULL) { \
639 Tcl_Panic("initialization failure in TclBNInitBignumFromWideInt"); \
640 } \
641 } while (0)
642 #undef TclBNInitBignumFromWideUInt
643 #define TclBNInitBignumFromWideUInt(a,b) \
644 do { \
645 (a)->dp = NULL; \
646 (void)tclTomMathStubsPtr->tclBNInitBignumFromWideUInt((a),(b)); \
647 if ((a)->dp == NULL) { \
648 Tcl_Panic("initialization failure in TclBNInitBignumFromWideUInt"); \
649 } \
650 } while (0)
651 #define mp_init_i32(a,b) (((a)->dp=NULL,tclTomMathStubsPtr->tclBNInitBignumFromLong((a),(int32_t)(b)),(a)->dp)?MP_OKAY:MP_ERR)
652 #define mp_init_l(a,b) (((a)->dp=NULL,tclTomMathStubsPtr->tclBNInitBignumFromLong((a),(b)),(a)->dp)?MP_OKAY:MP_ERR)
653 #define mp_init_ll(a,b) (((a)->dp=NULL,tclTomMathStubsPtr->tclBNInitBignumFromWideInt((a),(b)),(a)->dp)?MP_OKAY:MP_ERR)
654 #define mp_init_i64(a,b) (((a)->dp=NULL,tclTomMathStubsPtr->tclBNInitBignumFromWideInt((a),(b)),(a)->dp)?MP_OKAY:MP_ERR)
655 #define mp_init_u32(a,b) (((a)->dp=NULL,tclTomMathStubsPtr->tclBNInitBignumFromWideUInt((a),(uint32_t)(b)),(a)->dp)?MP_OKAY:MP_ERR)
656 #define mp_init_ul(a,b) (((a)->dp=NULL,tclTomMathStubsPtr->tclBNInitBignumFromWideUInt((a),(unsigned long)(b)),(a)->dp)?MP_OKAY:MP_ERR)
657 #define mp_init_ull(a,b) (((a)->dp=NULL,tclTomMathStubsPtr->tclBNInitBignumFromWideUInt((a),(b)),(a)->dp)?MP_OKAY:MP_ERR)
658 #define mp_init_u64(a,b) (((a)->dp=NULL,tclTomMathStubsPtr->tclBNInitBignumFromWideUInt((a),(b)),(a)->dp)?MP_OKAY:MP_ERR)
659 #else
660 #define mp_init_i32(a,b) (((a)->dp=NULL,(TclBNInitBignumFromLong)((a),(int32_t)(b)),(a)->dp)?MP_OKAY:MP_ERR)
661 #define mp_init_l(a,b) (((a)->dp=NULL,(TclBNInitBignumFromLong)((a),(b)),(a)->dp)?MP_OKAY:MP_ERR)
662 #define mp_init_ll(a,b) (((a)->dp=NULL,(TclBNInitBignumFromWideInt)((a),(b)),(a)->dp)?MP_OKAY:MP_ERR)
663 #define mp_init_i64(a,b) (((a)->dp=NULL,(TclBNInitBignumFromWideInt)((a),(b)),(a)->dp)?MP_OKAY:MP_ERR)
664 #define mp_init_u32(a,b) (((a)->dp=NULL,(TclBNInitBignumFromWideUInt)((a),(uint32_t)(b)),(a)->dp)?MP_OKAY:MP_ERR)
665 #define mp_init_ul(a,b) (((a)->dp=NULL,(TclBNInitBignumFromWideUInt)((a),(unsigned long)(b)),(a)->dp)?MP_OKAY:MP_ERR)
666 #define mp_init_ull(a,b) (((a)->dp=NULL,(TclBNInitBignumFromWideUInt)((a),(b)),(a)->dp)?MP_OKAY:MP_ERR)
667 #define mp_init_u64(a,b) (((a)->dp=NULL,(TclBNInitBignumFromWideUInt)((a),(b)),(a)->dp)?MP_OKAY:MP_ERR)
668 #endif /* USE_TCL_STUBS */
669 #endif /* _TCLINTDECLS */