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