Debian Codegraph @

generic/tclTomMathDecls.h

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