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