1 | /* Definitions for GNU multiple precision functions. -*- mode: c -*- |
2 | |
3 | Copyright 1991, 1993-1997, 1999-2014 Free Software Foundation, Inc. |
4 | |
5 | This file is part of the GNU MP Library. |
6 | |
7 | The GNU MP Library is free software; you can redistribute it and/or modify |
8 | it under the terms of either: |
9 | |
10 | * the GNU Lesser General Public License as published by the Free |
11 | Software Foundation; either version 3 of the License, or (at your |
12 | option) any later version. |
13 | |
14 | or |
15 | |
16 | * the GNU General Public License as published by the Free Software |
17 | Foundation; either version 2 of the License, or (at your option) any |
18 | later version. |
19 | |
20 | or both in parallel, as here. |
21 | |
22 | The GNU MP Library is distributed in the hope that it will be useful, but |
23 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
24 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
25 | for more details. |
26 | |
27 | You should have received copies of the GNU General Public License and the |
28 | GNU Lesser General Public License along with the GNU MP Library. If not, |
29 | see https://www.gnu.org/licenses/. */ |
30 | |
31 | #ifndef __GMP_H__ |
32 | |
33 | #if defined (__cplusplus) |
34 | #include <iosfwd> /* for std::istream, std::ostream, std::string */ |
35 | #include <cstdio> |
36 | #endif |
37 | |
38 | |
39 | /* Instantiated by configure. */ |
40 | #if ! defined (__GMP_WITHIN_CONFIGURE) |
41 | #define __GMP_HAVE_HOST_CPU_FAMILY_power 0 |
42 | #define __GMP_HAVE_HOST_CPU_FAMILY_powerpc 0 |
43 | #define GMP_LIMB_BITS 64 |
44 | #define GMP_NAIL_BITS 0 |
45 | #endif |
46 | #define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS) |
47 | #define GMP_NUMB_MASK ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS) |
48 | #define GMP_NUMB_MAX GMP_NUMB_MASK |
49 | #define GMP_NAIL_MASK (~ GMP_NUMB_MASK) |
50 | |
51 | |
52 | /* The following (everything under ifndef __GNU_MP__) must be identical in |
53 | gmp.h and mp.h to allow both to be included in an application or during |
54 | the library build. */ |
55 | #ifndef __GNU_MP__ |
56 | #define __GNU_MP__ 5 |
57 | |
58 | #include <stddef.h> /* for size_t */ |
59 | |
60 | /* Instantiated by configure. */ |
61 | #if ! defined (__GMP_WITHIN_CONFIGURE) |
62 | /* #undef _LONG_LONG_LIMB */ |
63 | #define __GMP_LIBGMP_DLL 0 |
64 | #endif |
65 | |
66 | |
67 | /* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in |
68 | all other circumstances. |
69 | |
70 | When compiling objects for libgmp, __GMP_DECLSPEC is an export directive, |
71 | or when compiling for an application it's an import directive. The two |
72 | cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles |
73 | (and not defined from an application). |
74 | |
75 | __GMP_DECLSPEC_XX is similarly used for libgmpxx. __GMP_WITHIN_GMPXX |
76 | indicates when building libgmpxx, and in that case libgmpxx functions are |
77 | exports, but libgmp functions which might get called are imports. |
78 | |
79 | Libtool DLL_EXPORT define is not used. |
80 | |
81 | There's no attempt to support GMP built both static and DLL. Doing so |
82 | would mean applications would have to tell us which of the two is going |
83 | to be used when linking, and that seems very tedious and error prone if |
84 | using GMP by hand, and equally tedious from a package since autoconf and |
85 | automake don't give much help. |
86 | |
87 | __GMP_DECLSPEC is required on all documented global functions and |
88 | variables, the various internals in gmp-impl.h etc can be left unadorned. |
89 | But internals used by the test programs or speed measuring programs |
90 | should have __GMP_DECLSPEC, and certainly constants or variables must |
91 | have it or the wrong address will be resolved. |
92 | |
93 | In gcc __declspec can go at either the start or end of a prototype. |
94 | |
95 | In Microsoft C __declspec must go at the start, or after the type like |
96 | void __declspec(...) *foo()". There's no __dllexport or anything to |
97 | guard against someone foolish #defining dllexport. _export used to be |
98 | available, but no longer. |
99 | |
100 | In Borland C _export still exists, but needs to go after the type, like |
101 | "void _export foo();". Would have to change the __GMP_DECLSPEC syntax to |
102 | make use of that. Probably more trouble than it's worth. */ |
103 | |
104 | #if defined (__GNUC__) |
105 | #define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__) |
106 | #define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__) |
107 | #endif |
108 | #if defined (_MSC_VER) || defined (__BORLANDC__) |
109 | #define __GMP_DECLSPEC_EXPORT __declspec(dllexport) |
110 | #define __GMP_DECLSPEC_IMPORT __declspec(dllimport) |
111 | #endif |
112 | #ifdef __WATCOMC__ |
113 | #define __GMP_DECLSPEC_EXPORT __export |
114 | #define __GMP_DECLSPEC_IMPORT __import |
115 | #endif |
116 | #ifdef __IBMC__ |
117 | #define __GMP_DECLSPEC_EXPORT _Export |
118 | #define __GMP_DECLSPEC_IMPORT _Import |
119 | #endif |
120 | |
121 | #if __GMP_LIBGMP_DLL |
122 | #ifdef __GMP_WITHIN_GMP |
123 | /* compiling to go into a DLL libgmp */ |
124 | #define __GMP_DECLSPEC __GMP_DECLSPEC_EXPORT |
125 | #else |
126 | /* compiling to go into an application which will link to a DLL libgmp */ |
127 | #define __GMP_DECLSPEC __GMP_DECLSPEC_IMPORT |
128 | #endif |
129 | #else |
130 | /* all other cases */ |
131 | #define __GMP_DECLSPEC |
132 | #endif |
133 | |
134 | |
135 | #ifdef __GMP_SHORT_LIMB |
136 | typedef unsigned int mp_limb_t; |
137 | typedef int mp_limb_signed_t; |
138 | #else |
139 | #ifdef _LONG_LONG_LIMB |
140 | typedef unsigned long long int mp_limb_t; |
141 | typedef long long int mp_limb_signed_t; |
142 | #else |
143 | typedef unsigned long int mp_limb_t; |
144 | typedef long int mp_limb_signed_t; |
145 | #endif |
146 | #endif |
147 | typedef unsigned long int mp_bitcnt_t; |
148 | |
149 | /* For reference, note that the name __mpz_struct gets into C++ mangled |
150 | function names, which means although the "__" suggests an internal, we |
151 | must leave this name for binary compatibility. */ |
152 | typedef struct |
153 | { |
154 | int _mp_alloc; /* Number of *limbs* allocated and pointed |
155 | to by the _mp_d field. */ |
156 | int _mp_size; /* abs(_mp_size) is the number of limbs the |
157 | last field points to. If _mp_size is |
158 | negative this is a negative number. */ |
159 | mp_limb_t *_mp_d; /* Pointer to the limbs. */ |
160 | } __mpz_struct; |
161 | |
162 | #endif /* __GNU_MP__ */ |
163 | |
164 | |
165 | typedef __mpz_struct MP_INT; /* gmp 1 source compatibility */ |
166 | typedef __mpz_struct mpz_t[1]; |
167 | |
168 | typedef mp_limb_t * mp_ptr; |
169 | typedef const mp_limb_t * mp_srcptr; |
170 | #if defined (_CRAY) && ! defined (_CRAYMPP) |
171 | /* plain `int' is much faster (48 bits) */ |
172 | #define __GMP_MP_SIZE_T_INT 1 |
173 | typedef int mp_size_t; |
174 | typedef int mp_exp_t; |
175 | #else |
176 | #define __GMP_MP_SIZE_T_INT 0 |
177 | typedef long int mp_size_t; |
178 | typedef long int mp_exp_t; |
179 | #endif |
180 | |
181 | typedef struct |
182 | { |
183 | __mpz_struct _mp_num; |
184 | __mpz_struct _mp_den; |
185 | } __mpq_struct; |
186 | |
187 | typedef __mpq_struct MP_RAT; /* gmp 1 source compatibility */ |
188 | typedef __mpq_struct mpq_t[1]; |
189 | |
190 | typedef struct |
191 | { |
192 | int _mp_prec; /* Max precision, in number of `mp_limb_t's. |
193 | Set by mpf_init and modified by |
194 | mpf_set_prec. The area pointed to by the |
195 | _mp_d field contains `prec' + 1 limbs. */ |
196 | int _mp_size; /* abs(_mp_size) is the number of limbs the |
197 | last field points to. If _mp_size is |
198 | negative this is a negative number. */ |
199 | mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */ |
200 | mp_limb_t *_mp_d; /* Pointer to the limbs. */ |
201 | } __mpf_struct; |
202 | |
203 | /* typedef __mpf_struct MP_FLOAT; */ |
204 | typedef __mpf_struct mpf_t[1]; |
205 | |
206 | /* Available random number generation algorithms. */ |
207 | typedef enum |
208 | { |
209 | GMP_RAND_ALG_DEFAULT = 0, |
210 | GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */ |
211 | } gmp_randalg_t; |
212 | |
213 | /* Random state struct. */ |
214 | typedef struct |
215 | { |
216 | mpz_t _mp_seed; /* _mp_d member points to state of the generator. */ |
217 | gmp_randalg_t _mp_alg; /* Currently unused. */ |
218 | union { |
219 | void *_mp_lc; /* Pointer to function pointers structure. */ |
220 | } _mp_algdata; |
221 | } __gmp_randstate_struct; |
222 | typedef __gmp_randstate_struct gmp_randstate_t[1]; |
223 | |
224 | /* Types for function declarations in gmp files. */ |
225 | /* ??? Should not pollute user name space with these ??? */ |
226 | typedef const __mpz_struct *mpz_srcptr; |
227 | typedef __mpz_struct *mpz_ptr; |
228 | typedef const __mpf_struct *mpf_srcptr; |
229 | typedef __mpf_struct *mpf_ptr; |
230 | typedef const __mpq_struct *mpq_srcptr; |
231 | typedef __mpq_struct *mpq_ptr; |
232 | |
233 | |
234 | /* This is not wanted in mp.h, so put it outside the __GNU_MP__ common |
235 | section. */ |
236 | #if __GMP_LIBGMP_DLL |
237 | #ifdef __GMP_WITHIN_GMPXX |
238 | /* compiling to go into a DLL libgmpxx */ |
239 | #define __GMP_DECLSPEC_XX __GMP_DECLSPEC_EXPORT |
240 | #else |
241 | /* compiling to go into a application which will link to a DLL libgmpxx */ |
242 | #define __GMP_DECLSPEC_XX __GMP_DECLSPEC_IMPORT |
243 | #endif |
244 | #else |
245 | /* all other cases */ |
246 | #define __GMP_DECLSPEC_XX |
247 | #endif |
248 | |
249 | |
250 | #ifndef __MPN |
251 | #define __MPN(x) __gmpn_##x |
252 | #endif |
253 | |
254 | /* For reference, "defined(EOF)" cannot be used here. In g++ 2.95.4, |
255 | <iostream> defines EOF but not FILE. */ |
256 | #if defined (FILE) \ |
257 | || defined (H_STDIO) \ |
258 | || defined (_H_STDIO) /* AIX */ \ |
259 | || defined (_STDIO_H) /* glibc, Sun, SCO */ \ |
260 | || defined (_STDIO_H_) /* BSD, OSF */ \ |
261 | || defined (__STDIO_H) /* Borland */ \ |
262 | || defined (__STDIO_H__) /* IRIX */ \ |
263 | || defined (_STDIO_INCLUDED) /* HPUX */ \ |
264 | || defined (__dj_include_stdio_h_) /* DJGPP */ \ |
265 | || defined (_FILE_DEFINED) /* Microsoft */ \ |
266 | || defined (__STDIO__) /* Apple MPW MrC */ \ |
267 | || defined (_MSL_STDIO_H) /* Metrowerks */ \ |
268 | || defined (_STDIO_H_INCLUDED) /* QNX4 */ \ |
269 | || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \ |
270 | || defined (__STDIO_LOADED) /* VMS */ |
271 | #define _GMP_H_HAVE_FILE 1 |
272 | #endif |
273 | |
274 | /* In ISO C, if a prototype involving "struct obstack *" is given without |
275 | that structure defined, then the struct is scoped down to just the |
276 | prototype, causing a conflict if it's subsequently defined for real. So |
277 | only give prototypes if we've got obstack.h. */ |
278 | #if defined (_OBSTACK_H) /* glibc <obstack.h> */ |
279 | #define _GMP_H_HAVE_OBSTACK 1 |
280 | #endif |
281 | |
282 | /* The prototypes for gmp_vprintf etc are provided only if va_list is defined, |
283 | via an application having included <stdarg.h>. Usually va_list is a typedef |
284 | so can't be tested directly, but C99 specifies that va_start is a macro. |
285 | |
286 | <stdio.h> will define some sort of va_list for vprintf and vfprintf, but |
287 | let's not bother trying to use that since it's not standard and since |
288 | application uses for gmp_vprintf etc will almost certainly require the |
289 | whole <stdarg.h> anyway. */ |
290 | |
291 | #ifdef va_start |
292 | #define _GMP_H_HAVE_VA_LIST 1 |
293 | #endif |
294 | |
295 | /* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */ |
296 | #if defined (__GNUC__) && defined (__GNUC_MINOR__) |
297 | #define __GMP_GNUC_PREREQ(maj, min) \ |
298 | ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) |
299 | #else |
300 | #define __GMP_GNUC_PREREQ(maj, min) 0 |
301 | #endif |
302 | |
303 | /* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes". Basically |
304 | it means a function does nothing but examine its arguments and memory |
305 | (global or via arguments) to generate a return value, but changes nothing |
306 | and has no side-effects. __GMP_NO_ATTRIBUTE_CONST_PURE lets |
307 | tune/common.c etc turn this off when trying to write timing loops. */ |
308 | #if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE) |
309 | #define __GMP_ATTRIBUTE_PURE __attribute__ ((__pure__)) |
310 | #else |
311 | #define __GMP_ATTRIBUTE_PURE |
312 | #endif |
313 | |
314 | |
315 | /* __GMP_CAST allows us to use static_cast in C++, so our macros are clean |
316 | to "g++ -Wold-style-cast". |
317 | |
318 | Casts in "extern inline" code within an extern "C" block don't induce |
319 | these warnings, so __GMP_CAST only needs to be used on documented |
320 | macros. */ |
321 | |
322 | #ifdef __cplusplus |
323 | #define __GMP_CAST(type, expr) (static_cast<type> (expr)) |
324 | #else |
325 | #define __GMP_CAST(type, expr) ((type) (expr)) |
326 | #endif |
327 | |
328 | |
329 | /* An empty "throw ()" means the function doesn't throw any C++ exceptions, |
330 | this can save some stack frame info in applications. |
331 | |
332 | Currently it's given only on functions which never divide-by-zero etc, |
333 | don't allocate memory, and are expected to never need to allocate memory. |
334 | This leaves open the possibility of a C++ throw from a future GMP |
335 | exceptions scheme. |
336 | |
337 | mpz_set_ui etc are omitted to leave open the lazy allocation scheme |
338 | described in doc/tasks.html. mpz_get_d etc are omitted to leave open |
339 | exceptions for float overflows. |
340 | |
341 | Note that __GMP_NOTHROW must be given on any inlines the same as on their |
342 | prototypes (for g++ at least, where they're used together). Note also |
343 | that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like |
344 | __GMP_ATTRIBUTE_PURE. */ |
345 | |
346 | #if defined (__cplusplus) |
347 | #define __GMP_NOTHROW throw () |
348 | #else |
349 | #define __GMP_NOTHROW |
350 | #endif |
351 | |
352 | |
353 | /* PORTME: What other compilers have a useful "extern inline"? "static |
354 | inline" would be an acceptable substitute if the compiler (or linker) |
355 | discards unused statics. */ |
356 | |
357 | /* gcc has __inline__ in all modes, including strict ansi. Give a prototype |
358 | for an inline too, so as to correctly specify "dllimport" on windows, in |
359 | case the function is called rather than inlined. |
360 | GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 |
361 | inline semantics, unless -fgnu89-inline is used. */ |
362 | #ifdef __GNUC__ |
363 | #if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2) \ |
364 | || (defined __GNUC_GNU_INLINE__ && defined __cplusplus) |
365 | #define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__)) |
366 | #else |
367 | #define __GMP_EXTERN_INLINE extern __inline__ |
368 | #endif |
369 | #define __GMP_INLINE_PROTOTYPES 1 |
370 | #endif |
371 | |
372 | /* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1 |
373 | strict ANSI mode. Inlining is done even when not optimizing (ie. -O0 |
374 | mode, which is the default), but an unnecessary local copy of foo is |
375 | emitted unless -O is used. "extern __inline" is accepted, but the |
376 | "extern" appears to be ignored, ie. it becomes a plain global function |
377 | but which is inlined within its file. Don't know if all old versions of |
378 | DEC C supported __inline, but as a start let's do the right thing for |
379 | current versions. */ |
380 | #ifdef __DECC |
381 | #define __GMP_EXTERN_INLINE static __inline |
382 | #endif |
383 | |
384 | /* SCO OpenUNIX 8 cc supports "static inline foo()" but not in -Xc strict |
385 | ANSI mode (__STDC__ is 1 in that mode). Inlining only actually takes |
386 | place under -O. Without -O "foo" seems to be emitted whether it's used |
387 | or not, which is wasteful. "extern inline foo()" isn't useful, the |
388 | "extern" is apparently ignored, so foo is inlined if possible but also |
389 | emitted as a global, which causes multiple definition errors when |
390 | building a shared libgmp. */ |
391 | #ifdef __SCO_VERSION__ |
392 | #if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \ |
393 | && ! defined (__GMP_EXTERN_INLINE) |
394 | #define __GMP_EXTERN_INLINE static inline |
395 | #endif |
396 | #endif |
397 | |
398 | /* Microsoft's C compiler accepts __inline */ |
399 | #ifdef _MSC_VER |
400 | #define __GMP_EXTERN_INLINE __inline |
401 | #endif |
402 | |
403 | /* Recent enough Sun C compilers want "inline" */ |
404 | #if defined (__SUNPRO_C) && __SUNPRO_C >= 0x560 \ |
405 | && ! defined (__GMP_EXTERN_INLINE) |
406 | #define __GMP_EXTERN_INLINE inline |
407 | #endif |
408 | |
409 | /* Somewhat older Sun C compilers want "static inline" */ |
410 | #if defined (__SUNPRO_C) && __SUNPRO_C >= 0x540 \ |
411 | && ! defined (__GMP_EXTERN_INLINE) |
412 | #define __GMP_EXTERN_INLINE static inline |
413 | #endif |
414 | |
415 | |
416 | /* C++ always has "inline" and since it's a normal feature the linker should |
417 | discard duplicate non-inlined copies, or if it doesn't then that's a |
418 | problem for everyone, not just GMP. */ |
419 | #if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE) |
420 | #define __GMP_EXTERN_INLINE inline |
421 | #endif |
422 | |
423 | /* Don't do any inlining within a configure run, since if the compiler ends |
424 | up emitting copies of the code into the object file it can end up |
425 | demanding the various support routines (like mpn_popcount) for linking, |
426 | making the "alloca" test and perhaps others fail. And on hppa ia64 a |
427 | pre-release gcc 3.2 was seen not respecting the "extern" in "extern |
428 | __inline__", triggering this problem too. */ |
429 | #if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE |
430 | #undef __GMP_EXTERN_INLINE |
431 | #endif |
432 | |
433 | /* By default, don't give a prototype when there's going to be an inline |
434 | version. Note in particular that Cray C++ objects to the combination of |
435 | prototype and inline. */ |
436 | #ifdef __GMP_EXTERN_INLINE |
437 | #ifndef __GMP_INLINE_PROTOTYPES |
438 | #define __GMP_INLINE_PROTOTYPES 0 |
439 | #endif |
440 | #else |
441 | #define __GMP_INLINE_PROTOTYPES 1 |
442 | #endif |
443 | |
444 | |
445 | #define __GMP_ABS(x) ((x) >= 0 ? (x) : -(x)) |
446 | #define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i)) |
447 | |
448 | /* __GMP_USHRT_MAX is not "~ (unsigned short) 0" because short is promoted |
449 | to int by "~". It still needs to have the promoted type. */ |
450 | #define __GMP_UINT_MAX (~ (unsigned) 0) |
451 | #define __GMP_ULONG_MAX (~ (unsigned long) 0) |
452 | #define __GMP_USHRT_MAX (0 + (unsigned short) ~0) |
453 | |
454 | |
455 | /* __builtin_expect is in gcc 3.0, and not in 2.95. */ |
456 | #if __GMP_GNUC_PREREQ (3,0) |
457 | #define __GMP_LIKELY(cond) __builtin_expect ((cond) != 0, 1) |
458 | #define __GMP_UNLIKELY(cond) __builtin_expect ((cond) != 0, 0) |
459 | #else |
460 | #define __GMP_LIKELY(cond) (cond) |
461 | #define __GMP_UNLIKELY(cond) (cond) |
462 | #endif |
463 | |
464 | #ifdef _CRAY |
465 | #define __GMP_CRAY_Pragma(str) _Pragma (str) |
466 | #else |
467 | #define __GMP_CRAY_Pragma(str) |
468 | #endif |
469 | |
470 | |
471 | /* Allow direct user access to numerator and denominator of a mpq_t object. */ |
472 | #define mpq_numref(Q) (&((Q)->_mp_num)) |
473 | #define mpq_denref(Q) (&((Q)->_mp_den)) |
474 | |
475 | |
476 | #if defined (__cplusplus) |
477 | extern "C" { |
478 | using std::FILE; |
479 | #endif |
480 | |
481 | #define mp_set_memory_functions __gmp_set_memory_functions |
482 | __GMP_DECLSPEC void mp_set_memory_functions (void *(*) (size_t), |
483 | void *(*) (void *, size_t, size_t), |
484 | void (*) (void *, size_t)) __GMP_NOTHROW; |
485 | |
486 | #define mp_get_memory_functions __gmp_get_memory_functions |
487 | __GMP_DECLSPEC void mp_get_memory_functions (void *(**) (size_t), |
488 | void *(**) (void *, size_t, size_t), |
489 | void (**) (void *, size_t)) __GMP_NOTHROW; |
490 | |
491 | #define mp_bits_per_limb __gmp_bits_per_limb |
492 | __GMP_DECLSPEC extern const int mp_bits_per_limb; |
493 | |
494 | #define gmp_errno __gmp_errno |
495 | __GMP_DECLSPEC extern int gmp_errno; |
496 | |
497 | #define gmp_version __gmp_version |
498 | __GMP_DECLSPEC extern const char * const gmp_version; |
499 | |
500 | |
501 | /**************** Random number routines. ****************/ |
502 | |
503 | /* obsolete */ |
504 | #define gmp_randinit __gmp_randinit |
505 | __GMP_DECLSPEC void gmp_randinit (gmp_randstate_t, gmp_randalg_t, ...); |
506 | |
507 | #define gmp_randinit_default __gmp_randinit_default |
508 | __GMP_DECLSPEC void gmp_randinit_default (gmp_randstate_t); |
509 | |
510 | #define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp |
511 | __GMP_DECLSPEC void gmp_randinit_lc_2exp (gmp_randstate_t, mpz_srcptr, unsigned long int, mp_bitcnt_t); |
512 | |
513 | #define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size |
514 | __GMP_DECLSPEC int gmp_randinit_lc_2exp_size (gmp_randstate_t, mp_bitcnt_t); |
515 | |
516 | #define gmp_randinit_mt __gmp_randinit_mt |
517 | __GMP_DECLSPEC void gmp_randinit_mt (gmp_randstate_t); |
518 | |
519 | #define gmp_randinit_set __gmp_randinit_set |
520 | __GMP_DECLSPEC void gmp_randinit_set (gmp_randstate_t, const __gmp_randstate_struct *); |
521 | |
522 | #define gmp_randseed __gmp_randseed |
523 | __GMP_DECLSPEC void gmp_randseed (gmp_randstate_t, mpz_srcptr); |
524 | |
525 | #define gmp_randseed_ui __gmp_randseed_ui |
526 | __GMP_DECLSPEC void gmp_randseed_ui (gmp_randstate_t, unsigned long int); |
527 | |
528 | #define gmp_randclear __gmp_randclear |
529 | __GMP_DECLSPEC void gmp_randclear (gmp_randstate_t); |
530 | |
531 | #define gmp_urandomb_ui __gmp_urandomb_ui |
532 | __GMP_DECLSPEC unsigned long gmp_urandomb_ui (gmp_randstate_t, unsigned long); |
533 | |
534 | #define gmp_urandomm_ui __gmp_urandomm_ui |
535 | __GMP_DECLSPEC unsigned long gmp_urandomm_ui (gmp_randstate_t, unsigned long); |
536 | |
537 | |
538 | /**************** Formatted output routines. ****************/ |
539 | |
540 | #define gmp_asprintf __gmp_asprintf |
541 | __GMP_DECLSPEC int gmp_asprintf (char **, const char *, ...); |
542 | |
543 | #define gmp_fprintf __gmp_fprintf |
544 | #ifdef _GMP_H_HAVE_FILE |
545 | __GMP_DECLSPEC int gmp_fprintf (FILE *, const char *, ...); |
546 | #endif |
547 | |
548 | #define gmp_obstack_printf __gmp_obstack_printf |
549 | #if defined (_GMP_H_HAVE_OBSTACK) |
550 | __GMP_DECLSPEC int gmp_obstack_printf (struct obstack *, const char *, ...); |
551 | #endif |
552 | |
553 | #define gmp_obstack_vprintf __gmp_obstack_vprintf |
554 | #if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST) |
555 | __GMP_DECLSPEC int gmp_obstack_vprintf (struct obstack *, const char *, va_list); |
556 | #endif |
557 | |
558 | #define gmp_printf __gmp_printf |
559 | __GMP_DECLSPEC int gmp_printf (const char *, ...); |
560 | |
561 | #define gmp_snprintf __gmp_snprintf |
562 | __GMP_DECLSPEC int gmp_snprintf (char *, size_t, const char *, ...); |
563 | |
564 | #define gmp_sprintf __gmp_sprintf |
565 | __GMP_DECLSPEC int gmp_sprintf (char *, const char *, ...); |
566 | |
567 | #define gmp_vasprintf __gmp_vasprintf |
568 | #if defined (_GMP_H_HAVE_VA_LIST) |
569 | __GMP_DECLSPEC int gmp_vasprintf (char **, const char *, va_list); |
570 | #endif |
571 | |
572 | #define gmp_vfprintf __gmp_vfprintf |
573 | #if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST) |
574 | __GMP_DECLSPEC int gmp_vfprintf (FILE *, const char *, va_list); |
575 | #endif |
576 | |
577 | #define gmp_vprintf __gmp_vprintf |
578 | #if defined (_GMP_H_HAVE_VA_LIST) |
579 | __GMP_DECLSPEC int gmp_vprintf (const char *, va_list); |
580 | #endif |
581 | |
582 | #define gmp_vsnprintf __gmp_vsnprintf |
583 | #if defined (_GMP_H_HAVE_VA_LIST) |
584 | __GMP_DECLSPEC int gmp_vsnprintf (char *, size_t, const char *, va_list); |
585 | #endif |
586 | |
587 | #define gmp_vsprintf __gmp_vsprintf |
588 | #if defined (_GMP_H_HAVE_VA_LIST) |
589 | __GMP_DECLSPEC int gmp_vsprintf (char *, const char *, va_list); |
590 | #endif |
591 | |
592 | |
593 | /**************** Formatted input routines. ****************/ |
594 | |
595 | #define gmp_fscanf __gmp_fscanf |
596 | #ifdef _GMP_H_HAVE_FILE |
597 | __GMP_DECLSPEC int gmp_fscanf (FILE *, const char *, ...); |
598 | #endif |
599 | |
600 | #define gmp_scanf __gmp_scanf |
601 | __GMP_DECLSPEC int gmp_scanf (const char *, ...); |
602 | |
603 | #define gmp_sscanf __gmp_sscanf |
604 | __GMP_DECLSPEC int gmp_sscanf (const char *, const char *, ...); |
605 | |
606 | #define gmp_vfscanf __gmp_vfscanf |
607 | #if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST) |
608 | __GMP_DECLSPEC int gmp_vfscanf (FILE *, const char *, va_list); |
609 | #endif |
610 | |
611 | #define gmp_vscanf __gmp_vscanf |
612 | #if defined (_GMP_H_HAVE_VA_LIST) |
613 | __GMP_DECLSPEC int gmp_vscanf (const char *, va_list); |
614 | #endif |
615 | |
616 | #define gmp_vsscanf __gmp_vsscanf |
617 | #if defined (_GMP_H_HAVE_VA_LIST) |
618 | __GMP_DECLSPEC int gmp_vsscanf (const char *, const char *, va_list); |
619 | #endif |
620 | |
621 | |
622 | /**************** Integer (i.e. Z) routines. ****************/ |
623 | |
624 | #define _mpz_realloc __gmpz_realloc |
625 | #define mpz_realloc __gmpz_realloc |
626 | __GMP_DECLSPEC void *_mpz_realloc (mpz_ptr, mp_size_t); |
627 | |
628 | #define mpz_abs __gmpz_abs |
629 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs) |
630 | __GMP_DECLSPEC void mpz_abs (mpz_ptr, mpz_srcptr); |
631 | #endif |
632 | |
633 | #define mpz_add __gmpz_add |
634 | __GMP_DECLSPEC void mpz_add (mpz_ptr, mpz_srcptr, mpz_srcptr); |
635 | |
636 | #define mpz_add_ui __gmpz_add_ui |
637 | __GMP_DECLSPEC void mpz_add_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
638 | |
639 | #define mpz_addmul __gmpz_addmul |
640 | __GMP_DECLSPEC void mpz_addmul (mpz_ptr, mpz_srcptr, mpz_srcptr); |
641 | |
642 | #define mpz_addmul_ui __gmpz_addmul_ui |
643 | __GMP_DECLSPEC void mpz_addmul_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
644 | |
645 | #define mpz_and __gmpz_and |
646 | __GMP_DECLSPEC void mpz_and (mpz_ptr, mpz_srcptr, mpz_srcptr); |
647 | |
648 | #define mpz_array_init __gmpz_array_init |
649 | __GMP_DECLSPEC void mpz_array_init (mpz_ptr, mp_size_t, mp_size_t); |
650 | |
651 | #define mpz_bin_ui __gmpz_bin_ui |
652 | __GMP_DECLSPEC void mpz_bin_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
653 | |
654 | #define mpz_bin_uiui __gmpz_bin_uiui |
655 | __GMP_DECLSPEC void mpz_bin_uiui (mpz_ptr, unsigned long int, unsigned long int); |
656 | |
657 | #define mpz_cdiv_q __gmpz_cdiv_q |
658 | __GMP_DECLSPEC void mpz_cdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); |
659 | |
660 | #define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp |
661 | __GMP_DECLSPEC void mpz_cdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); |
662 | |
663 | #define mpz_cdiv_q_ui __gmpz_cdiv_q_ui |
664 | __GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
665 | |
666 | #define mpz_cdiv_qr __gmpz_cdiv_qr |
667 | __GMP_DECLSPEC void mpz_cdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); |
668 | |
669 | #define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui |
670 | __GMP_DECLSPEC unsigned long int mpz_cdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); |
671 | |
672 | #define mpz_cdiv_r __gmpz_cdiv_r |
673 | __GMP_DECLSPEC void mpz_cdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); |
674 | |
675 | #define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp |
676 | __GMP_DECLSPEC void mpz_cdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); |
677 | |
678 | #define mpz_cdiv_r_ui __gmpz_cdiv_r_ui |
679 | __GMP_DECLSPEC unsigned long int mpz_cdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
680 | |
681 | #define mpz_cdiv_ui __gmpz_cdiv_ui |
682 | __GMP_DECLSPEC unsigned long int mpz_cdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE; |
683 | |
684 | #define mpz_clear __gmpz_clear |
685 | __GMP_DECLSPEC void mpz_clear (mpz_ptr); |
686 | |
687 | #define mpz_clears __gmpz_clears |
688 | __GMP_DECLSPEC void mpz_clears (mpz_ptr, ...); |
689 | |
690 | #define mpz_clrbit __gmpz_clrbit |
691 | __GMP_DECLSPEC void mpz_clrbit (mpz_ptr, mp_bitcnt_t); |
692 | |
693 | #define mpz_cmp __gmpz_cmp |
694 | __GMP_DECLSPEC int mpz_cmp (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
695 | |
696 | #define mpz_cmp_d __gmpz_cmp_d |
697 | __GMP_DECLSPEC int mpz_cmp_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE; |
698 | |
699 | #define _mpz_cmp_si __gmpz_cmp_si |
700 | __GMP_DECLSPEC int _mpz_cmp_si (mpz_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
701 | |
702 | #define _mpz_cmp_ui __gmpz_cmp_ui |
703 | __GMP_DECLSPEC int _mpz_cmp_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
704 | |
705 | #define mpz_cmpabs __gmpz_cmpabs |
706 | __GMP_DECLSPEC int mpz_cmpabs (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
707 | |
708 | #define mpz_cmpabs_d __gmpz_cmpabs_d |
709 | __GMP_DECLSPEC int mpz_cmpabs_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE; |
710 | |
711 | #define mpz_cmpabs_ui __gmpz_cmpabs_ui |
712 | __GMP_DECLSPEC int mpz_cmpabs_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
713 | |
714 | #define mpz_com __gmpz_com |
715 | __GMP_DECLSPEC void mpz_com (mpz_ptr, mpz_srcptr); |
716 | |
717 | #define mpz_combit __gmpz_combit |
718 | __GMP_DECLSPEC void mpz_combit (mpz_ptr, mp_bitcnt_t); |
719 | |
720 | #define mpz_congruent_p __gmpz_congruent_p |
721 | __GMP_DECLSPEC int mpz_congruent_p (mpz_srcptr, mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE; |
722 | |
723 | #define mpz_congruent_2exp_p __gmpz_congruent_2exp_p |
724 | __GMP_DECLSPEC int mpz_congruent_2exp_p (mpz_srcptr, mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
725 | |
726 | #define mpz_congruent_ui_p __gmpz_congruent_ui_p |
727 | __GMP_DECLSPEC int mpz_congruent_ui_p (mpz_srcptr, unsigned long, unsigned long) __GMP_ATTRIBUTE_PURE; |
728 | |
729 | #define mpz_divexact __gmpz_divexact |
730 | __GMP_DECLSPEC void mpz_divexact (mpz_ptr, mpz_srcptr, mpz_srcptr); |
731 | |
732 | #define mpz_divexact_ui __gmpz_divexact_ui |
733 | __GMP_DECLSPEC void mpz_divexact_ui (mpz_ptr, mpz_srcptr, unsigned long); |
734 | |
735 | #define mpz_divisible_p __gmpz_divisible_p |
736 | __GMP_DECLSPEC int mpz_divisible_p (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE; |
737 | |
738 | #define mpz_divisible_ui_p __gmpz_divisible_ui_p |
739 | __GMP_DECLSPEC int mpz_divisible_ui_p (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE; |
740 | |
741 | #define mpz_divisible_2exp_p __gmpz_divisible_2exp_p |
742 | __GMP_DECLSPEC int mpz_divisible_2exp_p (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
743 | |
744 | #define mpz_dump __gmpz_dump |
745 | __GMP_DECLSPEC void mpz_dump (mpz_srcptr); |
746 | |
747 | #define mpz_export __gmpz_export |
748 | __GMP_DECLSPEC void *mpz_export (void *, size_t *, int, size_t, int, size_t, mpz_srcptr); |
749 | |
750 | #define mpz_fac_ui __gmpz_fac_ui |
751 | __GMP_DECLSPEC void mpz_fac_ui (mpz_ptr, unsigned long int); |
752 | |
753 | #define mpz_2fac_ui __gmpz_2fac_ui |
754 | __GMP_DECLSPEC void mpz_2fac_ui (mpz_ptr, unsigned long int); |
755 | |
756 | #define mpz_mfac_uiui __gmpz_mfac_uiui |
757 | __GMP_DECLSPEC void mpz_mfac_uiui (mpz_ptr, unsigned long int, unsigned long int); |
758 | |
759 | #define mpz_primorial_ui __gmpz_primorial_ui |
760 | __GMP_DECLSPEC void mpz_primorial_ui (mpz_ptr, unsigned long int); |
761 | |
762 | #define mpz_fdiv_q __gmpz_fdiv_q |
763 | __GMP_DECLSPEC void mpz_fdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); |
764 | |
765 | #define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp |
766 | __GMP_DECLSPEC void mpz_fdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); |
767 | |
768 | #define mpz_fdiv_q_ui __gmpz_fdiv_q_ui |
769 | __GMP_DECLSPEC unsigned long int mpz_fdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
770 | |
771 | #define mpz_fdiv_qr __gmpz_fdiv_qr |
772 | __GMP_DECLSPEC void mpz_fdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); |
773 | |
774 | #define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui |
775 | __GMP_DECLSPEC unsigned long int mpz_fdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); |
776 | |
777 | #define mpz_fdiv_r __gmpz_fdiv_r |
778 | __GMP_DECLSPEC void mpz_fdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); |
779 | |
780 | #define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp |
781 | __GMP_DECLSPEC void mpz_fdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); |
782 | |
783 | #define mpz_fdiv_r_ui __gmpz_fdiv_r_ui |
784 | __GMP_DECLSPEC unsigned long int mpz_fdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
785 | |
786 | #define mpz_fdiv_ui __gmpz_fdiv_ui |
787 | __GMP_DECLSPEC unsigned long int mpz_fdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE; |
788 | |
789 | #define mpz_fib_ui __gmpz_fib_ui |
790 | __GMP_DECLSPEC void mpz_fib_ui (mpz_ptr, unsigned long int); |
791 | |
792 | #define mpz_fib2_ui __gmpz_fib2_ui |
793 | __GMP_DECLSPEC void mpz_fib2_ui (mpz_ptr, mpz_ptr, unsigned long int); |
794 | |
795 | #define mpz_fits_sint_p __gmpz_fits_sint_p |
796 | __GMP_DECLSPEC int mpz_fits_sint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
797 | |
798 | #define mpz_fits_slong_p __gmpz_fits_slong_p |
799 | __GMP_DECLSPEC int mpz_fits_slong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
800 | |
801 | #define mpz_fits_sshort_p __gmpz_fits_sshort_p |
802 | __GMP_DECLSPEC int mpz_fits_sshort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
803 | |
804 | #define mpz_fits_uint_p __gmpz_fits_uint_p |
805 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p) |
806 | __GMP_DECLSPEC int mpz_fits_uint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
807 | #endif |
808 | |
809 | #define mpz_fits_ulong_p __gmpz_fits_ulong_p |
810 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p) |
811 | __GMP_DECLSPEC int mpz_fits_ulong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
812 | #endif |
813 | |
814 | #define mpz_fits_ushort_p __gmpz_fits_ushort_p |
815 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p) |
816 | __GMP_DECLSPEC int mpz_fits_ushort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
817 | #endif |
818 | |
819 | #define mpz_gcd __gmpz_gcd |
820 | __GMP_DECLSPEC void mpz_gcd (mpz_ptr, mpz_srcptr, mpz_srcptr); |
821 | |
822 | #define mpz_gcd_ui __gmpz_gcd_ui |
823 | __GMP_DECLSPEC unsigned long int mpz_gcd_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
824 | |
825 | #define mpz_gcdext __gmpz_gcdext |
826 | __GMP_DECLSPEC void mpz_gcdext (mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); |
827 | |
828 | #define mpz_get_d __gmpz_get_d |
829 | __GMP_DECLSPEC double mpz_get_d (mpz_srcptr) __GMP_ATTRIBUTE_PURE; |
830 | |
831 | #define mpz_get_d_2exp __gmpz_get_d_2exp |
832 | __GMP_DECLSPEC double mpz_get_d_2exp (signed long int *, mpz_srcptr); |
833 | |
834 | #define mpz_get_si __gmpz_get_si |
835 | __GMP_DECLSPEC /* signed */ long int mpz_get_si (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
836 | |
837 | #define mpz_get_str __gmpz_get_str |
838 | __GMP_DECLSPEC char *mpz_get_str (char *, int, mpz_srcptr); |
839 | |
840 | #define mpz_get_ui __gmpz_get_ui |
841 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui) |
842 | __GMP_DECLSPEC unsigned long int mpz_get_ui (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
843 | #endif |
844 | |
845 | #define mpz_getlimbn __gmpz_getlimbn |
846 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn) |
847 | __GMP_DECLSPEC mp_limb_t mpz_getlimbn (mpz_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
848 | #endif |
849 | |
850 | #define mpz_hamdist __gmpz_hamdist |
851 | __GMP_DECLSPEC mp_bitcnt_t mpz_hamdist (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
852 | |
853 | #define mpz_import __gmpz_import |
854 | __GMP_DECLSPEC void mpz_import (mpz_ptr, size_t, int, size_t, int, size_t, const void *); |
855 | |
856 | #define mpz_init __gmpz_init |
857 | __GMP_DECLSPEC void mpz_init (mpz_ptr); |
858 | |
859 | #define mpz_init2 __gmpz_init2 |
860 | __GMP_DECLSPEC void mpz_init2 (mpz_ptr, mp_bitcnt_t); |
861 | |
862 | #define mpz_inits __gmpz_inits |
863 | __GMP_DECLSPEC void mpz_inits (mpz_ptr, ...); |
864 | |
865 | #define mpz_init_set __gmpz_init_set |
866 | __GMP_DECLSPEC void mpz_init_set (mpz_ptr, mpz_srcptr); |
867 | |
868 | #define mpz_init_set_d __gmpz_init_set_d |
869 | __GMP_DECLSPEC void mpz_init_set_d (mpz_ptr, double); |
870 | |
871 | #define mpz_init_set_si __gmpz_init_set_si |
872 | __GMP_DECLSPEC void mpz_init_set_si (mpz_ptr, signed long int); |
873 | |
874 | #define mpz_init_set_str __gmpz_init_set_str |
875 | __GMP_DECLSPEC int mpz_init_set_str (mpz_ptr, const char *, int); |
876 | |
877 | #define mpz_init_set_ui __gmpz_init_set_ui |
878 | __GMP_DECLSPEC void mpz_init_set_ui (mpz_ptr, unsigned long int); |
879 | |
880 | #define mpz_inp_raw __gmpz_inp_raw |
881 | #ifdef _GMP_H_HAVE_FILE |
882 | __GMP_DECLSPEC size_t mpz_inp_raw (mpz_ptr, FILE *); |
883 | #endif |
884 | |
885 | #define mpz_inp_str __gmpz_inp_str |
886 | #ifdef _GMP_H_HAVE_FILE |
887 | __GMP_DECLSPEC size_t mpz_inp_str (mpz_ptr, FILE *, int); |
888 | #endif |
889 | |
890 | #define mpz_invert __gmpz_invert |
891 | __GMP_DECLSPEC int mpz_invert (mpz_ptr, mpz_srcptr, mpz_srcptr); |
892 | |
893 | #define mpz_ior __gmpz_ior |
894 | __GMP_DECLSPEC void mpz_ior (mpz_ptr, mpz_srcptr, mpz_srcptr); |
895 | |
896 | #define mpz_jacobi __gmpz_jacobi |
897 | __GMP_DECLSPEC int mpz_jacobi (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE; |
898 | |
899 | #define mpz_kronecker mpz_jacobi /* alias */ |
900 | |
901 | #define mpz_kronecker_si __gmpz_kronecker_si |
902 | __GMP_DECLSPEC int mpz_kronecker_si (mpz_srcptr, long) __GMP_ATTRIBUTE_PURE; |
903 | |
904 | #define mpz_kronecker_ui __gmpz_kronecker_ui |
905 | __GMP_DECLSPEC int mpz_kronecker_ui (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE; |
906 | |
907 | #define mpz_si_kronecker __gmpz_si_kronecker |
908 | __GMP_DECLSPEC int mpz_si_kronecker (long, mpz_srcptr) __GMP_ATTRIBUTE_PURE; |
909 | |
910 | #define mpz_ui_kronecker __gmpz_ui_kronecker |
911 | __GMP_DECLSPEC int mpz_ui_kronecker (unsigned long, mpz_srcptr) __GMP_ATTRIBUTE_PURE; |
912 | |
913 | #define mpz_lcm __gmpz_lcm |
914 | __GMP_DECLSPEC void mpz_lcm (mpz_ptr, mpz_srcptr, mpz_srcptr); |
915 | |
916 | #define mpz_lcm_ui __gmpz_lcm_ui |
917 | __GMP_DECLSPEC void mpz_lcm_ui (mpz_ptr, mpz_srcptr, unsigned long); |
918 | |
919 | #define mpz_legendre mpz_jacobi /* alias */ |
920 | |
921 | #define mpz_lucnum_ui __gmpz_lucnum_ui |
922 | __GMP_DECLSPEC void mpz_lucnum_ui (mpz_ptr, unsigned long int); |
923 | |
924 | #define mpz_lucnum2_ui __gmpz_lucnum2_ui |
925 | __GMP_DECLSPEC void mpz_lucnum2_ui (mpz_ptr, mpz_ptr, unsigned long int); |
926 | |
927 | #define mpz_millerrabin __gmpz_millerrabin |
928 | __GMP_DECLSPEC int mpz_millerrabin (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE; |
929 | |
930 | #define mpz_mod __gmpz_mod |
931 | __GMP_DECLSPEC void mpz_mod (mpz_ptr, mpz_srcptr, mpz_srcptr); |
932 | |
933 | #define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */ |
934 | |
935 | #define mpz_mul __gmpz_mul |
936 | __GMP_DECLSPEC void mpz_mul (mpz_ptr, mpz_srcptr, mpz_srcptr); |
937 | |
938 | #define mpz_mul_2exp __gmpz_mul_2exp |
939 | __GMP_DECLSPEC void mpz_mul_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); |
940 | |
941 | #define mpz_mul_si __gmpz_mul_si |
942 | __GMP_DECLSPEC void mpz_mul_si (mpz_ptr, mpz_srcptr, long int); |
943 | |
944 | #define mpz_mul_ui __gmpz_mul_ui |
945 | __GMP_DECLSPEC void mpz_mul_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
946 | |
947 | #define mpz_neg __gmpz_neg |
948 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg) |
949 | __GMP_DECLSPEC void mpz_neg (mpz_ptr, mpz_srcptr); |
950 | #endif |
951 | |
952 | #define mpz_nextprime __gmpz_nextprime |
953 | __GMP_DECLSPEC void mpz_nextprime (mpz_ptr, mpz_srcptr); |
954 | |
955 | #define mpz_out_raw __gmpz_out_raw |
956 | #ifdef _GMP_H_HAVE_FILE |
957 | __GMP_DECLSPEC size_t mpz_out_raw (FILE *, mpz_srcptr); |
958 | #endif |
959 | |
960 | #define mpz_out_str __gmpz_out_str |
961 | #ifdef _GMP_H_HAVE_FILE |
962 | __GMP_DECLSPEC size_t mpz_out_str (FILE *, int, mpz_srcptr); |
963 | #endif |
964 | |
965 | #define mpz_perfect_power_p __gmpz_perfect_power_p |
966 | __GMP_DECLSPEC int mpz_perfect_power_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE; |
967 | |
968 | #define mpz_perfect_square_p __gmpz_perfect_square_p |
969 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p) |
970 | __GMP_DECLSPEC int mpz_perfect_square_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE; |
971 | #endif |
972 | |
973 | #define mpz_popcount __gmpz_popcount |
974 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount) |
975 | __GMP_DECLSPEC mp_bitcnt_t mpz_popcount (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
976 | #endif |
977 | |
978 | #define mpz_pow_ui __gmpz_pow_ui |
979 | __GMP_DECLSPEC void mpz_pow_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
980 | |
981 | #define mpz_powm __gmpz_powm |
982 | __GMP_DECLSPEC void mpz_powm (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); |
983 | |
984 | #define mpz_powm_sec __gmpz_powm_sec |
985 | __GMP_DECLSPEC void mpz_powm_sec (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); |
986 | |
987 | #define mpz_powm_ui __gmpz_powm_ui |
988 | __GMP_DECLSPEC void mpz_powm_ui (mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr); |
989 | |
990 | #define mpz_probab_prime_p __gmpz_probab_prime_p |
991 | __GMP_DECLSPEC int mpz_probab_prime_p (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE; |
992 | |
993 | #define mpz_random __gmpz_random |
994 | __GMP_DECLSPEC void mpz_random (mpz_ptr, mp_size_t); |
995 | |
996 | #define mpz_random2 __gmpz_random2 |
997 | __GMP_DECLSPEC void mpz_random2 (mpz_ptr, mp_size_t); |
998 | |
999 | #define mpz_realloc2 __gmpz_realloc2 |
1000 | __GMP_DECLSPEC void mpz_realloc2 (mpz_ptr, mp_bitcnt_t); |
1001 | |
1002 | #define mpz_remove __gmpz_remove |
1003 | __GMP_DECLSPEC mp_bitcnt_t mpz_remove (mpz_ptr, mpz_srcptr, mpz_srcptr); |
1004 | |
1005 | #define mpz_root __gmpz_root |
1006 | __GMP_DECLSPEC int mpz_root (mpz_ptr, mpz_srcptr, unsigned long int); |
1007 | |
1008 | #define mpz_rootrem __gmpz_rootrem |
1009 | __GMP_DECLSPEC void mpz_rootrem (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); |
1010 | |
1011 | #define mpz_rrandomb __gmpz_rrandomb |
1012 | __GMP_DECLSPEC void mpz_rrandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t); |
1013 | |
1014 | #define mpz_scan0 __gmpz_scan0 |
1015 | __GMP_DECLSPEC mp_bitcnt_t mpz_scan0 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1016 | |
1017 | #define mpz_scan1 __gmpz_scan1 |
1018 | __GMP_DECLSPEC mp_bitcnt_t mpz_scan1 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1019 | |
1020 | #define mpz_set __gmpz_set |
1021 | __GMP_DECLSPEC void mpz_set (mpz_ptr, mpz_srcptr); |
1022 | |
1023 | #define mpz_set_d __gmpz_set_d |
1024 | __GMP_DECLSPEC void mpz_set_d (mpz_ptr, double); |
1025 | |
1026 | #define mpz_set_f __gmpz_set_f |
1027 | __GMP_DECLSPEC void mpz_set_f (mpz_ptr, mpf_srcptr); |
1028 | |
1029 | #define mpz_set_q __gmpz_set_q |
1030 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q) |
1031 | __GMP_DECLSPEC void mpz_set_q (mpz_ptr, mpq_srcptr); |
1032 | #endif |
1033 | |
1034 | #define mpz_set_si __gmpz_set_si |
1035 | __GMP_DECLSPEC void mpz_set_si (mpz_ptr, signed long int); |
1036 | |
1037 | #define mpz_set_str __gmpz_set_str |
1038 | __GMP_DECLSPEC int mpz_set_str (mpz_ptr, const char *, int); |
1039 | |
1040 | #define mpz_set_ui __gmpz_set_ui |
1041 | __GMP_DECLSPEC void mpz_set_ui (mpz_ptr, unsigned long int); |
1042 | |
1043 | #define mpz_setbit __gmpz_setbit |
1044 | __GMP_DECLSPEC void mpz_setbit (mpz_ptr, mp_bitcnt_t); |
1045 | |
1046 | #define mpz_size __gmpz_size |
1047 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size) |
1048 | __GMP_DECLSPEC size_t mpz_size (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1049 | #endif |
1050 | |
1051 | #define mpz_sizeinbase __gmpz_sizeinbase |
1052 | __GMP_DECLSPEC size_t mpz_sizeinbase (mpz_srcptr, int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1053 | |
1054 | #define mpz_sqrt __gmpz_sqrt |
1055 | __GMP_DECLSPEC void mpz_sqrt (mpz_ptr, mpz_srcptr); |
1056 | |
1057 | #define mpz_sqrtrem __gmpz_sqrtrem |
1058 | __GMP_DECLSPEC void mpz_sqrtrem (mpz_ptr, mpz_ptr, mpz_srcptr); |
1059 | |
1060 | #define mpz_sub __gmpz_sub |
1061 | __GMP_DECLSPEC void mpz_sub (mpz_ptr, mpz_srcptr, mpz_srcptr); |
1062 | |
1063 | #define mpz_sub_ui __gmpz_sub_ui |
1064 | __GMP_DECLSPEC void mpz_sub_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
1065 | |
1066 | #define mpz_ui_sub __gmpz_ui_sub |
1067 | __GMP_DECLSPEC void mpz_ui_sub (mpz_ptr, unsigned long int, mpz_srcptr); |
1068 | |
1069 | #define mpz_submul __gmpz_submul |
1070 | __GMP_DECLSPEC void mpz_submul (mpz_ptr, mpz_srcptr, mpz_srcptr); |
1071 | |
1072 | #define mpz_submul_ui __gmpz_submul_ui |
1073 | __GMP_DECLSPEC void mpz_submul_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
1074 | |
1075 | #define mpz_swap __gmpz_swap |
1076 | __GMP_DECLSPEC void mpz_swap (mpz_ptr, mpz_ptr) __GMP_NOTHROW; |
1077 | |
1078 | #define mpz_tdiv_ui __gmpz_tdiv_ui |
1079 | __GMP_DECLSPEC unsigned long int mpz_tdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE; |
1080 | |
1081 | #define mpz_tdiv_q __gmpz_tdiv_q |
1082 | __GMP_DECLSPEC void mpz_tdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); |
1083 | |
1084 | #define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp |
1085 | __GMP_DECLSPEC void mpz_tdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); |
1086 | |
1087 | #define mpz_tdiv_q_ui __gmpz_tdiv_q_ui |
1088 | __GMP_DECLSPEC unsigned long int mpz_tdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
1089 | |
1090 | #define mpz_tdiv_qr __gmpz_tdiv_qr |
1091 | __GMP_DECLSPEC void mpz_tdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); |
1092 | |
1093 | #define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui |
1094 | __GMP_DECLSPEC unsigned long int mpz_tdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); |
1095 | |
1096 | #define mpz_tdiv_r __gmpz_tdiv_r |
1097 | __GMP_DECLSPEC void mpz_tdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); |
1098 | |
1099 | #define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp |
1100 | __GMP_DECLSPEC void mpz_tdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); |
1101 | |
1102 | #define mpz_tdiv_r_ui __gmpz_tdiv_r_ui |
1103 | __GMP_DECLSPEC unsigned long int mpz_tdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); |
1104 | |
1105 | #define mpz_tstbit __gmpz_tstbit |
1106 | __GMP_DECLSPEC int mpz_tstbit (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1107 | |
1108 | #define mpz_ui_pow_ui __gmpz_ui_pow_ui |
1109 | __GMP_DECLSPEC void mpz_ui_pow_ui (mpz_ptr, unsigned long int, unsigned long int); |
1110 | |
1111 | #define mpz_urandomb __gmpz_urandomb |
1112 | __GMP_DECLSPEC void mpz_urandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t); |
1113 | |
1114 | #define mpz_urandomm __gmpz_urandomm |
1115 | __GMP_DECLSPEC void mpz_urandomm (mpz_ptr, gmp_randstate_t, mpz_srcptr); |
1116 | |
1117 | #define mpz_xor __gmpz_xor |
1118 | #define mpz_eor __gmpz_xor |
1119 | __GMP_DECLSPEC void mpz_xor (mpz_ptr, mpz_srcptr, mpz_srcptr); |
1120 | |
1121 | #define mpz_limbs_read __gmpz_limbs_read |
1122 | __GMP_DECLSPEC mp_srcptr mpz_limbs_read (mpz_srcptr); |
1123 | |
1124 | #define mpz_limbs_write __gmpz_limbs_write |
1125 | __GMP_DECLSPEC mp_ptr mpz_limbs_write (mpz_ptr, mp_size_t); |
1126 | |
1127 | #define mpz_limbs_modify __gmpz_limbs_modify |
1128 | __GMP_DECLSPEC mp_ptr mpz_limbs_modify (mpz_ptr, mp_size_t); |
1129 | |
1130 | #define mpz_limbs_finish __gmpz_limbs_finish |
1131 | __GMP_DECLSPEC void mpz_limbs_finish (mpz_ptr, mp_size_t); |
1132 | |
1133 | #define mpz_roinit_n __gmpz_roinit_n |
1134 | __GMP_DECLSPEC mpz_srcptr mpz_roinit_n (mpz_ptr, mp_srcptr, mp_size_t); |
1135 | |
1136 | #define MPZ_ROINIT_N(xp, xs) {{0, (xs),(xp) }} |
1137 | |
1138 | /**************** Rational (i.e. Q) routines. ****************/ |
1139 | |
1140 | #define mpq_abs __gmpq_abs |
1141 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs) |
1142 | __GMP_DECLSPEC void mpq_abs (mpq_ptr, mpq_srcptr); |
1143 | #endif |
1144 | |
1145 | #define mpq_add __gmpq_add |
1146 | __GMP_DECLSPEC void mpq_add (mpq_ptr, mpq_srcptr, mpq_srcptr); |
1147 | |
1148 | #define mpq_canonicalize __gmpq_canonicalize |
1149 | __GMP_DECLSPEC void mpq_canonicalize (mpq_ptr); |
1150 | |
1151 | #define mpq_clear __gmpq_clear |
1152 | __GMP_DECLSPEC void mpq_clear (mpq_ptr); |
1153 | |
1154 | #define mpq_clears __gmpq_clears |
1155 | __GMP_DECLSPEC void mpq_clears (mpq_ptr, ...); |
1156 | |
1157 | #define mpq_cmp __gmpq_cmp |
1158 | __GMP_DECLSPEC int mpq_cmp (mpq_srcptr, mpq_srcptr) __GMP_ATTRIBUTE_PURE; |
1159 | |
1160 | #define _mpq_cmp_si __gmpq_cmp_si |
1161 | __GMP_DECLSPEC int _mpq_cmp_si (mpq_srcptr, long, unsigned long) __GMP_ATTRIBUTE_PURE; |
1162 | |
1163 | #define _mpq_cmp_ui __gmpq_cmp_ui |
1164 | __GMP_DECLSPEC int _mpq_cmp_ui (mpq_srcptr, unsigned long int, unsigned long int) __GMP_ATTRIBUTE_PURE; |
1165 | |
1166 | #define mpq_div __gmpq_div |
1167 | __GMP_DECLSPEC void mpq_div (mpq_ptr, mpq_srcptr, mpq_srcptr); |
1168 | |
1169 | #define mpq_div_2exp __gmpq_div_2exp |
1170 | __GMP_DECLSPEC void mpq_div_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t); |
1171 | |
1172 | #define mpq_equal __gmpq_equal |
1173 | __GMP_DECLSPEC int mpq_equal (mpq_srcptr, mpq_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1174 | |
1175 | #define mpq_get_num __gmpq_get_num |
1176 | __GMP_DECLSPEC void mpq_get_num (mpz_ptr, mpq_srcptr); |
1177 | |
1178 | #define mpq_get_den __gmpq_get_den |
1179 | __GMP_DECLSPEC void mpq_get_den (mpz_ptr, mpq_srcptr); |
1180 | |
1181 | #define mpq_get_d __gmpq_get_d |
1182 | __GMP_DECLSPEC double mpq_get_d (mpq_srcptr) __GMP_ATTRIBUTE_PURE; |
1183 | |
1184 | #define mpq_get_str __gmpq_get_str |
1185 | __GMP_DECLSPEC char *mpq_get_str (char *, int, mpq_srcptr); |
1186 | |
1187 | #define mpq_init __gmpq_init |
1188 | __GMP_DECLSPEC void mpq_init (mpq_ptr); |
1189 | |
1190 | #define mpq_inits __gmpq_inits |
1191 | __GMP_DECLSPEC void mpq_inits (mpq_ptr, ...); |
1192 | |
1193 | #define mpq_inp_str __gmpq_inp_str |
1194 | #ifdef _GMP_H_HAVE_FILE |
1195 | __GMP_DECLSPEC size_t mpq_inp_str (mpq_ptr, FILE *, int); |
1196 | #endif |
1197 | |
1198 | #define mpq_inv __gmpq_inv |
1199 | __GMP_DECLSPEC void mpq_inv (mpq_ptr, mpq_srcptr); |
1200 | |
1201 | #define mpq_mul __gmpq_mul |
1202 | __GMP_DECLSPEC void mpq_mul (mpq_ptr, mpq_srcptr, mpq_srcptr); |
1203 | |
1204 | #define mpq_mul_2exp __gmpq_mul_2exp |
1205 | __GMP_DECLSPEC void mpq_mul_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t); |
1206 | |
1207 | #define mpq_neg __gmpq_neg |
1208 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg) |
1209 | __GMP_DECLSPEC void mpq_neg (mpq_ptr, mpq_srcptr); |
1210 | #endif |
1211 | |
1212 | #define mpq_out_str __gmpq_out_str |
1213 | #ifdef _GMP_H_HAVE_FILE |
1214 | __GMP_DECLSPEC size_t mpq_out_str (FILE *, int, mpq_srcptr); |
1215 | #endif |
1216 | |
1217 | #define mpq_set __gmpq_set |
1218 | __GMP_DECLSPEC void mpq_set (mpq_ptr, mpq_srcptr); |
1219 | |
1220 | #define mpq_set_d __gmpq_set_d |
1221 | __GMP_DECLSPEC void mpq_set_d (mpq_ptr, double); |
1222 | |
1223 | #define mpq_set_den __gmpq_set_den |
1224 | __GMP_DECLSPEC void mpq_set_den (mpq_ptr, mpz_srcptr); |
1225 | |
1226 | #define mpq_set_f __gmpq_set_f |
1227 | __GMP_DECLSPEC void mpq_set_f (mpq_ptr, mpf_srcptr); |
1228 | |
1229 | #define mpq_set_num __gmpq_set_num |
1230 | __GMP_DECLSPEC void mpq_set_num (mpq_ptr, mpz_srcptr); |
1231 | |
1232 | #define mpq_set_si __gmpq_set_si |
1233 | __GMP_DECLSPEC void mpq_set_si (mpq_ptr, signed long int, unsigned long int); |
1234 | |
1235 | #define mpq_set_str __gmpq_set_str |
1236 | __GMP_DECLSPEC int mpq_set_str (mpq_ptr, const char *, int); |
1237 | |
1238 | #define mpq_set_ui __gmpq_set_ui |
1239 | __GMP_DECLSPEC void mpq_set_ui (mpq_ptr, unsigned long int, unsigned long int); |
1240 | |
1241 | #define mpq_set_z __gmpq_set_z |
1242 | __GMP_DECLSPEC void mpq_set_z (mpq_ptr, mpz_srcptr); |
1243 | |
1244 | #define mpq_sub __gmpq_sub |
1245 | __GMP_DECLSPEC void mpq_sub (mpq_ptr, mpq_srcptr, mpq_srcptr); |
1246 | |
1247 | #define mpq_swap __gmpq_swap |
1248 | __GMP_DECLSPEC void mpq_swap (mpq_ptr, mpq_ptr) __GMP_NOTHROW; |
1249 | |
1250 | |
1251 | /**************** Float (i.e. F) routines. ****************/ |
1252 | |
1253 | #define mpf_abs __gmpf_abs |
1254 | __GMP_DECLSPEC void mpf_abs (mpf_ptr, mpf_srcptr); |
1255 | |
1256 | #define mpf_add __gmpf_add |
1257 | __GMP_DECLSPEC void mpf_add (mpf_ptr, mpf_srcptr, mpf_srcptr); |
1258 | |
1259 | #define mpf_add_ui __gmpf_add_ui |
1260 | __GMP_DECLSPEC void mpf_add_ui (mpf_ptr, mpf_srcptr, unsigned long int); |
1261 | #define mpf_ceil __gmpf_ceil |
1262 | __GMP_DECLSPEC void mpf_ceil (mpf_ptr, mpf_srcptr); |
1263 | |
1264 | #define mpf_clear __gmpf_clear |
1265 | __GMP_DECLSPEC void mpf_clear (mpf_ptr); |
1266 | |
1267 | #define mpf_clears __gmpf_clears |
1268 | __GMP_DECLSPEC void mpf_clears (mpf_ptr, ...); |
1269 | |
1270 | #define mpf_cmp __gmpf_cmp |
1271 | __GMP_DECLSPEC int mpf_cmp (mpf_srcptr, mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1272 | |
1273 | #define mpf_cmp_d __gmpf_cmp_d |
1274 | __GMP_DECLSPEC int mpf_cmp_d (mpf_srcptr, double) __GMP_ATTRIBUTE_PURE; |
1275 | |
1276 | #define mpf_cmp_si __gmpf_cmp_si |
1277 | __GMP_DECLSPEC int mpf_cmp_si (mpf_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1278 | |
1279 | #define mpf_cmp_ui __gmpf_cmp_ui |
1280 | __GMP_DECLSPEC int mpf_cmp_ui (mpf_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1281 | |
1282 | #define mpf_div __gmpf_div |
1283 | __GMP_DECLSPEC void mpf_div (mpf_ptr, mpf_srcptr, mpf_srcptr); |
1284 | |
1285 | #define mpf_div_2exp __gmpf_div_2exp |
1286 | __GMP_DECLSPEC void mpf_div_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t); |
1287 | |
1288 | #define mpf_div_ui __gmpf_div_ui |
1289 | __GMP_DECLSPEC void mpf_div_ui (mpf_ptr, mpf_srcptr, unsigned long int); |
1290 | |
1291 | #define mpf_dump __gmpf_dump |
1292 | __GMP_DECLSPEC void mpf_dump (mpf_srcptr); |
1293 | |
1294 | #define mpf_eq __gmpf_eq |
1295 | __GMP_DECLSPEC int mpf_eq (mpf_srcptr, mpf_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE; |
1296 | |
1297 | #define mpf_fits_sint_p __gmpf_fits_sint_p |
1298 | __GMP_DECLSPEC int mpf_fits_sint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1299 | |
1300 | #define mpf_fits_slong_p __gmpf_fits_slong_p |
1301 | __GMP_DECLSPEC int mpf_fits_slong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1302 | |
1303 | #define mpf_fits_sshort_p __gmpf_fits_sshort_p |
1304 | __GMP_DECLSPEC int mpf_fits_sshort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1305 | |
1306 | #define mpf_fits_uint_p __gmpf_fits_uint_p |
1307 | __GMP_DECLSPEC int mpf_fits_uint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1308 | |
1309 | #define mpf_fits_ulong_p __gmpf_fits_ulong_p |
1310 | __GMP_DECLSPEC int mpf_fits_ulong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1311 | |
1312 | #define mpf_fits_ushort_p __gmpf_fits_ushort_p |
1313 | __GMP_DECLSPEC int mpf_fits_ushort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1314 | |
1315 | #define mpf_floor __gmpf_floor |
1316 | __GMP_DECLSPEC void mpf_floor (mpf_ptr, mpf_srcptr); |
1317 | |
1318 | #define mpf_get_d __gmpf_get_d |
1319 | __GMP_DECLSPEC double mpf_get_d (mpf_srcptr) __GMP_ATTRIBUTE_PURE; |
1320 | |
1321 | #define mpf_get_d_2exp __gmpf_get_d_2exp |
1322 | __GMP_DECLSPEC double mpf_get_d_2exp (signed long int *, mpf_srcptr); |
1323 | |
1324 | #define mpf_get_default_prec __gmpf_get_default_prec |
1325 | __GMP_DECLSPEC mp_bitcnt_t mpf_get_default_prec (void) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1326 | |
1327 | #define mpf_get_prec __gmpf_get_prec |
1328 | __GMP_DECLSPEC mp_bitcnt_t mpf_get_prec (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1329 | |
1330 | #define mpf_get_si __gmpf_get_si |
1331 | __GMP_DECLSPEC long mpf_get_si (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1332 | |
1333 | #define mpf_get_str __gmpf_get_str |
1334 | __GMP_DECLSPEC char *mpf_get_str (char *, mp_exp_t *, int, size_t, mpf_srcptr); |
1335 | |
1336 | #define mpf_get_ui __gmpf_get_ui |
1337 | __GMP_DECLSPEC unsigned long mpf_get_ui (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1338 | |
1339 | #define mpf_init __gmpf_init |
1340 | __GMP_DECLSPEC void mpf_init (mpf_ptr); |
1341 | |
1342 | #define mpf_init2 __gmpf_init2 |
1343 | __GMP_DECLSPEC void mpf_init2 (mpf_ptr, mp_bitcnt_t); |
1344 | |
1345 | #define mpf_inits __gmpf_inits |
1346 | __GMP_DECLSPEC void mpf_inits (mpf_ptr, ...); |
1347 | |
1348 | #define mpf_init_set __gmpf_init_set |
1349 | __GMP_DECLSPEC void mpf_init_set (mpf_ptr, mpf_srcptr); |
1350 | |
1351 | #define mpf_init_set_d __gmpf_init_set_d |
1352 | __GMP_DECLSPEC void mpf_init_set_d (mpf_ptr, double); |
1353 | |
1354 | #define mpf_init_set_si __gmpf_init_set_si |
1355 | __GMP_DECLSPEC void mpf_init_set_si (mpf_ptr, signed long int); |
1356 | |
1357 | #define mpf_init_set_str __gmpf_init_set_str |
1358 | __GMP_DECLSPEC int mpf_init_set_str (mpf_ptr, const char *, int); |
1359 | |
1360 | #define mpf_init_set_ui __gmpf_init_set_ui |
1361 | __GMP_DECLSPEC void mpf_init_set_ui (mpf_ptr, unsigned long int); |
1362 | |
1363 | #define mpf_inp_str __gmpf_inp_str |
1364 | #ifdef _GMP_H_HAVE_FILE |
1365 | __GMP_DECLSPEC size_t mpf_inp_str (mpf_ptr, FILE *, int); |
1366 | #endif |
1367 | |
1368 | #define mpf_integer_p __gmpf_integer_p |
1369 | __GMP_DECLSPEC int mpf_integer_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1370 | |
1371 | #define mpf_mul __gmpf_mul |
1372 | __GMP_DECLSPEC void mpf_mul (mpf_ptr, mpf_srcptr, mpf_srcptr); |
1373 | |
1374 | #define mpf_mul_2exp __gmpf_mul_2exp |
1375 | __GMP_DECLSPEC void mpf_mul_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t); |
1376 | |
1377 | #define mpf_mul_ui __gmpf_mul_ui |
1378 | __GMP_DECLSPEC void mpf_mul_ui (mpf_ptr, mpf_srcptr, unsigned long int); |
1379 | |
1380 | #define mpf_neg __gmpf_neg |
1381 | __GMP_DECLSPEC void mpf_neg (mpf_ptr, mpf_srcptr); |
1382 | |
1383 | #define mpf_out_str __gmpf_out_str |
1384 | #ifdef _GMP_H_HAVE_FILE |
1385 | __GMP_DECLSPEC size_t mpf_out_str (FILE *, int, size_t, mpf_srcptr); |
1386 | #endif |
1387 | |
1388 | #define mpf_pow_ui __gmpf_pow_ui |
1389 | __GMP_DECLSPEC void mpf_pow_ui (mpf_ptr, mpf_srcptr, unsigned long int); |
1390 | |
1391 | #define mpf_random2 __gmpf_random2 |
1392 | __GMP_DECLSPEC void mpf_random2 (mpf_ptr, mp_size_t, mp_exp_t); |
1393 | |
1394 | #define mpf_reldiff __gmpf_reldiff |
1395 | __GMP_DECLSPEC void mpf_reldiff (mpf_ptr, mpf_srcptr, mpf_srcptr); |
1396 | |
1397 | #define mpf_set __gmpf_set |
1398 | __GMP_DECLSPEC void mpf_set (mpf_ptr, mpf_srcptr); |
1399 | |
1400 | #define mpf_set_d __gmpf_set_d |
1401 | __GMP_DECLSPEC void mpf_set_d (mpf_ptr, double); |
1402 | |
1403 | #define mpf_set_default_prec __gmpf_set_default_prec |
1404 | __GMP_DECLSPEC void mpf_set_default_prec (mp_bitcnt_t) __GMP_NOTHROW; |
1405 | |
1406 | #define mpf_set_prec __gmpf_set_prec |
1407 | __GMP_DECLSPEC void mpf_set_prec (mpf_ptr, mp_bitcnt_t); |
1408 | |
1409 | #define mpf_set_prec_raw __gmpf_set_prec_raw |
1410 | __GMP_DECLSPEC void mpf_set_prec_raw (mpf_ptr, mp_bitcnt_t) __GMP_NOTHROW; |
1411 | |
1412 | #define mpf_set_q __gmpf_set_q |
1413 | __GMP_DECLSPEC void mpf_set_q (mpf_ptr, mpq_srcptr); |
1414 | |
1415 | #define mpf_set_si __gmpf_set_si |
1416 | __GMP_DECLSPEC void mpf_set_si (mpf_ptr, signed long int); |
1417 | |
1418 | #define mpf_set_str __gmpf_set_str |
1419 | __GMP_DECLSPEC int mpf_set_str (mpf_ptr, const char *, int); |
1420 | |
1421 | #define mpf_set_ui __gmpf_set_ui |
1422 | __GMP_DECLSPEC void mpf_set_ui (mpf_ptr, unsigned long int); |
1423 | |
1424 | #define mpf_set_z __gmpf_set_z |
1425 | __GMP_DECLSPEC void mpf_set_z (mpf_ptr, mpz_srcptr); |
1426 | |
1427 | #define mpf_size __gmpf_size |
1428 | __GMP_DECLSPEC size_t mpf_size (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1429 | |
1430 | #define mpf_sqrt __gmpf_sqrt |
1431 | __GMP_DECLSPEC void mpf_sqrt (mpf_ptr, mpf_srcptr); |
1432 | |
1433 | #define mpf_sqrt_ui __gmpf_sqrt_ui |
1434 | __GMP_DECLSPEC void mpf_sqrt_ui (mpf_ptr, unsigned long int); |
1435 | |
1436 | #define mpf_sub __gmpf_sub |
1437 | __GMP_DECLSPEC void mpf_sub (mpf_ptr, mpf_srcptr, mpf_srcptr); |
1438 | |
1439 | #define mpf_sub_ui __gmpf_sub_ui |
1440 | __GMP_DECLSPEC void mpf_sub_ui (mpf_ptr, mpf_srcptr, unsigned long int); |
1441 | |
1442 | #define mpf_swap __gmpf_swap |
1443 | __GMP_DECLSPEC void mpf_swap (mpf_ptr, mpf_ptr) __GMP_NOTHROW; |
1444 | |
1445 | #define mpf_trunc __gmpf_trunc |
1446 | __GMP_DECLSPEC void mpf_trunc (mpf_ptr, mpf_srcptr); |
1447 | |
1448 | #define mpf_ui_div __gmpf_ui_div |
1449 | __GMP_DECLSPEC void mpf_ui_div (mpf_ptr, unsigned long int, mpf_srcptr); |
1450 | |
1451 | #define mpf_ui_sub __gmpf_ui_sub |
1452 | __GMP_DECLSPEC void mpf_ui_sub (mpf_ptr, unsigned long int, mpf_srcptr); |
1453 | |
1454 | #define mpf_urandomb __gmpf_urandomb |
1455 | __GMP_DECLSPEC void mpf_urandomb (mpf_t, gmp_randstate_t, mp_bitcnt_t); |
1456 | |
1457 | |
1458 | /************ Low level positive-integer (i.e. N) routines. ************/ |
1459 | |
1460 | /* This is ugly, but we need to make user calls reach the prefixed function. */ |
1461 | |
1462 | #define mpn_add __MPN(add) |
1463 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add) |
1464 | __GMP_DECLSPEC mp_limb_t mpn_add (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); |
1465 | #endif |
1466 | |
1467 | #define mpn_add_1 __MPN(add_1) |
1468 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1) |
1469 | __GMP_DECLSPEC mp_limb_t mpn_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW; |
1470 | #endif |
1471 | |
1472 | #define mpn_add_n __MPN(add_n) |
1473 | __GMP_DECLSPEC mp_limb_t mpn_add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1474 | |
1475 | #define mpn_addmul_1 __MPN(addmul_1) |
1476 | __GMP_DECLSPEC mp_limb_t mpn_addmul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); |
1477 | |
1478 | #define mpn_cmp __MPN(cmp) |
1479 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp) |
1480 | __GMP_DECLSPEC int mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1481 | #endif |
1482 | |
1483 | #define mpn_divexact_by3(dst,src,size) \ |
1484 | mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0)) |
1485 | |
1486 | #define mpn_divexact_by3c __MPN(divexact_by3c) |
1487 | __GMP_DECLSPEC mp_limb_t mpn_divexact_by3c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); |
1488 | |
1489 | #define mpn_divmod_1(qp,np,nsize,dlimb) \ |
1490 | mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb) |
1491 | |
1492 | #define mpn_divrem __MPN(divrem) |
1493 | __GMP_DECLSPEC mp_limb_t mpn_divrem (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t); |
1494 | |
1495 | #define mpn_divrem_1 __MPN(divrem_1) |
1496 | __GMP_DECLSPEC mp_limb_t mpn_divrem_1 (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t); |
1497 | |
1498 | #define mpn_divrem_2 __MPN(divrem_2) |
1499 | __GMP_DECLSPEC mp_limb_t mpn_divrem_2 (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr); |
1500 | |
1501 | #define mpn_div_qr_1 __MPN(div_qr_1) |
1502 | __GMP_DECLSPEC mp_limb_t mpn_div_qr_1 (mp_ptr, mp_limb_t *, mp_srcptr, mp_size_t, mp_limb_t); |
1503 | |
1504 | #define mpn_div_qr_2 __MPN(div_qr_2) |
1505 | __GMP_DECLSPEC mp_limb_t mpn_div_qr_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); |
1506 | |
1507 | #define mpn_gcd __MPN(gcd) |
1508 | __GMP_DECLSPEC mp_size_t mpn_gcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t); |
1509 | |
1510 | #define mpn_gcd_1 __MPN(gcd_1) |
1511 | __GMP_DECLSPEC mp_limb_t mpn_gcd_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; |
1512 | |
1513 | #define mpn_gcdext_1 __MPN(gcdext_1) |
1514 | __GMP_DECLSPEC mp_limb_t mpn_gcdext_1 (mp_limb_signed_t *, mp_limb_signed_t *, mp_limb_t, mp_limb_t); |
1515 | |
1516 | #define mpn_gcdext __MPN(gcdext) |
1517 | __GMP_DECLSPEC mp_size_t mpn_gcdext (mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_size_t, mp_ptr, mp_size_t); |
1518 | |
1519 | #define mpn_get_str __MPN(get_str) |
1520 | __GMP_DECLSPEC size_t mpn_get_str (unsigned char *, int, mp_ptr, mp_size_t); |
1521 | |
1522 | #define mpn_hamdist __MPN(hamdist) |
1523 | __GMP_DECLSPEC mp_bitcnt_t mpn_hamdist (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1524 | |
1525 | #define mpn_lshift __MPN(lshift) |
1526 | __GMP_DECLSPEC mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); |
1527 | |
1528 | #define mpn_mod_1 __MPN(mod_1) |
1529 | __GMP_DECLSPEC mp_limb_t mpn_mod_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; |
1530 | |
1531 | #define mpn_mul __MPN(mul) |
1532 | __GMP_DECLSPEC mp_limb_t mpn_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); |
1533 | |
1534 | #define mpn_mul_1 __MPN(mul_1) |
1535 | __GMP_DECLSPEC mp_limb_t mpn_mul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); |
1536 | |
1537 | #define mpn_mul_n __MPN(mul_n) |
1538 | __GMP_DECLSPEC void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1539 | |
1540 | #define mpn_sqr __MPN(sqr) |
1541 | __GMP_DECLSPEC void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t); |
1542 | |
1543 | #define mpn_neg __MPN(neg) |
1544 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_neg) |
1545 | __GMP_DECLSPEC mp_limb_t mpn_neg (mp_ptr, mp_srcptr, mp_size_t); |
1546 | #endif |
1547 | |
1548 | #define mpn_com __MPN(com) |
1549 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_com) |
1550 | __GMP_DECLSPEC void mpn_com (mp_ptr, mp_srcptr, mp_size_t); |
1551 | #endif |
1552 | |
1553 | #define mpn_perfect_square_p __MPN(perfect_square_p) |
1554 | __GMP_DECLSPEC int mpn_perfect_square_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE; |
1555 | |
1556 | #define mpn_perfect_power_p __MPN(perfect_power_p) |
1557 | __GMP_DECLSPEC int mpn_perfect_power_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE; |
1558 | |
1559 | #define mpn_popcount __MPN(popcount) |
1560 | __GMP_DECLSPEC mp_bitcnt_t mpn_popcount (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; |
1561 | |
1562 | #define mpn_pow_1 __MPN(pow_1) |
1563 | __GMP_DECLSPEC mp_size_t mpn_pow_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); |
1564 | |
1565 | /* undocumented now, but retained here for upward compatibility */ |
1566 | #define mpn_preinv_mod_1 __MPN(preinv_mod_1) |
1567 | __GMP_DECLSPEC mp_limb_t mpn_preinv_mod_1 (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; |
1568 | |
1569 | #define mpn_random __MPN(random) |
1570 | __GMP_DECLSPEC void mpn_random (mp_ptr, mp_size_t); |
1571 | |
1572 | #define mpn_random2 __MPN(random2) |
1573 | __GMP_DECLSPEC void mpn_random2 (mp_ptr, mp_size_t); |
1574 | |
1575 | #define mpn_rshift __MPN(rshift) |
1576 | __GMP_DECLSPEC mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); |
1577 | |
1578 | #define mpn_scan0 __MPN(scan0) |
1579 | __GMP_DECLSPEC mp_bitcnt_t mpn_scan0 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE; |
1580 | |
1581 | #define mpn_scan1 __MPN(scan1) |
1582 | __GMP_DECLSPEC mp_bitcnt_t mpn_scan1 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE; |
1583 | |
1584 | #define mpn_set_str __MPN(set_str) |
1585 | __GMP_DECLSPEC mp_size_t mpn_set_str (mp_ptr, const unsigned char *, size_t, int); |
1586 | |
1587 | #define mpn_sizeinbase __MPN(sizeinbase) |
1588 | __GMP_DECLSPEC size_t mpn_sizeinbase (mp_srcptr, mp_size_t, int); |
1589 | |
1590 | #define mpn_sqrtrem __MPN(sqrtrem) |
1591 | __GMP_DECLSPEC mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t); |
1592 | |
1593 | #define mpn_sub __MPN(sub) |
1594 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub) |
1595 | __GMP_DECLSPEC mp_limb_t mpn_sub (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); |
1596 | #endif |
1597 | |
1598 | #define mpn_sub_1 __MPN(sub_1) |
1599 | #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1) |
1600 | __GMP_DECLSPEC mp_limb_t mpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW; |
1601 | #endif |
1602 | |
1603 | #define mpn_sub_n __MPN(sub_n) |
1604 | __GMP_DECLSPEC mp_limb_t mpn_sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1605 | |
1606 | #define mpn_submul_1 __MPN(submul_1) |
1607 | __GMP_DECLSPEC mp_limb_t mpn_submul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); |
1608 | |
1609 | #define mpn_tdiv_qr __MPN(tdiv_qr) |
1610 | __GMP_DECLSPEC void mpn_tdiv_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); |
1611 | |
1612 | #define mpn_and_n __MPN(and_n) |
1613 | __GMP_DECLSPEC void mpn_and_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1614 | #define mpn_andn_n __MPN(andn_n) |
1615 | __GMP_DECLSPEC void mpn_andn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1616 | #define mpn_nand_n __MPN(nand_n) |
1617 | __GMP_DECLSPEC void mpn_nand_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1618 | #define mpn_ior_n __MPN(ior_n) |
1619 | __GMP_DECLSPEC void mpn_ior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1620 | #define mpn_iorn_n __MPN(iorn_n) |
1621 | __GMP_DECLSPEC void mpn_iorn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1622 | #define mpn_nior_n __MPN(nior_n) |
1623 | __GMP_DECLSPEC void mpn_nior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1624 | #define mpn_xor_n __MPN(xor_n) |
1625 | __GMP_DECLSPEC void mpn_xor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1626 | #define mpn_xnor_n __MPN(xnor_n) |
1627 | __GMP_DECLSPEC void mpn_xnor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1628 | |
1629 | #define mpn_copyi __MPN(copyi) |
1630 | __GMP_DECLSPEC void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t); |
1631 | #define mpn_copyd __MPN(copyd) |
1632 | __GMP_DECLSPEC void mpn_copyd (mp_ptr, mp_srcptr, mp_size_t); |
1633 | #define mpn_zero __MPN(zero) |
1634 | __GMP_DECLSPEC void mpn_zero (mp_ptr, mp_size_t); |
1635 | |
1636 | #define mpn_cnd_add_n __MPN(cnd_add_n) |
1637 | __GMP_DECLSPEC mp_limb_t mpn_cnd_add_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1638 | #define mpn_cnd_sub_n __MPN(cnd_sub_n) |
1639 | __GMP_DECLSPEC mp_limb_t mpn_cnd_sub_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); |
1640 | |
1641 | #define mpn_sec_add_1 __MPN(sec_add_1) |
1642 | __GMP_DECLSPEC mp_limb_t mpn_sec_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); |
1643 | #define mpn_sec_add_1_itch __MPN(sec_add_1_itch) |
1644 | __GMP_DECLSPEC mp_size_t mpn_sec_add_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; |
1645 | |
1646 | #define mpn_sec_sub_1 __MPN(sec_sub_1) |
1647 | __GMP_DECLSPEC mp_limb_t mpn_sec_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); |
1648 | #define mpn_sec_sub_1_itch __MPN(sec_sub_1_itch) |
1649 | __GMP_DECLSPEC mp_size_t mpn_sec_sub_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; |
1650 | |
1651 | #define mpn_sec_mul __MPN(sec_mul) |
1652 | __GMP_DECLSPEC void mpn_sec_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); |
1653 | #define mpn_sec_mul_itch __MPN(sec_mul_itch) |
1654 | __GMP_DECLSPEC mp_size_t mpn_sec_mul_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE; |
1655 | |
1656 | #define mpn_sec_sqr __MPN(sec_sqr) |
1657 | __GMP_DECLSPEC void mpn_sec_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); |
1658 | #define mpn_sec_sqr_itch __MPN(sec_sqr_itch) |
1659 | __GMP_DECLSPEC mp_size_t mpn_sec_sqr_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; |
1660 | |
1661 | #define mpn_sec_powm __MPN(sec_powm) |
1662 | __GMP_DECLSPEC void mpn_sec_powm (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_bitcnt_t, mp_srcptr, mp_size_t, mp_ptr); |
1663 | #define mpn_sec_powm_itch __MPN(sec_powm_itch) |
1664 | __GMP_DECLSPEC mp_size_t mpn_sec_powm_itch (mp_size_t, mp_bitcnt_t, mp_size_t) __GMP_ATTRIBUTE_PURE; |
1665 | |
1666 | #define mpn_sec_tabselect __MPN(sec_tabselect) |
1667 | __GMP_DECLSPEC void mpn_sec_tabselect (volatile mp_limb_t *, volatile const mp_limb_t *, mp_size_t, mp_size_t, mp_size_t); |
1668 | |
1669 | #define mpn_sec_div_qr __MPN(sec_div_qr) |
1670 | __GMP_DECLSPEC mp_limb_t mpn_sec_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); |
1671 | #define mpn_sec_div_qr_itch __MPN(sec_div_qr_itch) |
1672 | __GMP_DECLSPEC mp_size_t mpn_sec_div_qr_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE; |
1673 | #define mpn_sec_div_r __MPN(sec_div_r) |
1674 | __GMP_DECLSPEC void mpn_sec_div_r (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); |
1675 | #define mpn_sec_div_r_itch __MPN(sec_div_r_itch) |
1676 | __GMP_DECLSPEC mp_size_t mpn_sec_div_r_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE; |
1677 | |
1678 | #define mpn_sec_invert __MPN(sec_invert) |
1679 | __GMP_DECLSPEC int mpn_sec_invert (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_bitcnt_t, mp_ptr); |
1680 | #define mpn_sec_invert_itch __MPN(sec_invert_itch) |
1681 | __GMP_DECLSPEC mp_size_t mpn_sec_invert_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; |
1682 | |
1683 | |
1684 | /**************** mpz inlines ****************/ |
1685 | |
1686 | /* The following are provided as inlines where possible, but always exist as |
1687 | library functions too, for binary compatibility. |
1688 | |
1689 | Within gmp itself this inlining generally isn't relied on, since it |
1690 | doesn't get done for all compilers, whereas if something is worth |
1691 | inlining then it's worth arranging always. |
1692 | |
1693 | There are two styles of inlining here. When the same bit of code is |
1694 | wanted for the inline as for the library version, then __GMP_FORCE_foo |
1695 | arranges for that code to be emitted and the __GMP_EXTERN_INLINE |
1696 | directive suppressed, eg. mpz_fits_uint_p. When a different bit of code |
1697 | is wanted for the inline than for the library version, then |
1698 | __GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs. */ |
1699 | |
1700 | #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs) |
1701 | __GMP_EXTERN_INLINE void |
1702 | mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) |
1703 | { |
1704 | if (__gmp_w != __gmp_u) |
1705 | mpz_set (__gmp_w, __gmp_u); |
1706 | __gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size); |
1707 | } |
1708 | #endif |
1709 | |
1710 | #if GMP_NAIL_BITS == 0 |
1711 | #define __GMPZ_FITS_UTYPE_P(z,maxval) \ |
1712 | mp_size_t __gmp_n = z->_mp_size; \ |
1713 | mp_ptr __gmp_p = z->_mp_d; \ |
1714 | return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval)); |
1715 | #else |
1716 | #define __GMPZ_FITS_UTYPE_P(z,maxval) \ |
1717 | mp_size_t __gmp_n = z->_mp_size; \ |
1718 | mp_ptr __gmp_p = z->_mp_d; \ |
1719 | return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval) \ |
1720 | || (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS))); |
1721 | #endif |
1722 | |
1723 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p) |
1724 | #if ! defined (__GMP_FORCE_mpz_fits_uint_p) |
1725 | __GMP_EXTERN_INLINE |
1726 | #endif |
1727 | int |
1728 | mpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW |
1729 | { |
1730 | __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_UINT_MAX); |
1731 | } |
1732 | #endif |
1733 | |
1734 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p) |
1735 | #if ! defined (__GMP_FORCE_mpz_fits_ulong_p) |
1736 | __GMP_EXTERN_INLINE |
1737 | #endif |
1738 | int |
1739 | mpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW |
1740 | { |
1741 | __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_ULONG_MAX); |
1742 | } |
1743 | #endif |
1744 | |
1745 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p) |
1746 | #if ! defined (__GMP_FORCE_mpz_fits_ushort_p) |
1747 | __GMP_EXTERN_INLINE |
1748 | #endif |
1749 | int |
1750 | mpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW |
1751 | { |
1752 | __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_USHRT_MAX); |
1753 | } |
1754 | #endif |
1755 | |
1756 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui) |
1757 | #if ! defined (__GMP_FORCE_mpz_get_ui) |
1758 | __GMP_EXTERN_INLINE |
1759 | #endif |
1760 | unsigned long |
1761 | mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW |
1762 | { |
1763 | mp_ptr __gmp_p = __gmp_z->_mp_d; |
1764 | mp_size_t __gmp_n = __gmp_z->_mp_size; |
1765 | mp_limb_t __gmp_l = __gmp_p[0]; |
1766 | /* This is a "#if" rather than a plain "if" so as to avoid gcc warnings |
1767 | about "<< GMP_NUMB_BITS" exceeding the type size, and to avoid Borland |
1768 | C++ 6.0 warnings about condition always true for something like |
1769 | "__GMP_ULONG_MAX < GMP_NUMB_MASK". */ |
1770 | #if GMP_NAIL_BITS == 0 || defined (_LONG_LONG_LIMB) |
1771 | /* limb==long and no nails, or limb==longlong, one limb is enough */ |
1772 | return (__gmp_n != 0 ? __gmp_l : 0); |
1773 | #else |
1774 | /* limb==long and nails, need two limbs when available */ |
1775 | __gmp_n = __GMP_ABS (__gmp_n); |
1776 | if (__gmp_n <= 1) |
1777 | return (__gmp_n != 0 ? __gmp_l : 0); |
1778 | else |
1779 | return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS); |
1780 | #endif |
1781 | } |
1782 | #endif |
1783 | |
1784 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn) |
1785 | #if ! defined (__GMP_FORCE_mpz_getlimbn) |
1786 | __GMP_EXTERN_INLINE |
1787 | #endif |
1788 | mp_limb_t |
1789 | mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW |
1790 | { |
1791 | mp_limb_t __gmp_result = 0; |
1792 | if (__GMP_LIKELY (__gmp_n >= 0 && __gmp_n < __GMP_ABS (__gmp_z->_mp_size))) |
1793 | __gmp_result = __gmp_z->_mp_d[__gmp_n]; |
1794 | return __gmp_result; |
1795 | } |
1796 | #endif |
1797 | |
1798 | #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg) |
1799 | __GMP_EXTERN_INLINE void |
1800 | mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) |
1801 | { |
1802 | if (__gmp_w != __gmp_u) |
1803 | mpz_set (__gmp_w, __gmp_u); |
1804 | __gmp_w->_mp_size = - __gmp_w->_mp_size; |
1805 | } |
1806 | #endif |
1807 | |
1808 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p) |
1809 | #if ! defined (__GMP_FORCE_mpz_perfect_square_p) |
1810 | __GMP_EXTERN_INLINE |
1811 | #endif |
1812 | int |
1813 | mpz_perfect_square_p (mpz_srcptr __gmp_a) |
1814 | { |
1815 | mp_size_t __gmp_asize; |
1816 | int __gmp_result; |
1817 | |
1818 | __gmp_asize = __gmp_a->_mp_size; |
1819 | __gmp_result = (__gmp_asize >= 0); /* zero is a square, negatives are not */ |
1820 | if (__GMP_LIKELY (__gmp_asize > 0)) |
1821 | __gmp_result = mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize); |
1822 | return __gmp_result; |
1823 | } |
1824 | #endif |
1825 | |
1826 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount) |
1827 | #if ! defined (__GMP_FORCE_mpz_popcount) |
1828 | __GMP_EXTERN_INLINE |
1829 | #endif |
1830 | mp_bitcnt_t |
1831 | mpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW |
1832 | { |
1833 | mp_size_t __gmp_usize; |
1834 | mp_bitcnt_t __gmp_result; |
1835 | |
1836 | __gmp_usize = __gmp_u->_mp_size; |
1837 | __gmp_result = (__gmp_usize < 0 ? __GMP_ULONG_MAX : 0); |
1838 | if (__GMP_LIKELY (__gmp_usize > 0)) |
1839 | __gmp_result = mpn_popcount (__gmp_u->_mp_d, __gmp_usize); |
1840 | return __gmp_result; |
1841 | } |
1842 | #endif |
1843 | |
1844 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q) |
1845 | #if ! defined (__GMP_FORCE_mpz_set_q) |
1846 | __GMP_EXTERN_INLINE |
1847 | #endif |
1848 | void |
1849 | mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u) |
1850 | { |
1851 | mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u)); |
1852 | } |
1853 | #endif |
1854 | |
1855 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size) |
1856 | #if ! defined (__GMP_FORCE_mpz_size) |
1857 | __GMP_EXTERN_INLINE |
1858 | #endif |
1859 | size_t |
1860 | mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW |
1861 | { |
1862 | return __GMP_ABS (__gmp_z->_mp_size); |
1863 | } |
1864 | #endif |
1865 | |
1866 | |
1867 | /**************** mpq inlines ****************/ |
1868 | |
1869 | #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs) |
1870 | __GMP_EXTERN_INLINE void |
1871 | mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) |
1872 | { |
1873 | if (__gmp_w != __gmp_u) |
1874 | mpq_set (__gmp_w, __gmp_u); |
1875 | __gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size); |
1876 | } |
1877 | #endif |
1878 | |
1879 | #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg) |
1880 | __GMP_EXTERN_INLINE void |
1881 | mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) |
1882 | { |
1883 | if (__gmp_w != __gmp_u) |
1884 | mpq_set (__gmp_w, __gmp_u); |
1885 | __gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size; |
1886 | } |
1887 | #endif |
1888 | |
1889 | |
1890 | /**************** mpn inlines ****************/ |
1891 | |
1892 | /* The comments with __GMPN_ADD_1 below apply here too. |
1893 | |
1894 | The test for FUNCTION returning 0 should predict well. If it's assumed |
1895 | {yp,ysize} will usually have a random number of bits then the high limb |
1896 | won't be full and a carry out will occur a good deal less than 50% of the |
1897 | time. |
1898 | |
1899 | ysize==0 isn't a documented feature, but is used internally in a few |
1900 | places. |
1901 | |
1902 | Producing cout last stops it using up a register during the main part of |
1903 | the calculation, though gcc (as of 3.0) on an "if (mpn_add (...))" |
1904 | doesn't seem able to move the true and false legs of the conditional up |
1905 | to the two places cout is generated. */ |
1906 | |
1907 | #define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST) \ |
1908 | do { \ |
1909 | mp_size_t __gmp_i; \ |
1910 | mp_limb_t __gmp_x; \ |
1911 | \ |
1912 | /* ASSERT ((ysize) >= 0); */ \ |
1913 | /* ASSERT ((xsize) >= (ysize)); */ \ |
1914 | /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */ \ |
1915 | /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */ \ |
1916 | \ |
1917 | __gmp_i = (ysize); \ |
1918 | if (__gmp_i != 0) \ |
1919 | { \ |
1920 | if (FUNCTION (wp, xp, yp, __gmp_i)) \ |
1921 | { \ |
1922 | do \ |
1923 | { \ |
1924 | if (__gmp_i >= (xsize)) \ |
1925 | { \ |
1926 | (cout) = 1; \ |
1927 | goto __gmp_done; \ |
1928 | } \ |
1929 | __gmp_x = (xp)[__gmp_i]; \ |
1930 | } \ |
1931 | while (TEST); \ |
1932 | } \ |
1933 | } \ |
1934 | if ((wp) != (xp)) \ |
1935 | __GMPN_COPY_REST (wp, xp, xsize, __gmp_i); \ |
1936 | (cout) = 0; \ |
1937 | __gmp_done: \ |
1938 | ; \ |
1939 | } while (0) |
1940 | |
1941 | #define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize) \ |
1942 | __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n, \ |
1943 | (((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0)) |
1944 | #define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize) \ |
1945 | __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n, \ |
1946 | (((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0)) |
1947 | |
1948 | |
1949 | /* The use of __gmp_i indexing is designed to ensure a compile time src==dst |
1950 | remains nice and clear to the compiler, so that __GMPN_COPY_REST can |
1951 | disappear, and the load/add/store gets a chance to become a |
1952 | read-modify-write on CISC CPUs. |
1953 | |
1954 | Alternatives: |
1955 | |
1956 | Using a pair of pointers instead of indexing would be possible, but gcc |
1957 | isn't able to recognise compile-time src==dst in that case, even when the |
1958 | pointers are incremented more or less together. Other compilers would |
1959 | very likely have similar difficulty. |
1960 | |
1961 | gcc could use "if (__builtin_constant_p(src==dst) && src==dst)" or |
1962 | similar to detect a compile-time src==dst. This works nicely on gcc |
1963 | 2.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems |
1964 | to be always false, for a pointer p. But the current code form seems |
1965 | good enough for src==dst anyway. |
1966 | |
1967 | gcc on x86 as usual doesn't give particularly good flags handling for the |
1968 | carry/borrow detection. It's tempting to want some multi instruction asm |
1969 | blocks to help it, and this was tried, but in truth there's only a few |
1970 | instructions to save and any gain is all too easily lost by register |
1971 | juggling setting up for the asm. */ |
1972 | |
1973 | #if GMP_NAIL_BITS == 0 |
1974 | #define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \ |
1975 | do { \ |
1976 | mp_size_t __gmp_i; \ |
1977 | mp_limb_t __gmp_x, __gmp_r; \ |
1978 | \ |
1979 | /* ASSERT ((n) >= 1); */ \ |
1980 | /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \ |
1981 | \ |
1982 | __gmp_x = (src)[0]; \ |
1983 | __gmp_r = __gmp_x OP (v); \ |
1984 | (dst)[0] = __gmp_r; \ |
1985 | if (CB (__gmp_r, __gmp_x, (v))) \ |
1986 | { \ |
1987 | (cout) = 1; \ |
1988 | for (__gmp_i = 1; __gmp_i < (n);) \ |
1989 | { \ |
1990 | __gmp_x = (src)[__gmp_i]; \ |
1991 | __gmp_r = __gmp_x OP 1; \ |
1992 | (dst)[__gmp_i] = __gmp_r; \ |
1993 | ++__gmp_i; \ |
1994 | if (!CB (__gmp_r, __gmp_x, 1)) \ |
1995 | { \ |
1996 | if ((src) != (dst)) \ |
1997 | __GMPN_COPY_REST (dst, src, n, __gmp_i); \ |
1998 | (cout) = 0; \ |
1999 | break; \ |
2000 | } \ |
2001 | } \ |
2002 | } \ |
2003 | else \ |
2004 | { \ |
2005 | if ((src) != (dst)) \ |
2006 | __GMPN_COPY_REST (dst, src, n, 1); \ |
2007 | (cout) = 0; \ |
2008 | } \ |
2009 | } while (0) |
2010 | #endif |
2011 | |
2012 | #if GMP_NAIL_BITS >= 1 |
2013 | #define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \ |
2014 | do { \ |
2015 | mp_size_t __gmp_i; \ |
2016 | mp_limb_t __gmp_x, __gmp_r; \ |
2017 | \ |
2018 | /* ASSERT ((n) >= 1); */ \ |
2019 | /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \ |
2020 | \ |
2021 | __gmp_x = (src)[0]; \ |
2022 | __gmp_r = __gmp_x OP (v); \ |
2023 | (dst)[0] = __gmp_r & GMP_NUMB_MASK; \ |
2024 | if (__gmp_r >> GMP_NUMB_BITS != 0) \ |
2025 | { \ |
2026 | (cout) = 1; \ |
2027 | for (__gmp_i = 1; __gmp_i < (n);) \ |
2028 | { \ |
2029 | __gmp_x = (src)[__gmp_i]; \ |
2030 | __gmp_r = __gmp_x OP 1; \ |
2031 | (dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK; \ |
2032 | ++__gmp_i; \ |
2033 | if (__gmp_r >> GMP_NUMB_BITS == 0) \ |
2034 | { \ |
2035 | if ((src) != (dst)) \ |
2036 | __GMPN_COPY_REST (dst, src, n, __gmp_i); \ |
2037 | (cout) = 0; \ |
2038 | break; \ |
2039 | } \ |
2040 | } \ |
2041 | } \ |
2042 | else \ |
2043 | { \ |
2044 | if ((src) != (dst)) \ |
2045 | __GMPN_COPY_REST (dst, src, n, 1); \ |
2046 | (cout) = 0; \ |
2047 | } \ |
2048 | } while (0) |
2049 | #endif |
2050 | |
2051 | #define __GMPN_ADDCB(r,x,y) ((r) < (y)) |
2052 | #define __GMPN_SUBCB(r,x,y) ((x) < (y)) |
2053 | |
2054 | #define __GMPN_ADD_1(cout, dst, src, n, v) \ |
2055 | __GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB) |
2056 | #define __GMPN_SUB_1(cout, dst, src, n, v) \ |
2057 | __GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB) |
2058 | |
2059 | |
2060 | /* Compare {xp,size} and {yp,size}, setting "result" to positive, zero or |
2061 | negative. size==0 is allowed. On random data usually only one limb will |
2062 | need to be examined to get a result, so it's worth having it inline. */ |
2063 | #define __GMPN_CMP(result, xp, yp, size) \ |
2064 | do { \ |
2065 | mp_size_t __gmp_i; \ |
2066 | mp_limb_t __gmp_x, __gmp_y; \ |
2067 | \ |
2068 | /* ASSERT ((size) >= 0); */ \ |
2069 | \ |
2070 | (result) = 0; \ |
2071 | __gmp_i = (size); \ |
2072 | while (--__gmp_i >= 0) \ |
2073 | { \ |
2074 | __gmp_x = (xp)[__gmp_i]; \ |
2075 | __gmp_y = (yp)[__gmp_i]; \ |
2076 | if (__gmp_x != __gmp_y) \ |
2077 | { \ |
2078 | /* Cannot use __gmp_x - __gmp_y, may overflow an "int" */ \ |
2079 | (result) = (__gmp_x > __gmp_y ? 1 : -1); \ |
2080 | break; \ |
2081 | } \ |
2082 | } \ |
2083 | } while (0) |
2084 | |
2085 | |
2086 | #if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST) |
2087 | #define __GMPN_COPY_REST(dst, src, size, start) \ |
2088 | do { \ |
2089 | /* ASSERT ((start) >= 0); */ \ |
2090 | /* ASSERT ((start) <= (size)); */ \ |
2091 | __GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \ |
2092 | } while (0) |
2093 | #endif |
2094 | |
2095 | /* Copy {src,size} to {dst,size}, starting at "start". This is designed to |
2096 | keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1, |
2097 | __GMPN_ADD, etc. */ |
2098 | #if ! defined (__GMPN_COPY_REST) |
2099 | #define __GMPN_COPY_REST(dst, src, size, start) \ |
2100 | do { \ |
2101 | mp_size_t __gmp_j; \ |
2102 | /* ASSERT ((size) >= 0); */ \ |
2103 | /* ASSERT ((start) >= 0); */ \ |
2104 | /* ASSERT ((start) <= (size)); */ \ |
2105 | /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */ \ |
2106 | __GMP_CRAY_Pragma ("_CRI ivdep"); \ |
2107 | for (__gmp_j = (start); __gmp_j < (size); __gmp_j++) \ |
2108 | (dst)[__gmp_j] = (src)[__gmp_j]; \ |
2109 | } while (0) |
2110 | #endif |
2111 | |
2112 | /* Enhancement: Use some of the smarter code from gmp-impl.h. Maybe use |
2113 | mpn_copyi if there's a native version, and if we don't mind demanding |
2114 | binary compatibility for it (on targets which use it). */ |
2115 | |
2116 | #if ! defined (__GMPN_COPY) |
2117 | #define __GMPN_COPY(dst, src, size) __GMPN_COPY_REST (dst, src, size, 0) |
2118 | #endif |
2119 | |
2120 | |
2121 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add) |
2122 | #if ! defined (__GMP_FORCE_mpn_add) |
2123 | __GMP_EXTERN_INLINE |
2124 | #endif |
2125 | mp_limb_t |
2126 | mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) |
2127 | { |
2128 | mp_limb_t __gmp_c; |
2129 | __GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize); |
2130 | return __gmp_c; |
2131 | } |
2132 | #endif |
2133 | |
2134 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1) |
2135 | #if ! defined (__GMP_FORCE_mpn_add_1) |
2136 | __GMP_EXTERN_INLINE |
2137 | #endif |
2138 | mp_limb_t |
2139 | mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW |
2140 | { |
2141 | mp_limb_t __gmp_c; |
2142 | __GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n); |
2143 | return __gmp_c; |
2144 | } |
2145 | #endif |
2146 | |
2147 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp) |
2148 | #if ! defined (__GMP_FORCE_mpn_cmp) |
2149 | __GMP_EXTERN_INLINE |
2150 | #endif |
2151 | int |
2152 | mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW |
2153 | { |
2154 | int __gmp_result; |
2155 | __GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size); |
2156 | return __gmp_result; |
2157 | } |
2158 | #endif |
2159 | |
2160 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub) |
2161 | #if ! defined (__GMP_FORCE_mpn_sub) |
2162 | __GMP_EXTERN_INLINE |
2163 | #endif |
2164 | mp_limb_t |
2165 | mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) |
2166 | { |
2167 | mp_limb_t __gmp_c; |
2168 | __GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize); |
2169 | return __gmp_c; |
2170 | } |
2171 | #endif |
2172 | |
2173 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1) |
2174 | #if ! defined (__GMP_FORCE_mpn_sub_1) |
2175 | __GMP_EXTERN_INLINE |
2176 | #endif |
2177 | mp_limb_t |
2178 | mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW |
2179 | { |
2180 | mp_limb_t __gmp_c; |
2181 | __GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n); |
2182 | return __gmp_c; |
2183 | } |
2184 | #endif |
2185 | |
2186 | #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_neg) |
2187 | #if ! defined (__GMP_FORCE_mpn_neg) |
2188 | __GMP_EXTERN_INLINE |
2189 | #endif |
2190 | mp_limb_t |
2191 | mpn_neg (mp_ptr __gmp_rp, mp_srcptr __gmp_up, mp_size_t __gmp_n) |
2192 | { |
2193 | mp_limb_t __gmp_ul, __gmp_cy; |
2194 | __gmp_cy = 0; |
2195 | do { |
2196 | __gmp_ul = *__gmp_up++; |
2197 | *__gmp_rp++ = -__gmp_ul - __gmp_cy; |
2198 | __gmp_cy |= __gmp_ul != 0; |
2199 | } while (--__gmp_n != 0); |
2200 | return __gmp_cy; |
2201 | } |
2202 | #endif |
2203 | |
2204 | #if defined (__cplusplus) |
2205 | } |
2206 | #endif |
2207 | |
2208 | |
2209 | /* Allow faster testing for negative, zero, and positive. */ |
2210 | #define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0) |
2211 | #define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0) |
2212 | #define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0) |
2213 | |
2214 | /* When using GCC, optimize certain common comparisons. */ |
2215 | #if defined (__GNUC__) && __GNUC__ >= 2 |
2216 | #define mpz_cmp_ui(Z,UI) \ |
2217 | (__builtin_constant_p (UI) && (UI) == 0 \ |
2218 | ? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI)) |
2219 | #define mpz_cmp_si(Z,SI) \ |
2220 | (__builtin_constant_p ((SI) >= 0) && (SI) >= 0 \ |
2221 | ? mpz_cmp_ui (Z, __GMP_CAST (unsigned long, SI)) \ |
2222 | : _mpz_cmp_si (Z,SI)) |
2223 | #define mpq_cmp_ui(Q,NUI,DUI) \ |
2224 | (__builtin_constant_p (NUI) && (NUI) == 0 ? mpq_sgn (Q) \ |
2225 | : __builtin_constant_p ((NUI) == (DUI)) && (NUI) == (DUI) \ |
2226 | ? mpz_cmp (mpq_numref (Q), mpq_denref (Q)) \ |
2227 | : _mpq_cmp_ui (Q,NUI,DUI)) |
2228 | #define mpq_cmp_si(q,n,d) \ |
2229 | (__builtin_constant_p ((n) >= 0) && (n) >= 0 \ |
2230 | ? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d) \ |
2231 | : _mpq_cmp_si (q, n, d)) |
2232 | #else |
2233 | #define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI) |
2234 | #define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI) |
2235 | #define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI) |
2236 | #define mpq_cmp_si(q,n,d) _mpq_cmp_si(q,n,d) |
2237 | #endif |
2238 | |
2239 | |
2240 | /* Using "&" rather than "&&" means these can come out branch-free. Every |
2241 | mpz_t has at least one limb allocated, so fetching the low limb is always |
2242 | allowed. */ |
2243 | #define mpz_odd_p(z) (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0])) |
2244 | #define mpz_even_p(z) (! mpz_odd_p (z)) |
2245 | |
2246 | |
2247 | /**************** C++ routines ****************/ |
2248 | |
2249 | #ifdef __cplusplus |
2250 | __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr); |
2251 | __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr); |
2252 | __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr); |
2253 | __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr); |
2254 | __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr); |
2255 | __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr); |
2256 | #endif |
2257 | |
2258 | |
2259 | /* Source-level compatibility with GMP 2 and earlier. */ |
2260 | #define mpn_divmod(qp,np,nsize,dp,dsize) \ |
2261 | mpn_divrem (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dp, dsize) |
2262 | |
2263 | /* Source-level compatibility with GMP 1. */ |
2264 | #define mpz_mdiv mpz_fdiv_q |
2265 | #define mpz_mdivmod mpz_fdiv_qr |
2266 | #define mpz_mmod mpz_fdiv_r |
2267 | #define mpz_mdiv_ui mpz_fdiv_q_ui |
2268 | #define mpz_mdivmod_ui(q,r,n,d) \ |
2269 | (((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d)) |
2270 | #define mpz_mmod_ui(r,n,d) \ |
2271 | (((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d)) |
2272 | |
2273 | /* Useful synonyms, but not quite compatible with GMP 1. */ |
2274 | #define mpz_div mpz_fdiv_q |
2275 | #define mpz_divmod mpz_fdiv_qr |
2276 | #define mpz_div_ui mpz_fdiv_q_ui |
2277 | #define mpz_divmod_ui mpz_fdiv_qr_ui |
2278 | #define mpz_div_2exp mpz_fdiv_q_2exp |
2279 | #define mpz_mod_2exp mpz_fdiv_r_2exp |
2280 | |
2281 | enum |
2282 | { |
2283 | GMP_ERROR_NONE = 0, |
2284 | GMP_ERROR_UNSUPPORTED_ARGUMENT = 1, |
2285 | GMP_ERROR_DIVISION_BY_ZERO = 2, |
2286 | GMP_ERROR_SQRT_OF_NEGATIVE = 4, |
2287 | GMP_ERROR_INVALID_ARGUMENT = 8 |
2288 | }; |
2289 | |
2290 | /* Define CC and CFLAGS which were used to build this version of GMP */ |
2291 | #define __GMP_CC "gcc -std=gnu99" |
2292 | #define __GMP_CFLAGS "-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4" |
2293 | |
2294 | /* Major version number is the value of __GNU_MP__ too, above and in mp.h. */ |
2295 | #define __GNU_MP_VERSION 6 |
2296 | #define __GNU_MP_VERSION_MINOR 0 |
2297 | #define __GNU_MP_VERSION_PATCHLEVEL 0 |
2298 | #define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL) |
2299 | |
2300 | #define __GMP_H__ |
2301 | #endif /* __GMP_H__ */ |
2302 | |