1 /* Definitions for GNU multiple precision functions. -*- mode: c -*-
3 Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
4 2004, 2005, 2006 Free Software Foundation, Inc.
6 This file is part of the GNU MP Library.
8 The GNU MP Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or (at your
11 option) any later version.
13 The GNU MP Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 MA 02110-1301, USA. */
25 #if defined (__cplusplus)
26 #include <iosfwd> /* for std::istream, std::ostream, std::string */
30 /* Instantiated by configure. */
31 #if ! defined (__GMP_WITHIN_CONFIGURE)
32 #define __GMP_BITS_PER_MP_LIMB @BITS_PER_MP_LIMB@
33 #define __GMP_HAVE_HOST_CPU_FAMILY_power @HAVE_HOST_CPU_FAMILY_power@
34 #define __GMP_HAVE_HOST_CPU_FAMILY_powerpc @HAVE_HOST_CPU_FAMILY_powerpc@
35 #define GMP_LIMB_BITS @BITS_PER_MP_LIMB@
36 #define GMP_NAIL_BITS @GMP_NAIL_BITS@
38 #define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS)
39 #define GMP_NUMB_MASK ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS)
40 #define GMP_NUMB_MAX GMP_NUMB_MASK
41 #define GMP_NAIL_MASK (~ GMP_NUMB_MASK)
44 /* The following (everything under ifndef __GNU_MP__) must be identical in
45 gmp.h and mp.h to allow both to be included in an application or during
50 #define __need_size_t /* tell gcc stddef.h we only want size_t */
51 #if defined (__cplusplus)
52 #include <cstddef> /* for size_t */
54 #include <stddef.h> /* for size_t */
58 /* Instantiated by configure. */
59 #if ! defined (__GMP_WITHIN_CONFIGURE)
61 #define __GMP_LIBGMP_DLL @LIBGMP_DLL@
65 /* __STDC__ - some ANSI compilers define this only to 0, hence the use of
66 "defined" and not "__STDC__-0". In particular Sun workshop C 5.0
67 sets __STDC__ to 0, but requires "##" for token pasting.
69 _AIX - gnu ansidecl.h asserts that all known AIX compilers are ANSI but
70 don't always define __STDC__.
72 __DECC - current versions of DEC C (5.9 for instance) for alpha are ANSI,
73 but don't define __STDC__ in their default mode. Don't know if old
74 versions might have been K&R, but let's not worry about that unless
75 someone is still using one.
77 _mips - gnu ansidecl.h says the RISC/OS MIPS compiler is ANSI in SVR4
78 mode, but doesn't define __STDC__.
80 _MSC_VER - Microsoft C is ANSI, but __STDC__ is undefined unless the /Za
81 option is given (in which case it's 1).
83 _WIN32 - tested for by gnu ansidecl.h, no doubt on the assumption that
84 all w32 compilers are ansi.
86 Note: This same set of tests is used by gen-psqr.c and
87 demos/expr/expr-impl.h, so if anything needs adding, then be sure to
90 #if defined (__STDC__) \
91 || defined (__cplusplus) \
94 || (defined (__mips) && defined (_SYSTYPE_SVR4)) \
95 || defined (_MSC_VER) \
97 #define __GMP_HAVE_CONST 1
98 #define __GMP_HAVE_PROTOTYPES 1
99 #define __GMP_HAVE_TOKEN_PASTE 1
101 #define __GMP_HAVE_CONST 0
102 #define __GMP_HAVE_PROTOTYPES 0
103 #define __GMP_HAVE_TOKEN_PASTE 0
108 #define __gmp_const const
109 #define __gmp_signed signed
116 /* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in
117 all other circumstances.
119 When compiling objects for libgmp, __GMP_DECLSPEC is an export directive,
120 or when compiling for an application it's an import directive. The two
121 cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles
122 (and not defined from an application).
124 __GMP_DECLSPEC_XX is similarly used for libgmpxx. __GMP_WITHIN_GMPXX
125 indicates when building libgmpxx, and in that case libgmpxx functions are
126 exports, but libgmp functions which might get called are imports.
128 libmp.la uses __GMP_DECLSPEC, just as if it were libgmp.la. libgmp and
129 libmp don't call each other, so there's no conflict or confusion.
131 Libtool DLL_EXPORT define is not used.
133 There's no attempt to support GMP built both static and DLL. Doing so
134 would mean applications would have to tell us which of the two is going
135 to be used when linking, and that seems very tedious and error prone if
136 using GMP by hand, and equally tedious from a package since autoconf and
137 automake don't give much help.
139 __GMP_DECLSPEC is required on all documented global functions and
140 variables, the various internals in gmp-impl.h etc can be left unadorned.
141 But internals used by the test programs or speed measuring programs
142 should have __GMP_DECLSPEC, and certainly constants or variables must
143 have it or the wrong address will be resolved.
145 In gcc __declspec can go at either the start or end of a prototype.
147 In Microsoft C __declspec must go at the start, or after the type like
148 void __declspec(...) *foo()". There's no __dllexport or anything to
149 guard against someone foolish #defining dllexport. _export used to be
150 available, but no longer.
152 In Borland C _export still exists, but needs to go after the type, like
153 "void _export foo();". Would have to change the __GMP_DECLSPEC syntax to
154 make use of that. Probably more trouble than it's worth. */
156 #if defined (__GNUC__)
157 #define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__)
158 #define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__)
160 #if defined (_MSC_VER) || defined (__BORLANDC__)
161 #define __GMP_DECLSPEC_EXPORT __declspec(dllexport)
162 #define __GMP_DECLSPEC_IMPORT __declspec(dllimport)
165 #define __GMP_DECLSPEC_EXPORT __export
166 #define __GMP_DECLSPEC_IMPORT __import
169 #define __GMP_DECLSPEC_EXPORT _Export
170 #define __GMP_DECLSPEC_IMPORT _Import
175 /* compiling to go into a DLL libgmp */
176 #define __GMP_DECLSPEC __GMP_DECLSPEC_EXPORT
178 /* compiling to go into an application which will link to a DLL libgmp */
179 #define __GMP_DECLSPEC __GMP_DECLSPEC_IMPORT
182 /* all other cases */
183 #define __GMP_DECLSPEC
187 #ifdef __GMP_SHORT_LIMB
188 typedef unsigned int mp_limb_t;
189 typedef int mp_limb_signed_t;
191 #ifdef _LONG_LONG_LIMB
192 typedef unsigned long long int mp_limb_t;
193 typedef long long int mp_limb_signed_t;
195 typedef unsigned long int mp_limb_t;
196 typedef long int mp_limb_signed_t;
200 /* For reference, note that the name __mpz_struct gets into C++ mangled
201 function names, which means although the "__" suggests an internal, we
202 must leave this name for binary compatibility. */
205 int _mp_alloc; /* Number of *limbs* allocated and pointed
206 to by the _mp_d field. */
207 int _mp_size; /* abs(_mp_size) is the number of limbs the
208 last field points to. If _mp_size is
209 negative this is a negative number. */
210 mp_limb_t *_mp_d; /* Pointer to the limbs. */
213 #endif /* __GNU_MP__ */
216 typedef __mpz_struct MP_INT; /* gmp 1 source compatibility */
217 typedef __mpz_struct mpz_t[1];
219 typedef mp_limb_t * mp_ptr;
220 typedef __gmp_const mp_limb_t * mp_srcptr;
221 #if defined (_CRAY) && ! defined (_CRAYMPP)
222 /* plain `int' is much faster (48 bits) */
223 #define __GMP_MP_SIZE_T_INT 1
224 typedef int mp_size_t;
225 typedef int mp_exp_t;
227 #define __GMP_MP_SIZE_T_INT 0
228 typedef long int mp_size_t;
229 typedef long int mp_exp_t;
234 __mpz_struct _mp_num;
235 __mpz_struct _mp_den;
238 typedef __mpq_struct MP_RAT; /* gmp 1 source compatibility */
239 typedef __mpq_struct mpq_t[1];
243 int _mp_prec; /* Max precision, in number of `mp_limb_t's.
244 Set by mpf_init and modified by
245 mpf_set_prec. The area pointed to by the
246 _mp_d field contains `prec' + 1 limbs. */
247 int _mp_size; /* abs(_mp_size) is the number of limbs the
248 last field points to. If _mp_size is
249 negative this is a negative number. */
250 mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */
251 mp_limb_t *_mp_d; /* Pointer to the limbs. */
254 /* typedef __mpf_struct MP_FLOAT; */
255 typedef __mpf_struct mpf_t[1];
257 /* Available random number generation algorithms. */
260 GMP_RAND_ALG_DEFAULT = 0,
261 GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */
264 /* Random state struct. */
267 mpz_t _mp_seed; /* _mp_d member points to state of the generator. */
268 gmp_randalg_t _mp_alg; /* Currently unused. */
270 void *_mp_lc; /* Pointer to function pointers structure. */
272 } __gmp_randstate_struct;
273 typedef __gmp_randstate_struct gmp_randstate_t[1];
275 /* Types for function declarations in gmp files. */
276 /* ??? Should not pollute user name space with these ??? */
277 typedef __gmp_const __mpz_struct *mpz_srcptr;
278 typedef __mpz_struct *mpz_ptr;
279 typedef __gmp_const __mpf_struct *mpf_srcptr;
280 typedef __mpf_struct *mpf_ptr;
281 typedef __gmp_const __mpq_struct *mpq_srcptr;
282 typedef __mpq_struct *mpq_ptr;
285 /* This is not wanted in mp.h, so put it outside the __GNU_MP__ common
288 #if __GMP_WITHIN_GMPXX
289 /* compiling to go into a DLL libgmpxx */
290 #define __GMP_DECLSPEC_XX __GMP_DECLSPEC_EXPORT
292 /* compiling to go into a application which will link to a DLL libgmpxx */
293 #define __GMP_DECLSPEC_XX __GMP_DECLSPEC_IMPORT
296 /* all other cases */
297 #define __GMP_DECLSPEC_XX
301 #if __GMP_HAVE_PROTOTYPES
302 #define __GMP_PROTO(x) x
304 #define __GMP_PROTO(x) ()
308 #if __GMP_HAVE_TOKEN_PASTE
309 #define __MPN(x) __gmpn_##x
311 #define __MPN(x) __gmpn_/**/x
315 /* For reference, "defined(EOF)" cannot be used here. In g++ 2.95.4,
316 <iostream> defines EOF but not FILE. */
318 || defined (H_STDIO) \
319 || defined (_H_STDIO) /* AIX */ \
320 || defined (_STDIO_H) /* glibc, Sun, SCO */ \
321 || defined (_STDIO_H_) /* BSD, OSF */ \
322 || defined (__STDIO_H) /* Borland */ \
323 || defined (__STDIO_H__) /* IRIX */ \
324 || defined (_STDIO_INCLUDED) /* HPUX */ \
325 || defined (__dj_include_stdio_h_) /* DJGPP */ \
326 || defined (_FILE_DEFINED) /* Microsoft */ \
327 || defined (__STDIO__) /* Apple MPW MrC */ \
328 || defined (_MSL_STDIO_H) /* Metrowerks */ \
329 || defined (_STDIO_H_INCLUDED) /* QNX4 */ \
330 || defined (_ISO_STDIO_ISO_H) /* Sun C++ */
331 #define _GMP_H_HAVE_FILE 1
334 /* In ISO C, if a prototype involving "struct obstack *" is given without
335 that structure defined, then the struct is scoped down to just the
336 prototype, causing a conflict if it's subsequently defined for real. So
337 only give prototypes if we've got obstack.h. */
338 #if defined (_OBSTACK_H) /* glibc <obstack.h> */
339 #define _GMP_H_HAVE_OBSTACK 1
342 /* The prototypes for gmp_vprintf etc are provided only if va_list is
343 available, via an application having included <stdarg.h> or <varargs.h>.
344 Usually va_list is a typedef so can't be tested directly, but C99
345 specifies that va_start is a macro (and it was normally a macro on past
346 systems too), so look for that.
348 <stdio.h> will define some sort of va_list for vprintf and vfprintf, but
349 let's not bother trying to use that since it's not standard and since
350 application uses for gmp_vprintf etc will almost certainly require the
351 whole <stdarg.h> or <varargs.h> anyway. */
354 #define _GMP_H_HAVE_VA_LIST 1
357 /* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */
358 #if defined (__GNUC__) && defined (__GNUC_MINOR__)
359 #define __GMP_GNUC_PREREQ(maj, min) \
360 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
362 #define __GMP_GNUC_PREREQ(maj, min) 0
365 /* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes". Basically
366 it means a function does nothing but examine its arguments and memory
367 (global or via arguments) to generate a return value, but changes nothing
368 and has no side-effects. __GMP_NO_ATTRIBUTE_CONST_PURE lets
369 tune/common.c etc turn this off when trying to write timing loops. */
370 #if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE)
371 #define __GMP_ATTRIBUTE_PURE __attribute__ ((__pure__))
373 #define __GMP_ATTRIBUTE_PURE
377 /* __GMP_CAST allows us to use static_cast in C++, so our macros are clean
378 to "g++ -Wold-style-cast".
380 Casts in "extern inline" code within an extern "C" block don't induce
381 these warnings, so __GMP_CAST only needs to be used on documented
385 #define __GMP_CAST(type, expr) (static_cast<type> (expr))
387 #define __GMP_CAST(type, expr) ((type) (expr))
391 /* An empty "throw ()" means the function doesn't throw any C++ exceptions,
392 this can save some stack frame info in applications.
394 Currently it's given only on functions which never divide-by-zero etc,
395 don't allocate memory, and are expected to never need to allocate memory.
396 This leaves open the possibility of a C++ throw from a future GMP
399 mpz_set_ui etc are omitted to leave open the lazy allocation scheme
400 described in doc/tasks.html. mpz_get_d etc are omitted to leave open
401 exceptions for float overflows.
403 Note that __GMP_NOTHROW must be given on any inlines the same as on their
404 prototypes (for g++ at least, where they're used together). Note also
405 that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like
406 __GMP_ATTRIBUTE_PURE. */
408 #if defined (__cplusplus)
409 #define __GMP_NOTHROW throw ()
411 #define __GMP_NOTHROW
415 /* PORTME: What other compilers have a useful "extern inline"? "static
416 inline" would be an acceptable substitute if the compiler (or linker)
417 discards unused statics. */
419 /* gcc has __inline__ in all modes, including strict ansi. Give a prototype
420 for an inline too, so as to correctly specify "dllimport" on windows, in
421 case the function is called rather than inlined. */
423 #define __GMP_EXTERN_INLINE extern __inline__
424 #define __GMP_INLINE_PROTOTYPES 1
427 /* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1
428 strict ANSI mode. Inlining is done even when not optimizing (ie. -O0
429 mode, which is the default), but an unnecessary local copy of foo is
430 emitted unless -O is used. "extern __inline" is accepted, but the
431 "extern" appears to be ignored, ie. it becomes a plain global function
432 but which is inlined within its file. Don't know if all old versions of
433 DEC C supported __inline, but as a start let's do the right thing for
436 #define __GMP_EXTERN_INLINE static __inline
439 /* SCO OpenUNIX 8 cc supports "static inline foo()" but not in -Xc strict
440 ANSI mode (__STDC__ is 1 in that mode). Inlining only actually takes
441 place under -O. Without -O "foo" seems to be emitted whether it's used
442 or not, which is wasteful. "extern inline foo()" isn't useful, the
443 "extern" is apparently ignored, so foo is inlined if possible but also
444 emitted as a global, which causes multiple definition errors when
445 building a shared libgmp. */
446 #ifdef __SCO_VERSION__
447 #if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \
448 && ! defined (__GMP_EXTERN_INLINE)
449 #define __GMP_EXTERN_INLINE static inline
453 /* C++ always has "inline" and since it's a normal feature the linker should
454 discard duplicate non-inlined copies, or if it doesn't then that's a
455 problem for everyone, not just GMP. */
456 #if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE)
457 #define __GMP_EXTERN_INLINE inline
460 /* Don't do any inlining within a configure run, since if the compiler ends
461 up emitting copies of the code into the object file it can end up
462 demanding the various support routines (like mpn_popcount) for linking,
463 making the "alloca" test and perhaps others fail. And on hppa ia64 a
464 pre-release gcc 3.2 was seen not respecting the "extern" in "extern
465 __inline__", triggering this problem too. */
466 #if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE
467 #undef __GMP_EXTERN_INLINE
470 /* By default, don't give a prototype when there's going to be an inline
471 version. Note in particular that Cray C++ objects to the combination of
472 prototype and inline. */
473 #ifdef __GMP_EXTERN_INLINE
474 #ifndef __GMP_INLINE_PROTOTYPES
475 #define __GMP_INLINE_PROTOTYPES 0
478 #define __GMP_INLINE_PROTOTYPES 1
482 #define __GMP_ABS(x) ((x) >= 0 ? (x) : -(x))
483 #define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i))
485 /* __GMP_USHRT_MAX is not "~ (unsigned short) 0" because short is promoted
487 #define __GMP_UINT_MAX (~ (unsigned) 0)
488 #define __GMP_ULONG_MAX (~ (unsigned long) 0)
489 #define __GMP_USHRT_MAX ((unsigned short) ~0)
492 /* __builtin_expect is in gcc 3.0, and not in 2.95. */
493 #if __GMP_GNUC_PREREQ (3,0)
494 #define __GMP_LIKELY(cond) __builtin_expect ((cond) != 0, 1)
495 #define __GMP_UNLIKELY(cond) __builtin_expect ((cond) != 0, 0)
497 #define __GMP_LIKELY(cond) (cond)
498 #define __GMP_UNLIKELY(cond) (cond)
502 #define __GMP_CRAY_Pragma(str) _Pragma (str)
504 #define __GMP_CRAY_Pragma(str)
508 /* Allow direct user access to numerator and denominator of a mpq_t object. */
509 #define mpq_numref(Q) (&((Q)->_mp_num))
510 #define mpq_denref(Q) (&((Q)->_mp_den))
513 #if defined (__cplusplus)
518 #define mp_set_memory_functions __gmp_set_memory_functions
519 __GMP_DECLSPEC void mp_set_memory_functions __GMP_PROTO ((void *(*) (size_t),
520 void *(*) (void *, size_t, size_t),
521 void (*) (void *, size_t))) __GMP_NOTHROW;
523 #define mp_get_memory_functions __gmp_get_memory_functions
524 __GMP_DECLSPEC void mp_get_memory_functions __GMP_PROTO ((void *(**) (size_t),
525 void *(**) (void *, size_t, size_t),
526 void (**) (void *, size_t))) __GMP_NOTHROW;
528 #define mp_bits_per_limb __gmp_bits_per_limb
529 __GMP_DECLSPEC extern __gmp_const int mp_bits_per_limb;
531 #define gmp_errno __gmp_errno
532 __GMP_DECLSPEC extern int gmp_errno;
534 #define gmp_version __gmp_version
535 __GMP_DECLSPEC extern __gmp_const char * __gmp_const gmp_version;
538 /**************** Random number routines. ****************/
541 #define gmp_randinit __gmp_randinit
542 __GMP_DECLSPEC void gmp_randinit __GMP_PROTO ((gmp_randstate_t, gmp_randalg_t, ...));
544 #define gmp_randinit_default __gmp_randinit_default
545 __GMP_DECLSPEC void gmp_randinit_default __GMP_PROTO ((gmp_randstate_t));
547 #define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp
548 __GMP_DECLSPEC void gmp_randinit_lc_2exp __GMP_PROTO ((gmp_randstate_t,
549 mpz_srcptr, unsigned long int,
552 #define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size
553 __GMP_DECLSPEC int gmp_randinit_lc_2exp_size __GMP_PROTO ((gmp_randstate_t, unsigned long));
555 #define gmp_randinit_mt __gmp_randinit_mt
556 __GMP_DECLSPEC void gmp_randinit_mt __GMP_PROTO ((gmp_randstate_t));
558 #define gmp_randinit_set __gmp_randinit_set
559 void gmp_randinit_set __GMP_PROTO ((gmp_randstate_t, __gmp_const __gmp_randstate_struct *));
561 #define gmp_randseed __gmp_randseed
562 __GMP_DECLSPEC void gmp_randseed __GMP_PROTO ((gmp_randstate_t, mpz_srcptr));
564 #define gmp_randseed_ui __gmp_randseed_ui
565 __GMP_DECLSPEC void gmp_randseed_ui __GMP_PROTO ((gmp_randstate_t, unsigned long int));
567 #define gmp_randclear __gmp_randclear
568 __GMP_DECLSPEC void gmp_randclear __GMP_PROTO ((gmp_randstate_t));
570 #define gmp_urandomb_ui __gmp_urandomb_ui
571 unsigned long gmp_urandomb_ui __GMP_PROTO ((gmp_randstate_t, unsigned long));
573 #define gmp_urandomm_ui __gmp_urandomm_ui
574 unsigned long gmp_urandomm_ui __GMP_PROTO ((gmp_randstate_t, unsigned long));
577 /**************** Formatted output routines. ****************/
579 #define gmp_asprintf __gmp_asprintf
580 __GMP_DECLSPEC int gmp_asprintf __GMP_PROTO ((char **, __gmp_const char *, ...));
582 #define gmp_fprintf __gmp_fprintf
583 #ifdef _GMP_H_HAVE_FILE
584 __GMP_DECLSPEC int gmp_fprintf __GMP_PROTO ((FILE *, __gmp_const char *, ...));
587 #define gmp_obstack_printf __gmp_obstack_printf
588 #if defined (_GMP_H_HAVE_OBSTACK)
589 __GMP_DECLSPEC int gmp_obstack_printf __GMP_PROTO ((struct obstack *, __gmp_const char *, ...));
592 #define gmp_obstack_vprintf __gmp_obstack_vprintf
593 #if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST)
594 __GMP_DECLSPEC int gmp_obstack_vprintf __GMP_PROTO ((struct obstack *, __gmp_const char *, va_list));
597 #define gmp_printf __gmp_printf
598 __GMP_DECLSPEC int gmp_printf __GMP_PROTO ((__gmp_const char *, ...));
600 #define gmp_snprintf __gmp_snprintf
601 __GMP_DECLSPEC int gmp_snprintf __GMP_PROTO ((char *, size_t, __gmp_const char *, ...));
603 #define gmp_sprintf __gmp_sprintf
604 __GMP_DECLSPEC int gmp_sprintf __GMP_PROTO ((char *, __gmp_const char *, ...));
606 #define gmp_vasprintf __gmp_vasprintf
607 #if defined (_GMP_H_HAVE_VA_LIST)
608 __GMP_DECLSPEC int gmp_vasprintf __GMP_PROTO ((char **, __gmp_const char *, va_list));
611 #define gmp_vfprintf __gmp_vfprintf
612 #if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)
613 __GMP_DECLSPEC int gmp_vfprintf __GMP_PROTO ((FILE *, __gmp_const char *, va_list));
616 #define gmp_vprintf __gmp_vprintf
617 #if defined (_GMP_H_HAVE_VA_LIST)
618 __GMP_DECLSPEC int gmp_vprintf __GMP_PROTO ((__gmp_const char *, va_list));
621 #define gmp_vsnprintf __gmp_vsnprintf
622 #if defined (_GMP_H_HAVE_VA_LIST)
623 __GMP_DECLSPEC int gmp_vsnprintf __GMP_PROTO ((char *, size_t, __gmp_const char *, va_list));
626 #define gmp_vsprintf __gmp_vsprintf
627 #if defined (_GMP_H_HAVE_VA_LIST)
628 __GMP_DECLSPEC int gmp_vsprintf __GMP_PROTO ((char *, __gmp_const char *, va_list));
632 /**************** Formatted input routines. ****************/
634 #define gmp_fscanf __gmp_fscanf
635 #ifdef _GMP_H_HAVE_FILE
636 __GMP_DECLSPEC int gmp_fscanf __GMP_PROTO ((FILE *, __gmp_const char *, ...));
639 #define gmp_scanf __gmp_scanf
640 __GMP_DECLSPEC int gmp_scanf __GMP_PROTO ((__gmp_const char *, ...));
642 #define gmp_sscanf __gmp_sscanf
643 __GMP_DECLSPEC int gmp_sscanf __GMP_PROTO ((__gmp_const char *, __gmp_const char *, ...));
645 #define gmp_vfscanf __gmp_vfscanf
646 #if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)
647 __GMP_DECLSPEC int gmp_vfscanf __GMP_PROTO ((FILE *, __gmp_const char *, va_list));
650 #define gmp_vscanf __gmp_vscanf
651 #if defined (_GMP_H_HAVE_VA_LIST)
652 __GMP_DECLSPEC int gmp_vscanf __GMP_PROTO ((__gmp_const char *, va_list));
655 #define gmp_vsscanf __gmp_vsscanf
656 #if defined (_GMP_H_HAVE_VA_LIST)
657 __GMP_DECLSPEC int gmp_vsscanf __GMP_PROTO ((__gmp_const char *, __gmp_const char *, va_list));
661 /**************** Integer (i.e. Z) routines. ****************/
663 #define _mpz_realloc __gmpz_realloc
664 #define mpz_realloc __gmpz_realloc
665 __GMP_DECLSPEC void *_mpz_realloc __GMP_PROTO ((mpz_ptr, mp_size_t));
667 #define mpz_abs __gmpz_abs
668 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs)
669 __GMP_DECLSPEC void mpz_abs __GMP_PROTO ((mpz_ptr, mpz_srcptr));
672 #define mpz_add __gmpz_add
673 __GMP_DECLSPEC void mpz_add __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
675 #define mpz_add_ui __gmpz_add_ui
676 __GMP_DECLSPEC void mpz_add_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
678 #define mpz_addmul __gmpz_addmul
679 __GMP_DECLSPEC void mpz_addmul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
681 #define mpz_addmul_ui __gmpz_addmul_ui
682 __GMP_DECLSPEC void mpz_addmul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
684 #define mpz_and __gmpz_and
685 __GMP_DECLSPEC void mpz_and __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
687 #define mpz_array_init __gmpz_array_init
688 __GMP_DECLSPEC void mpz_array_init __GMP_PROTO ((mpz_ptr, mp_size_t, mp_size_t));
690 #define mpz_bin_ui __gmpz_bin_ui
691 __GMP_DECLSPEC void mpz_bin_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
693 #define mpz_bin_uiui __gmpz_bin_uiui
694 __GMP_DECLSPEC void mpz_bin_uiui __GMP_PROTO ((mpz_ptr, unsigned long int, unsigned long int));
696 #define mpz_cdiv_q __gmpz_cdiv_q
697 __GMP_DECLSPEC void mpz_cdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
699 #define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp
700 __GMP_DECLSPEC void mpz_cdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));
702 #define mpz_cdiv_q_ui __gmpz_cdiv_q_ui
703 __GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
705 #define mpz_cdiv_qr __gmpz_cdiv_qr
706 __GMP_DECLSPEC void mpz_cdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
708 #define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui
709 __GMP_DECLSPEC unsigned long int mpz_cdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
711 #define mpz_cdiv_r __gmpz_cdiv_r
712 __GMP_DECLSPEC void mpz_cdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
714 #define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp
715 __GMP_DECLSPEC void mpz_cdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));
717 #define mpz_cdiv_r_ui __gmpz_cdiv_r_ui
718 __GMP_DECLSPEC unsigned long int mpz_cdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
720 #define mpz_cdiv_ui __gmpz_cdiv_ui
721 __GMP_DECLSPEC unsigned long int mpz_cdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
723 #define mpz_clear __gmpz_clear
724 __GMP_DECLSPEC void mpz_clear __GMP_PROTO ((mpz_ptr));
726 #define mpz_clrbit __gmpz_clrbit
727 __GMP_DECLSPEC void mpz_clrbit __GMP_PROTO ((mpz_ptr, unsigned long int));
729 #define mpz_cmp __gmpz_cmp
730 __GMP_DECLSPEC int mpz_cmp __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
732 #define mpz_cmp_d __gmpz_cmp_d
733 __GMP_DECLSPEC int mpz_cmp_d __GMP_PROTO ((mpz_srcptr, double)) __GMP_ATTRIBUTE_PURE;
735 #define _mpz_cmp_si __gmpz_cmp_si
736 __GMP_DECLSPEC int _mpz_cmp_si __GMP_PROTO ((mpz_srcptr, signed long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
738 #define _mpz_cmp_ui __gmpz_cmp_ui
739 __GMP_DECLSPEC int _mpz_cmp_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
741 #define mpz_cmpabs __gmpz_cmpabs
742 __GMP_DECLSPEC int mpz_cmpabs __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
744 #define mpz_cmpabs_d __gmpz_cmpabs_d
745 __GMP_DECLSPEC int mpz_cmpabs_d __GMP_PROTO ((mpz_srcptr, double)) __GMP_ATTRIBUTE_PURE;
747 #define mpz_cmpabs_ui __gmpz_cmpabs_ui
748 __GMP_DECLSPEC int mpz_cmpabs_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
750 #define mpz_com __gmpz_com
751 __GMP_DECLSPEC void mpz_com __GMP_PROTO ((mpz_ptr, mpz_srcptr));
753 #define mpz_combit __gmpz_combit
754 __GMP_DECLSPEC void mpz_combit __GMP_PROTO ((mpz_ptr, unsigned long int));
756 #define mpz_congruent_p __gmpz_congruent_p
757 __GMP_DECLSPEC int mpz_congruent_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
759 #define mpz_congruent_2exp_p __gmpz_congruent_2exp_p
760 __GMP_DECLSPEC int mpz_congruent_2exp_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr, unsigned long)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
762 #define mpz_congruent_ui_p __gmpz_congruent_ui_p
763 __GMP_DECLSPEC int mpz_congruent_ui_p __GMP_PROTO ((mpz_srcptr, unsigned long, unsigned long)) __GMP_ATTRIBUTE_PURE;
765 #define mpz_divexact __gmpz_divexact
766 __GMP_DECLSPEC void mpz_divexact __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
768 #define mpz_divexact_ui __gmpz_divexact_ui
769 __GMP_DECLSPEC void mpz_divexact_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));
771 #define mpz_divisible_p __gmpz_divisible_p
772 __GMP_DECLSPEC int mpz_divisible_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
774 #define mpz_divisible_ui_p __gmpz_divisible_ui_p
775 __GMP_DECLSPEC int mpz_divisible_ui_p __GMP_PROTO ((mpz_srcptr, unsigned long)) __GMP_ATTRIBUTE_PURE;
777 #define mpz_divisible_2exp_p __gmpz_divisible_2exp_p
778 __GMP_DECLSPEC int mpz_divisible_2exp_p __GMP_PROTO ((mpz_srcptr, unsigned long)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
780 #define mpz_dump __gmpz_dump
781 __GMP_DECLSPEC void mpz_dump __GMP_PROTO ((mpz_srcptr));
783 #define mpz_export __gmpz_export
784 __GMP_DECLSPEC void *mpz_export __GMP_PROTO ((void *, size_t *, int, size_t, int, size_t, mpz_srcptr));
786 #define mpz_fac_ui __gmpz_fac_ui
787 __GMP_DECLSPEC void mpz_fac_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
789 #define mpz_fdiv_q __gmpz_fdiv_q
790 __GMP_DECLSPEC void mpz_fdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
792 #define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp
793 __GMP_DECLSPEC void mpz_fdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
795 #define mpz_fdiv_q_ui __gmpz_fdiv_q_ui
796 __GMP_DECLSPEC unsigned long int mpz_fdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
798 #define mpz_fdiv_qr __gmpz_fdiv_qr
799 __GMP_DECLSPEC void mpz_fdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
801 #define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui
802 __GMP_DECLSPEC unsigned long int mpz_fdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
804 #define mpz_fdiv_r __gmpz_fdiv_r
805 __GMP_DECLSPEC void mpz_fdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
807 #define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp
808 __GMP_DECLSPEC void mpz_fdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
810 #define mpz_fdiv_r_ui __gmpz_fdiv_r_ui
811 __GMP_DECLSPEC unsigned long int mpz_fdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
813 #define mpz_fdiv_ui __gmpz_fdiv_ui
814 __GMP_DECLSPEC unsigned long int mpz_fdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
816 #define mpz_fib_ui __gmpz_fib_ui
817 __GMP_DECLSPEC void mpz_fib_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
819 #define mpz_fib2_ui __gmpz_fib2_ui
820 __GMP_DECLSPEC void mpz_fib2_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, unsigned long int));
822 #define mpz_fits_sint_p __gmpz_fits_sint_p
823 __GMP_DECLSPEC int mpz_fits_sint_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
825 #define mpz_fits_slong_p __gmpz_fits_slong_p
826 __GMP_DECLSPEC int mpz_fits_slong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
828 #define mpz_fits_sshort_p __gmpz_fits_sshort_p
829 __GMP_DECLSPEC int mpz_fits_sshort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
831 #define mpz_fits_uint_p __gmpz_fits_uint_p
832 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p)
833 __GMP_DECLSPEC int mpz_fits_uint_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
836 #define mpz_fits_ulong_p __gmpz_fits_ulong_p
837 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p)
838 __GMP_DECLSPEC int mpz_fits_ulong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
841 #define mpz_fits_ushort_p __gmpz_fits_ushort_p
842 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p)
843 __GMP_DECLSPEC int mpz_fits_ushort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
846 #define mpz_gcd __gmpz_gcd
847 __GMP_DECLSPEC void mpz_gcd __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
849 #define mpz_gcd_ui __gmpz_gcd_ui
850 __GMP_DECLSPEC unsigned long int mpz_gcd_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
852 #define mpz_gcdext __gmpz_gcdext
853 __GMP_DECLSPEC void mpz_gcdext __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
855 #define mpz_get_d __gmpz_get_d
856 __GMP_DECLSPEC double mpz_get_d __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
858 #define mpz_get_d_2exp __gmpz_get_d_2exp
859 __GMP_DECLSPEC double mpz_get_d_2exp __GMP_PROTO ((signed long int *, mpz_srcptr));
861 #define mpz_get_si __gmpz_get_si
862 __GMP_DECLSPEC /* signed */ long int mpz_get_si __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
864 #define mpz_get_str __gmpz_get_str
865 __GMP_DECLSPEC char *mpz_get_str __GMP_PROTO ((char *, int, mpz_srcptr));
867 #define mpz_get_ui __gmpz_get_ui
868 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui)
869 __GMP_DECLSPEC unsigned long int mpz_get_ui __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
872 #define mpz_getlimbn __gmpz_getlimbn
873 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn)
874 __GMP_DECLSPEC mp_limb_t mpz_getlimbn __GMP_PROTO ((mpz_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
877 #define mpz_hamdist __gmpz_hamdist
878 __GMP_DECLSPEC unsigned long int mpz_hamdist __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
880 #define mpz_import __gmpz_import
881 __GMP_DECLSPEC void mpz_import __GMP_PROTO ((mpz_ptr, size_t, int, size_t, int, size_t, __gmp_const void *));
883 #define mpz_init __gmpz_init
884 __GMP_DECLSPEC void mpz_init __GMP_PROTO ((mpz_ptr));
886 #define mpz_init2 __gmpz_init2
887 __GMP_DECLSPEC void mpz_init2 __GMP_PROTO ((mpz_ptr, unsigned long));
889 #define mpz_init_set __gmpz_init_set
890 __GMP_DECLSPEC void mpz_init_set __GMP_PROTO ((mpz_ptr, mpz_srcptr));
892 #define mpz_init_set_d __gmpz_init_set_d
893 __GMP_DECLSPEC void mpz_init_set_d __GMP_PROTO ((mpz_ptr, double));
895 #define mpz_init_set_si __gmpz_init_set_si
896 __GMP_DECLSPEC void mpz_init_set_si __GMP_PROTO ((mpz_ptr, signed long int));
898 #define mpz_init_set_str __gmpz_init_set_str
899 __GMP_DECLSPEC int mpz_init_set_str __GMP_PROTO ((mpz_ptr, __gmp_const char *, int));
901 #define mpz_init_set_ui __gmpz_init_set_ui
902 __GMP_DECLSPEC void mpz_init_set_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
904 #define mpz_inp_raw __gmpz_inp_raw
905 #ifdef _GMP_H_HAVE_FILE
906 __GMP_DECLSPEC size_t mpz_inp_raw __GMP_PROTO ((mpz_ptr, FILE *));
909 #define mpz_inp_str __gmpz_inp_str
910 #ifdef _GMP_H_HAVE_FILE
911 __GMP_DECLSPEC size_t mpz_inp_str __GMP_PROTO ((mpz_ptr, FILE *, int));
914 #define mpz_invert __gmpz_invert
915 __GMP_DECLSPEC int mpz_invert __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
917 #define mpz_ior __gmpz_ior
918 __GMP_DECLSPEC void mpz_ior __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
920 #define mpz_jacobi __gmpz_jacobi
921 __GMP_DECLSPEC int mpz_jacobi __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
923 #define mpz_kronecker mpz_jacobi /* alias */
925 #define mpz_kronecker_si __gmpz_kronecker_si
926 __GMP_DECLSPEC int mpz_kronecker_si __GMP_PROTO ((mpz_srcptr, long)) __GMP_ATTRIBUTE_PURE;
928 #define mpz_kronecker_ui __gmpz_kronecker_ui
929 __GMP_DECLSPEC int mpz_kronecker_ui __GMP_PROTO ((mpz_srcptr, unsigned long)) __GMP_ATTRIBUTE_PURE;
931 #define mpz_si_kronecker __gmpz_si_kronecker
932 __GMP_DECLSPEC int mpz_si_kronecker __GMP_PROTO ((long, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
934 #define mpz_ui_kronecker __gmpz_ui_kronecker
935 __GMP_DECLSPEC int mpz_ui_kronecker __GMP_PROTO ((unsigned long, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
937 #define mpz_lcm __gmpz_lcm
938 __GMP_DECLSPEC void mpz_lcm __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
940 #define mpz_lcm_ui __gmpz_lcm_ui
941 __GMP_DECLSPEC void mpz_lcm_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));
943 #define mpz_legendre mpz_jacobi /* alias */
945 #define mpz_lucnum_ui __gmpz_lucnum_ui
946 __GMP_DECLSPEC void mpz_lucnum_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
948 #define mpz_lucnum2_ui __gmpz_lucnum2_ui
949 __GMP_DECLSPEC void mpz_lucnum2_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, unsigned long int));
951 #define mpz_millerrabin __gmpz_millerrabin
952 __GMP_DECLSPEC int mpz_millerrabin __GMP_PROTO ((mpz_srcptr, int)) __GMP_ATTRIBUTE_PURE;
954 #define mpz_mod __gmpz_mod
955 __GMP_DECLSPEC void mpz_mod __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
957 #define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */
959 #define mpz_mul __gmpz_mul
960 __GMP_DECLSPEC void mpz_mul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
962 #define mpz_mul_2exp __gmpz_mul_2exp
963 __GMP_DECLSPEC void mpz_mul_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
965 #define mpz_mul_si __gmpz_mul_si
966 __GMP_DECLSPEC void mpz_mul_si __GMP_PROTO ((mpz_ptr, mpz_srcptr, long int));
968 #define mpz_mul_ui __gmpz_mul_ui
969 __GMP_DECLSPEC void mpz_mul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
971 #define mpz_neg __gmpz_neg
972 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg)
973 __GMP_DECLSPEC void mpz_neg __GMP_PROTO ((mpz_ptr, mpz_srcptr));
976 #define mpz_nextprime __gmpz_nextprime
977 __GMP_DECLSPEC void mpz_nextprime __GMP_PROTO ((mpz_ptr, mpz_srcptr));
979 #define mpz_out_raw __gmpz_out_raw
980 #ifdef _GMP_H_HAVE_FILE
981 __GMP_DECLSPEC size_t mpz_out_raw __GMP_PROTO ((FILE *, mpz_srcptr));
984 #define mpz_out_str __gmpz_out_str
985 #ifdef _GMP_H_HAVE_FILE
986 __GMP_DECLSPEC size_t mpz_out_str __GMP_PROTO ((FILE *, int, mpz_srcptr));
989 #define mpz_perfect_power_p __gmpz_perfect_power_p
990 __GMP_DECLSPEC int mpz_perfect_power_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
992 #define mpz_perfect_square_p __gmpz_perfect_square_p
993 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p)
994 __GMP_DECLSPEC int mpz_perfect_square_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
997 #define mpz_popcount __gmpz_popcount
998 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount)
999 __GMP_DECLSPEC unsigned long int mpz_popcount __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1002 #define mpz_pow_ui __gmpz_pow_ui
1003 __GMP_DECLSPEC void mpz_pow_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1005 #define mpz_powm __gmpz_powm
1006 __GMP_DECLSPEC void mpz_powm __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr));
1008 #define mpz_powm_ui __gmpz_powm_ui
1009 __GMP_DECLSPEC void mpz_powm_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr));
1011 #define mpz_probab_prime_p __gmpz_probab_prime_p
1012 __GMP_DECLSPEC int mpz_probab_prime_p __GMP_PROTO ((mpz_srcptr, int)) __GMP_ATTRIBUTE_PURE;
1014 #define mpz_random __gmpz_random
1015 __GMP_DECLSPEC void mpz_random __GMP_PROTO ((mpz_ptr, mp_size_t));
1017 #define mpz_random2 __gmpz_random2
1018 __GMP_DECLSPEC void mpz_random2 __GMP_PROTO ((mpz_ptr, mp_size_t));
1020 #define mpz_realloc2 __gmpz_realloc2
1021 __GMP_DECLSPEC void mpz_realloc2 __GMP_PROTO ((mpz_ptr, unsigned long));
1023 #define mpz_remove __gmpz_remove
1024 __GMP_DECLSPEC unsigned long int mpz_remove __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1026 #define mpz_root __gmpz_root
1027 __GMP_DECLSPEC int mpz_root __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1029 #define mpz_rootrem __gmpz_rootrem
1030 __GMP_DECLSPEC void mpz_rootrem __GMP_PROTO ((mpz_ptr,mpz_ptr, mpz_srcptr, unsigned long int));
1032 #define mpz_rrandomb __gmpz_rrandomb
1033 __GMP_DECLSPEC void mpz_rrandomb __GMP_PROTO ((mpz_ptr, gmp_randstate_t, unsigned long int));
1035 #define mpz_scan0 __gmpz_scan0
1036 __GMP_DECLSPEC unsigned long int mpz_scan0 __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1038 #define mpz_scan1 __gmpz_scan1
1039 __GMP_DECLSPEC unsigned long int mpz_scan1 __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1041 #define mpz_set __gmpz_set
1042 __GMP_DECLSPEC void mpz_set __GMP_PROTO ((mpz_ptr, mpz_srcptr));
1044 #define mpz_set_d __gmpz_set_d
1045 __GMP_DECLSPEC void mpz_set_d __GMP_PROTO ((mpz_ptr, double));
1047 #define mpz_set_f __gmpz_set_f
1048 __GMP_DECLSPEC void mpz_set_f __GMP_PROTO ((mpz_ptr, mpf_srcptr));
1050 #define mpz_set_q __gmpz_set_q
1051 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q)
1052 __GMP_DECLSPEC void mpz_set_q __GMP_PROTO ((mpz_ptr, mpq_srcptr));
1055 #define mpz_set_si __gmpz_set_si
1056 __GMP_DECLSPEC void mpz_set_si __GMP_PROTO ((mpz_ptr, signed long int));
1058 #define mpz_set_str __gmpz_set_str
1059 __GMP_DECLSPEC int mpz_set_str __GMP_PROTO ((mpz_ptr, __gmp_const char *, int));
1061 #define mpz_set_ui __gmpz_set_ui
1062 __GMP_DECLSPEC void mpz_set_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
1064 #define mpz_setbit __gmpz_setbit
1065 __GMP_DECLSPEC void mpz_setbit __GMP_PROTO ((mpz_ptr, unsigned long int));
1067 #define mpz_size __gmpz_size
1068 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size)
1069 __GMP_DECLSPEC size_t mpz_size __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1072 #define mpz_sizeinbase __gmpz_sizeinbase
1073 __GMP_DECLSPEC size_t mpz_sizeinbase __GMP_PROTO ((mpz_srcptr, int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1075 #define mpz_sqrt __gmpz_sqrt
1076 __GMP_DECLSPEC void mpz_sqrt __GMP_PROTO ((mpz_ptr, mpz_srcptr));
1078 #define mpz_sqrtrem __gmpz_sqrtrem
1079 __GMP_DECLSPEC void mpz_sqrtrem __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr));
1081 #define mpz_sub __gmpz_sub
1082 __GMP_DECLSPEC void mpz_sub __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1084 #define mpz_sub_ui __gmpz_sub_ui
1085 __GMP_DECLSPEC void mpz_sub_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1087 #define mpz_ui_sub __gmpz_ui_sub
1088 __GMP_DECLSPEC void mpz_ui_sub __GMP_PROTO ((mpz_ptr, unsigned long int, mpz_srcptr));
1090 #define mpz_submul __gmpz_submul
1091 __GMP_DECLSPEC void mpz_submul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1093 #define mpz_submul_ui __gmpz_submul_ui
1094 __GMP_DECLSPEC void mpz_submul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1096 #define mpz_swap __gmpz_swap
1097 __GMP_DECLSPEC void mpz_swap __GMP_PROTO ((mpz_ptr, mpz_ptr)) __GMP_NOTHROW;
1099 #define mpz_tdiv_ui __gmpz_tdiv_ui
1100 __GMP_DECLSPEC unsigned long int mpz_tdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
1102 #define mpz_tdiv_q __gmpz_tdiv_q
1103 __GMP_DECLSPEC void mpz_tdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1105 #define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp
1106 __GMP_DECLSPEC void mpz_tdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1108 #define mpz_tdiv_q_ui __gmpz_tdiv_q_ui
1109 __GMP_DECLSPEC unsigned long int mpz_tdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1111 #define mpz_tdiv_qr __gmpz_tdiv_qr
1112 __GMP_DECLSPEC void mpz_tdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
1114 #define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui
1115 __GMP_DECLSPEC unsigned long int mpz_tdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
1117 #define mpz_tdiv_r __gmpz_tdiv_r
1118 __GMP_DECLSPEC void mpz_tdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1120 #define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp
1121 __GMP_DECLSPEC void mpz_tdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1123 #define mpz_tdiv_r_ui __gmpz_tdiv_r_ui
1124 __GMP_DECLSPEC unsigned long int mpz_tdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1126 #define mpz_tstbit __gmpz_tstbit
1127 __GMP_DECLSPEC int mpz_tstbit __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1129 #define mpz_ui_pow_ui __gmpz_ui_pow_ui
1130 __GMP_DECLSPEC void mpz_ui_pow_ui __GMP_PROTO ((mpz_ptr, unsigned long int, unsigned long int));
1132 #define mpz_urandomb __gmpz_urandomb
1133 __GMP_DECLSPEC void mpz_urandomb __GMP_PROTO ((mpz_ptr, gmp_randstate_t, unsigned long int));
1135 #define mpz_urandomm __gmpz_urandomm
1136 __GMP_DECLSPEC void mpz_urandomm __GMP_PROTO ((mpz_ptr, gmp_randstate_t, mpz_srcptr));
1138 #define mpz_xor __gmpz_xor
1139 #define mpz_eor __gmpz_xor
1140 __GMP_DECLSPEC void mpz_xor __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1143 /**************** Rational (i.e. Q) routines. ****************/
1145 #define mpq_abs __gmpq_abs
1146 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs)
1147 __GMP_DECLSPEC void mpq_abs __GMP_PROTO ((mpq_ptr, mpq_srcptr));
1150 #define mpq_add __gmpq_add
1151 __GMP_DECLSPEC void mpq_add __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
1153 #define mpq_canonicalize __gmpq_canonicalize
1154 __GMP_DECLSPEC void mpq_canonicalize __GMP_PROTO ((mpq_ptr));
1156 #define mpq_clear __gmpq_clear
1157 __GMP_DECLSPEC void mpq_clear __GMP_PROTO ((mpq_ptr));
1159 #define mpq_cmp __gmpq_cmp
1160 __GMP_DECLSPEC int mpq_cmp __GMP_PROTO ((mpq_srcptr, mpq_srcptr)) __GMP_ATTRIBUTE_PURE;
1162 #define _mpq_cmp_si __gmpq_cmp_si
1163 __GMP_DECLSPEC int _mpq_cmp_si __GMP_PROTO ((mpq_srcptr, long, unsigned long)) __GMP_ATTRIBUTE_PURE;
1165 #define _mpq_cmp_ui __gmpq_cmp_ui
1166 __GMP_DECLSPEC int _mpq_cmp_ui __GMP_PROTO ((mpq_srcptr, unsigned long int, unsigned long int)) __GMP_ATTRIBUTE_PURE;
1168 #define mpq_div __gmpq_div
1169 __GMP_DECLSPEC void mpq_div __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
1171 #define mpq_div_2exp __gmpq_div_2exp
1172 __GMP_DECLSPEC void mpq_div_2exp __GMP_PROTO ((mpq_ptr, mpq_srcptr, unsigned long));
1174 #define mpq_equal __gmpq_equal
1175 __GMP_DECLSPEC int mpq_equal __GMP_PROTO ((mpq_srcptr, mpq_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1177 #define mpq_get_num __gmpq_get_num
1178 __GMP_DECLSPEC void mpq_get_num __GMP_PROTO ((mpz_ptr, mpq_srcptr));
1180 #define mpq_get_den __gmpq_get_den
1181 __GMP_DECLSPEC void mpq_get_den __GMP_PROTO ((mpz_ptr, mpq_srcptr));
1183 #define mpq_get_d __gmpq_get_d
1184 __GMP_DECLSPEC double mpq_get_d __GMP_PROTO ((mpq_srcptr)) __GMP_ATTRIBUTE_PURE;
1186 #define mpq_get_str __gmpq_get_str
1187 __GMP_DECLSPEC char *mpq_get_str __GMP_PROTO ((char *, int, mpq_srcptr));
1189 #define mpq_init __gmpq_init
1190 __GMP_DECLSPEC void mpq_init __GMP_PROTO ((mpq_ptr));
1192 #define mpq_inp_str __gmpq_inp_str
1193 #ifdef _GMP_H_HAVE_FILE
1194 __GMP_DECLSPEC size_t mpq_inp_str __GMP_PROTO ((mpq_ptr, FILE *, int));
1197 #define mpq_inv __gmpq_inv
1198 __GMP_DECLSPEC void mpq_inv __GMP_PROTO ((mpq_ptr, mpq_srcptr));
1200 #define mpq_mul __gmpq_mul
1201 __GMP_DECLSPEC void mpq_mul __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
1203 #define mpq_mul_2exp __gmpq_mul_2exp
1204 __GMP_DECLSPEC void mpq_mul_2exp __GMP_PROTO ((mpq_ptr, mpq_srcptr, unsigned long));
1206 #define mpq_neg __gmpq_neg
1207 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg)
1208 __GMP_DECLSPEC void mpq_neg __GMP_PROTO ((mpq_ptr, mpq_srcptr));
1211 #define mpq_out_str __gmpq_out_str
1212 #ifdef _GMP_H_HAVE_FILE
1213 __GMP_DECLSPEC size_t mpq_out_str __GMP_PROTO ((FILE *, int, mpq_srcptr));
1216 #define mpq_set __gmpq_set
1217 __GMP_DECLSPEC void mpq_set __GMP_PROTO ((mpq_ptr, mpq_srcptr));
1219 #define mpq_set_d __gmpq_set_d
1220 __GMP_DECLSPEC void mpq_set_d __GMP_PROTO ((mpq_ptr, double));
1222 #define mpq_set_den __gmpq_set_den
1223 __GMP_DECLSPEC void mpq_set_den __GMP_PROTO ((mpq_ptr, mpz_srcptr));
1225 #define mpq_set_f __gmpq_set_f
1226 __GMP_DECLSPEC void mpq_set_f __GMP_PROTO ((mpq_ptr, mpf_srcptr));
1228 #define mpq_set_num __gmpq_set_num
1229 __GMP_DECLSPEC void mpq_set_num __GMP_PROTO ((mpq_ptr, mpz_srcptr));
1231 #define mpq_set_si __gmpq_set_si
1232 __GMP_DECLSPEC void mpq_set_si __GMP_PROTO ((mpq_ptr, signed long int, unsigned long int));
1234 #define mpq_set_str __gmpq_set_str
1235 __GMP_DECLSPEC int mpq_set_str __GMP_PROTO ((mpq_ptr, __gmp_const char *, int));
1237 #define mpq_set_ui __gmpq_set_ui
1238 __GMP_DECLSPEC void mpq_set_ui __GMP_PROTO ((mpq_ptr, unsigned long int, unsigned long int));
1240 #define mpq_set_z __gmpq_set_z
1241 __GMP_DECLSPEC void mpq_set_z __GMP_PROTO ((mpq_ptr, mpz_srcptr));
1243 #define mpq_sub __gmpq_sub
1244 __GMP_DECLSPEC void mpq_sub __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
1246 #define mpq_swap __gmpq_swap
1247 __GMP_DECLSPEC void mpq_swap __GMP_PROTO ((mpq_ptr, mpq_ptr)) __GMP_NOTHROW;
1250 /**************** Float (i.e. F) routines. ****************/
1252 #define mpf_abs __gmpf_abs
1253 __GMP_DECLSPEC void mpf_abs __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1255 #define mpf_add __gmpf_add
1256 __GMP_DECLSPEC void mpf_add __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
1258 #define mpf_add_ui __gmpf_add_ui
1259 __GMP_DECLSPEC void mpf_add_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1260 #define mpf_ceil __gmpf_ceil
1261 __GMP_DECLSPEC void mpf_ceil __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1263 #define mpf_clear __gmpf_clear
1264 __GMP_DECLSPEC void mpf_clear __GMP_PROTO ((mpf_ptr));
1266 #define mpf_cmp __gmpf_cmp
1267 __GMP_DECLSPEC int mpf_cmp __GMP_PROTO ((mpf_srcptr, mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1269 #define mpf_cmp_d __gmpf_cmp_d
1270 __GMP_DECLSPEC int mpf_cmp_d __GMP_PROTO ((mpf_srcptr, double)) __GMP_ATTRIBUTE_PURE;
1272 #define mpf_cmp_si __gmpf_cmp_si
1273 __GMP_DECLSPEC int mpf_cmp_si __GMP_PROTO ((mpf_srcptr, signed long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1275 #define mpf_cmp_ui __gmpf_cmp_ui
1276 __GMP_DECLSPEC int mpf_cmp_ui __GMP_PROTO ((mpf_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1278 #define mpf_div __gmpf_div
1279 __GMP_DECLSPEC void mpf_div __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
1281 #define mpf_div_2exp __gmpf_div_2exp
1282 __GMP_DECLSPEC void mpf_div_2exp __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1284 #define mpf_div_ui __gmpf_div_ui
1285 __GMP_DECLSPEC void mpf_div_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1287 #define mpf_dump __gmpf_dump
1288 __GMP_DECLSPEC void mpf_dump __GMP_PROTO ((mpf_srcptr));
1290 #define mpf_eq __gmpf_eq
1291 __GMP_DECLSPEC int mpf_eq __GMP_PROTO ((mpf_srcptr, mpf_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
1293 #define mpf_fits_sint_p __gmpf_fits_sint_p
1294 __GMP_DECLSPEC int mpf_fits_sint_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1296 #define mpf_fits_slong_p __gmpf_fits_slong_p
1297 __GMP_DECLSPEC int mpf_fits_slong_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1299 #define mpf_fits_sshort_p __gmpf_fits_sshort_p
1300 __GMP_DECLSPEC int mpf_fits_sshort_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1302 #define mpf_fits_uint_p __gmpf_fits_uint_p
1303 __GMP_DECLSPEC int mpf_fits_uint_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1305 #define mpf_fits_ulong_p __gmpf_fits_ulong_p
1306 __GMP_DECLSPEC int mpf_fits_ulong_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1308 #define mpf_fits_ushort_p __gmpf_fits_ushort_p
1309 __GMP_DECLSPEC int mpf_fits_ushort_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1311 #define mpf_floor __gmpf_floor
1312 __GMP_DECLSPEC void mpf_floor __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1314 #define mpf_get_d __gmpf_get_d
1315 __GMP_DECLSPEC double mpf_get_d __GMP_PROTO ((mpf_srcptr)) __GMP_ATTRIBUTE_PURE;
1317 #define mpf_get_d_2exp __gmpf_get_d_2exp
1318 __GMP_DECLSPEC double mpf_get_d_2exp __GMP_PROTO ((signed long int *, mpf_srcptr));
1320 #define mpf_get_default_prec __gmpf_get_default_prec
1321 __GMP_DECLSPEC unsigned long int mpf_get_default_prec __GMP_PROTO ((void)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1323 #define mpf_get_prec __gmpf_get_prec
1324 __GMP_DECLSPEC unsigned long int mpf_get_prec __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1326 #define mpf_get_si __gmpf_get_si
1327 __GMP_DECLSPEC long mpf_get_si __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1329 #define mpf_get_str __gmpf_get_str
1330 __GMP_DECLSPEC char *mpf_get_str __GMP_PROTO ((char *, mp_exp_t *, int, size_t, mpf_srcptr));
1332 #define mpf_get_ui __gmpf_get_ui
1333 __GMP_DECLSPEC unsigned long mpf_get_ui __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1335 #define mpf_init __gmpf_init
1336 __GMP_DECLSPEC void mpf_init __GMP_PROTO ((mpf_ptr));
1338 #define mpf_init2 __gmpf_init2
1339 __GMP_DECLSPEC void mpf_init2 __GMP_PROTO ((mpf_ptr, unsigned long int));
1341 #define mpf_init_set __gmpf_init_set
1342 __GMP_DECLSPEC void mpf_init_set __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1344 #define mpf_init_set_d __gmpf_init_set_d
1345 __GMP_DECLSPEC void mpf_init_set_d __GMP_PROTO ((mpf_ptr, double));
1347 #define mpf_init_set_si __gmpf_init_set_si
1348 __GMP_DECLSPEC void mpf_init_set_si __GMP_PROTO ((mpf_ptr, signed long int));
1350 #define mpf_init_set_str __gmpf_init_set_str
1351 __GMP_DECLSPEC int mpf_init_set_str __GMP_PROTO ((mpf_ptr, __gmp_const char *, int));
1353 #define mpf_init_set_ui __gmpf_init_set_ui
1354 __GMP_DECLSPEC void mpf_init_set_ui __GMP_PROTO ((mpf_ptr, unsigned long int));
1356 #define mpf_inp_str __gmpf_inp_str
1357 #ifdef _GMP_H_HAVE_FILE
1358 __GMP_DECLSPEC size_t mpf_inp_str __GMP_PROTO ((mpf_ptr, FILE *, int));
1361 #define mpf_integer_p __gmpf_integer_p
1362 __GMP_DECLSPEC int mpf_integer_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1364 #define mpf_mul __gmpf_mul
1365 __GMP_DECLSPEC void mpf_mul __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
1367 #define mpf_mul_2exp __gmpf_mul_2exp
1368 __GMP_DECLSPEC void mpf_mul_2exp __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1370 #define mpf_mul_ui __gmpf_mul_ui
1371 __GMP_DECLSPEC void mpf_mul_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1373 #define mpf_neg __gmpf_neg
1374 __GMP_DECLSPEC void mpf_neg __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1376 #define mpf_out_str __gmpf_out_str
1377 #ifdef _GMP_H_HAVE_FILE
1378 __GMP_DECLSPEC size_t mpf_out_str __GMP_PROTO ((FILE *, int, size_t, mpf_srcptr));
1381 #define mpf_pow_ui __gmpf_pow_ui
1382 __GMP_DECLSPEC void mpf_pow_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1384 #define mpf_random2 __gmpf_random2
1385 __GMP_DECLSPEC void mpf_random2 __GMP_PROTO ((mpf_ptr, mp_size_t, mp_exp_t));
1387 #define mpf_reldiff __gmpf_reldiff
1388 __GMP_DECLSPEC void mpf_reldiff __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
1390 #define mpf_set __gmpf_set
1391 __GMP_DECLSPEC void mpf_set __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1393 #define mpf_set_d __gmpf_set_d
1394 __GMP_DECLSPEC void mpf_set_d __GMP_PROTO ((mpf_ptr, double));
1396 #define mpf_set_default_prec __gmpf_set_default_prec
1397 __GMP_DECLSPEC void mpf_set_default_prec __GMP_PROTO ((unsigned long int)) __GMP_NOTHROW;
1399 #define mpf_set_prec __gmpf_set_prec
1400 __GMP_DECLSPEC void mpf_set_prec __GMP_PROTO ((mpf_ptr, unsigned long int));
1402 #define mpf_set_prec_raw __gmpf_set_prec_raw
1403 __GMP_DECLSPEC void mpf_set_prec_raw __GMP_PROTO ((mpf_ptr, unsigned long int)) __GMP_NOTHROW;
1405 #define mpf_set_q __gmpf_set_q
1406 __GMP_DECLSPEC void mpf_set_q __GMP_PROTO ((mpf_ptr, mpq_srcptr));
1408 #define mpf_set_si __gmpf_set_si
1409 __GMP_DECLSPEC void mpf_set_si __GMP_PROTO ((mpf_ptr, signed long int));
1411 #define mpf_set_str __gmpf_set_str
1412 __GMP_DECLSPEC int mpf_set_str __GMP_PROTO ((mpf_ptr, __gmp_const char *, int));
1414 #define mpf_set_ui __gmpf_set_ui
1415 __GMP_DECLSPEC void mpf_set_ui __GMP_PROTO ((mpf_ptr, unsigned long int));
1417 #define mpf_set_z __gmpf_set_z
1418 __GMP_DECLSPEC void mpf_set_z __GMP_PROTO ((mpf_ptr, mpz_srcptr));
1420 #define mpf_size __gmpf_size
1421 __GMP_DECLSPEC size_t mpf_size __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1423 #define mpf_sqrt __gmpf_sqrt
1424 __GMP_DECLSPEC void mpf_sqrt __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1426 #define mpf_sqrt_ui __gmpf_sqrt_ui
1427 __GMP_DECLSPEC void mpf_sqrt_ui __GMP_PROTO ((mpf_ptr, unsigned long int));
1429 #define mpf_sub __gmpf_sub
1430 __GMP_DECLSPEC void mpf_sub __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
1432 #define mpf_sub_ui __gmpf_sub_ui
1433 __GMP_DECLSPEC void mpf_sub_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1435 #define mpf_swap __gmpf_swap
1436 __GMP_DECLSPEC void mpf_swap __GMP_PROTO ((mpf_ptr, mpf_ptr)) __GMP_NOTHROW;
1438 #define mpf_trunc __gmpf_trunc
1439 __GMP_DECLSPEC void mpf_trunc __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1441 #define mpf_ui_div __gmpf_ui_div
1442 __GMP_DECLSPEC void mpf_ui_div __GMP_PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
1444 #define mpf_ui_sub __gmpf_ui_sub
1445 __GMP_DECLSPEC void mpf_ui_sub __GMP_PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
1447 #define mpf_urandomb __gmpf_urandomb
1448 __GMP_DECLSPEC void mpf_urandomb __GMP_PROTO ((mpf_t, gmp_randstate_t, unsigned long int));
1451 /************ Low level positive-integer (i.e. N) routines. ************/
1453 /* This is ugly, but we need to make user calls reach the prefixed function. */
1455 #define mpn_add __MPN(add)
1456 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add)
1457 __GMP_DECLSPEC mp_limb_t mpn_add __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
1460 #define mpn_add_1 __MPN(add_1)
1461 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1)
1462 __GMP_DECLSPEC mp_limb_t mpn_add_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW;
1465 #define mpn_add_n __MPN(add_n)
1466 __GMP_DECLSPEC mp_limb_t mpn_add_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
1468 #define mpn_addmul_1 __MPN(addmul_1)
1469 __GMP_DECLSPEC mp_limb_t mpn_addmul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
1471 #define mpn_bdivmod __MPN(bdivmod)
1472 __GMP_DECLSPEC mp_limb_t mpn_bdivmod __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, unsigned long int));
1474 #define mpn_cmp __MPN(cmp)
1475 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp)
1476 __GMP_DECLSPEC int mpn_cmp __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1479 #define mpn_divexact_by3(dst,src,size) \
1480 mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0))
1482 #define mpn_divexact_by3c __MPN(divexact_by3c)
1483 __GMP_DECLSPEC mp_limb_t mpn_divexact_by3c __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
1485 #define mpn_divmod_1(qp,np,nsize,dlimb) \
1486 mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb)
1488 #define mpn_divrem __MPN(divrem)
1489 __GMP_DECLSPEC mp_limb_t mpn_divrem __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t));
1491 #define mpn_divrem_1 __MPN(divrem_1)
1492 __GMP_DECLSPEC mp_limb_t mpn_divrem_1 __GMP_PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t));
1494 #define mpn_divrem_2 __MPN(divrem_2)
1495 __GMP_DECLSPEC mp_limb_t mpn_divrem_2 __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr));
1497 #define mpn_gcd __MPN(gcd)
1498 __GMP_DECLSPEC mp_size_t mpn_gcd __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t));
1500 #define mpn_gcd_1 __MPN(gcd_1)
1501 __GMP_DECLSPEC mp_limb_t mpn_gcd_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE;
1503 #define mpn_gcdext __MPN(gcdext)
1504 __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));
1506 #define mpn_get_str __MPN(get_str)
1507 __GMP_DECLSPEC size_t mpn_get_str __GMP_PROTO ((unsigned char *, int, mp_ptr, mp_size_t));
1509 #define mpn_hamdist __MPN(hamdist)
1510 __GMP_DECLSPEC unsigned long int mpn_hamdist __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1512 #define mpn_lshift __MPN(lshift)
1513 __GMP_DECLSPEC mp_limb_t mpn_lshift __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
1515 #define mpn_mod_1 __MPN(mod_1)
1516 __GMP_DECLSPEC mp_limb_t mpn_mod_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE;
1518 #define mpn_mul __MPN(mul)
1519 __GMP_DECLSPEC mp_limb_t mpn_mul __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));
1521 #define mpn_mul_1 __MPN(mul_1)
1522 __GMP_DECLSPEC mp_limb_t mpn_mul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
1524 #define mpn_mul_n __MPN(mul_n)
1525 __GMP_DECLSPEC void mpn_mul_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
1527 #define mpn_perfect_square_p __MPN(perfect_square_p)
1528 __GMP_DECLSPEC int mpn_perfect_square_p __GMP_PROTO ((mp_srcptr, mp_size_t)) __GMP_ATTRIBUTE_PURE;
1530 #define mpn_popcount __MPN(popcount)
1531 __GMP_DECLSPEC unsigned long int mpn_popcount __GMP_PROTO ((mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1533 #define mpn_pow_1 __MPN(pow_1)
1534 __GMP_DECLSPEC mp_size_t mpn_pow_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr));
1536 /* undocumented now, but retained here for upward compatibility */
1537 #define mpn_preinv_mod_1 __MPN(preinv_mod_1)
1538 __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;
1540 #define mpn_random __MPN(random)
1541 __GMP_DECLSPEC void mpn_random __GMP_PROTO ((mp_ptr, mp_size_t));
1543 #define mpn_random2 __MPN(random2)
1544 __GMP_DECLSPEC void mpn_random2 __GMP_PROTO ((mp_ptr, mp_size_t));
1546 #define mpn_rshift __MPN(rshift)
1547 __GMP_DECLSPEC mp_limb_t mpn_rshift __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
1549 #define mpn_scan0 __MPN(scan0)
1550 __GMP_DECLSPEC unsigned long int mpn_scan0 __GMP_PROTO ((mp_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
1552 #define mpn_scan1 __MPN(scan1)
1553 __GMP_DECLSPEC unsigned long int mpn_scan1 __GMP_PROTO ((mp_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
1555 #define mpn_set_str __MPN(set_str)
1556 __GMP_DECLSPEC mp_size_t mpn_set_str __GMP_PROTO ((mp_ptr, __gmp_const unsigned char *, size_t, int));
1558 #define mpn_sqrtrem __MPN(sqrtrem)
1559 __GMP_DECLSPEC mp_size_t mpn_sqrtrem __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t));
1561 #define mpn_sub __MPN(sub)
1562 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub)
1563 __GMP_DECLSPEC mp_limb_t mpn_sub __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
1566 #define mpn_sub_1 __MPN(sub_1)
1567 #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1)
1568 __GMP_DECLSPEC mp_limb_t mpn_sub_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW;
1571 #define mpn_sub_n __MPN(sub_n)
1572 __GMP_DECLSPEC mp_limb_t mpn_sub_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
1574 #define mpn_submul_1 __MPN(submul_1)
1575 __GMP_DECLSPEC mp_limb_t mpn_submul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
1577 #define mpn_tdiv_qr __MPN(tdiv_qr)
1578 __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));
1581 /**************** mpz inlines ****************/
1583 /* The following are provided as inlines where possible, but always exist as
1584 library functions too, for binary compatibility.
1586 Within gmp itself this inlining generally isn't relied on, since it
1587 doesn't get done for all compilers, whereas if something is worth
1588 inlining then it's worth arranging always.
1590 There are two styles of inlining here. When the same bit of code is
1591 wanted for the inline as for the library version, then __GMP_FORCE_foo
1592 arranges for that code to be emitted and the __GMP_EXTERN_INLINE
1593 directive suppressed, eg. mpz_fits_uint_p. When a different bit of code
1594 is wanted for the inline than for the library version, then
1595 __GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs. */
1597 #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs)
1598 __GMP_EXTERN_INLINE void
1599 mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)
1601 if (__gmp_w != __gmp_u)
1602 mpz_set (__gmp_w, __gmp_u);
1603 __gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size);
1607 #if GMP_NAIL_BITS == 0
1608 #define __GMPZ_FITS_UTYPE_P(z,maxval) \
1609 mp_size_t __gmp_n = z->_mp_size; \
1610 mp_ptr __gmp_p = z->_mp_d; \
1611 return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval));
1613 #define __GMPZ_FITS_UTYPE_P(z,maxval) \
1614 mp_size_t __gmp_n = z->_mp_size; \
1615 mp_ptr __gmp_p = z->_mp_d; \
1616 return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval) \
1617 || (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS)));
1620 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p)
1621 #if ! defined (__GMP_FORCE_mpz_fits_uint_p)
1625 mpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
1627 __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_UINT_MAX);
1631 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p)
1632 #if ! defined (__GMP_FORCE_mpz_fits_ulong_p)
1636 mpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
1638 __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_ULONG_MAX);
1642 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p)
1643 #if ! defined (__GMP_FORCE_mpz_fits_ushort_p)
1647 mpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
1649 __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_USHRT_MAX);
1653 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui)
1654 #if ! defined (__GMP_FORCE_mpz_get_ui)
1658 mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW
1660 mp_ptr __gmp_p = __gmp_z->_mp_d;
1661 mp_size_t __gmp_n = __gmp_z->_mp_size;
1662 mp_limb_t __gmp_l = __gmp_p[0];
1663 /* This is a "#if" rather than a plain "if" so as to avoid gcc warnings
1664 about "<< GMP_NUMB_BITS" exceeding the type size, and to avoid Borland
1665 C++ 6.0 warnings about condition always true for something like
1666 "__GMP_ULONG_MAX < GMP_NUMB_MASK". */
1667 #if GMP_NAIL_BITS == 0 || defined (_LONG_LONG_LIMB)
1668 /* limb==long and no nails, or limb==longlong, one limb is enough */
1669 return (__gmp_n != 0 ? __gmp_l : 0);
1671 /* limb==long and nails, need two limbs when available */
1672 __gmp_n = __GMP_ABS (__gmp_n);
1674 return (__gmp_n != 0 ? __gmp_l : 0);
1676 return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS);
1681 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn)
1682 #if ! defined (__GMP_FORCE_mpz_getlimbn)
1686 mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW
1688 mp_limb_t __gmp_result = 0;
1689 if (__GMP_LIKELY (__gmp_n >= 0 && __gmp_n < __GMP_ABS (__gmp_z->_mp_size)))
1690 __gmp_result = __gmp_z->_mp_d[__gmp_n];
1691 return __gmp_result;
1695 #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg)
1696 __GMP_EXTERN_INLINE void
1697 mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)
1699 if (__gmp_w != __gmp_u)
1700 mpz_set (__gmp_w, __gmp_u);
1701 __gmp_w->_mp_size = - __gmp_w->_mp_size;
1705 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p)
1706 #if ! defined (__GMP_FORCE_mpz_perfect_square_p)
1710 mpz_perfect_square_p (mpz_srcptr __gmp_a)
1712 mp_size_t __gmp_asize;
1715 __gmp_asize = __gmp_a->_mp_size;
1716 __gmp_result = (__gmp_asize >= 0); /* zero is a square, negatives are not */
1717 if (__GMP_LIKELY (__gmp_asize > 0))
1718 __gmp_result = mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize);
1719 return __gmp_result;
1723 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount)
1724 #if ! defined (__GMP_FORCE_mpz_popcount)
1728 mpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW
1730 mp_size_t __gmp_usize;
1731 unsigned long __gmp_result;
1733 __gmp_usize = __gmp_u->_mp_size;
1734 __gmp_result = (__gmp_usize < 0 ? __GMP_ULONG_MAX : 0);
1735 if (__GMP_LIKELY (__gmp_usize > 0))
1736 __gmp_result = mpn_popcount (__gmp_u->_mp_d, __gmp_usize);
1737 return __gmp_result;
1741 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q)
1742 #if ! defined (__GMP_FORCE_mpz_set_q)
1746 mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u)
1748 mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u));
1752 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size)
1753 #if ! defined (__GMP_FORCE_mpz_size)
1757 mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW
1759 return __GMP_ABS (__gmp_z->_mp_size);
1764 /**************** mpq inlines ****************/
1766 #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs)
1767 __GMP_EXTERN_INLINE void
1768 mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)
1770 if (__gmp_w != __gmp_u)
1771 mpq_set (__gmp_w, __gmp_u);
1772 __gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size);
1776 #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg)
1777 __GMP_EXTERN_INLINE void
1778 mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)
1780 if (__gmp_w != __gmp_u)
1781 mpq_set (__gmp_w, __gmp_u);
1782 __gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size;
1787 /**************** mpn inlines ****************/
1789 /* The comments with __GMPN_ADD_1 below apply here too.
1791 The test for FUNCTION returning 0 should predict well. If it's assumed
1792 {yp,ysize} will usually have a random number of bits then the high limb
1793 won't be full and a carry out will occur a good deal less than 50% of the
1796 ysize==0 isn't a documented feature, but is used internally in a few
1799 Producing cout last stops it using up a register during the main part of
1800 the calculation, though gcc (as of 3.0) on an "if (mpn_add (...))"
1801 doesn't seem able to move the true and false legs of the conditional up
1802 to the two places cout is generated. */
1804 #define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST) \
1806 mp_size_t __gmp_i; \
1807 mp_limb_t __gmp_x; \
1809 /* ASSERT ((ysize) >= 0); */ \
1810 /* ASSERT ((xsize) >= (ysize)); */ \
1811 /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */ \
1812 /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */ \
1814 __gmp_i = (ysize); \
1817 if (FUNCTION (wp, xp, yp, __gmp_i)) \
1821 if (__gmp_i >= (xsize)) \
1826 __gmp_x = (xp)[__gmp_i]; \
1832 __GMPN_COPY_REST (wp, xp, xsize, __gmp_i); \
1838 #define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize) \
1839 __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n, \
1840 (((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0))
1841 #define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize) \
1842 __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n, \
1843 (((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0))
1846 /* The use of __gmp_i indexing is designed to ensure a compile time src==dst
1847 remains nice and clear to the compiler, so that __GMPN_COPY_REST can
1848 disappear, and the load/add/store gets a chance to become a
1849 read-modify-write on CISC CPUs.
1853 Using a pair of pointers instead of indexing would be possible, but gcc
1854 isn't able to recognise compile-time src==dst in that case, even when the
1855 pointers are incremented more or less together. Other compilers would
1856 very likely have similar difficulty.
1858 gcc could use "if (__builtin_constant_p(src==dst) && src==dst)" or
1859 similar to detect a compile-time src==dst. This works nicely on gcc
1860 2.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems
1861 to be always false, for a pointer p. But the current code form seems
1862 good enough for src==dst anyway.
1864 gcc on x86 as usual doesn't give particularly good flags handling for the
1865 carry/borrow detection. It's tempting to want some multi instruction asm
1866 blocks to help it, and this was tried, but in truth there's only a few
1867 instructions to save and any gain is all too easily lost by register
1868 juggling setting up for the asm. */
1870 #if GMP_NAIL_BITS == 0
1871 #define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \
1873 mp_size_t __gmp_i; \
1874 mp_limb_t __gmp_x, __gmp_r; \
1876 /* ASSERT ((n) >= 1); */ \
1877 /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \
1879 __gmp_x = (src)[0]; \
1880 __gmp_r = __gmp_x OP (v); \
1881 (dst)[0] = __gmp_r; \
1882 if (CB (__gmp_r, __gmp_x, (v))) \
1885 for (__gmp_i = 1; __gmp_i < (n);) \
1887 __gmp_x = (src)[__gmp_i]; \
1888 __gmp_r = __gmp_x OP 1; \
1889 (dst)[__gmp_i] = __gmp_r; \
1891 if (!CB (__gmp_r, __gmp_x, 1)) \
1893 if ((src) != (dst)) \
1894 __GMPN_COPY_REST (dst, src, n, __gmp_i); \
1902 if ((src) != (dst)) \
1903 __GMPN_COPY_REST (dst, src, n, 1); \
1909 #if GMP_NAIL_BITS >= 1
1910 #define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \
1912 mp_size_t __gmp_i; \
1913 mp_limb_t __gmp_x, __gmp_r; \
1915 /* ASSERT ((n) >= 1); */ \
1916 /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \
1918 __gmp_x = (src)[0]; \
1919 __gmp_r = __gmp_x OP (v); \
1920 (dst)[0] = __gmp_r & GMP_NUMB_MASK; \
1921 if (__gmp_r >> GMP_NUMB_BITS != 0) \
1924 for (__gmp_i = 1; __gmp_i < (n);) \
1926 __gmp_x = (src)[__gmp_i]; \
1927 __gmp_r = __gmp_x OP 1; \
1928 (dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK; \
1930 if (__gmp_r >> GMP_NUMB_BITS == 0) \
1932 if ((src) != (dst)) \
1933 __GMPN_COPY_REST (dst, src, n, __gmp_i); \
1941 if ((src) != (dst)) \
1942 __GMPN_COPY_REST (dst, src, n, 1); \
1948 #define __GMPN_ADDCB(r,x,y) ((r) < (y))
1949 #define __GMPN_SUBCB(r,x,y) ((x) < (y))
1951 #define __GMPN_ADD_1(cout, dst, src, n, v) \
1952 __GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB)
1953 #define __GMPN_SUB_1(cout, dst, src, n, v) \
1954 __GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB)
1957 /* Compare {xp,size} and {yp,size}, setting "result" to positive, zero or
1958 negative. size==0 is allowed. On random data usually only one limb will
1959 need to be examined to get a result, so it's worth having it inline. */
1960 #define __GMPN_CMP(result, xp, yp, size) \
1962 mp_size_t __gmp_i; \
1963 mp_limb_t __gmp_x, __gmp_y; \
1965 /* ASSERT ((size) >= 0); */ \
1969 while (--__gmp_i >= 0) \
1971 __gmp_x = (xp)[__gmp_i]; \
1972 __gmp_y = (yp)[__gmp_i]; \
1973 if (__gmp_x != __gmp_y) \
1975 /* Cannot use __gmp_x - __gmp_y, may overflow an "int" */ \
1976 (result) = (__gmp_x > __gmp_y ? 1 : -1); \
1983 #if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST)
1984 #define __GMPN_COPY_REST(dst, src, size, start) \
1986 /* ASSERT ((start) >= 0); */ \
1987 /* ASSERT ((start) <= (size)); */ \
1988 __GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \
1992 /* Copy {src,size} to {dst,size}, starting at "start". This is designed to
1993 keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1,
1995 #if ! defined (__GMPN_COPY_REST)
1996 #define __GMPN_COPY_REST(dst, src, size, start) \
1998 mp_size_t __gmp_j; \
1999 /* ASSERT ((size) >= 0); */ \
2000 /* ASSERT ((start) >= 0); */ \
2001 /* ASSERT ((start) <= (size)); */ \
2002 /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */ \
2003 __GMP_CRAY_Pragma ("_CRI ivdep"); \
2004 for (__gmp_j = (start); __gmp_j < (size); __gmp_j++) \
2005 (dst)[__gmp_j] = (src)[__gmp_j]; \
2009 /* Enhancement: Use some of the smarter code from gmp-impl.h. Maybe use
2010 mpn_copyi if there's a native version, and if we don't mind demanding
2011 binary compatibility for it (on targets which use it). */
2013 #if ! defined (__GMPN_COPY)
2014 #define __GMPN_COPY(dst, src, size) __GMPN_COPY_REST (dst, src, size, 0)
2018 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add)
2019 #if ! defined (__GMP_FORCE_mpn_add)
2023 mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)
2026 __GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);
2031 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1)
2032 #if ! defined (__GMP_FORCE_mpn_add_1)
2036 mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW
2039 __GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);
2044 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp)
2045 #if ! defined (__GMP_FORCE_mpn_cmp)
2049 mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW
2052 __GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size);
2053 return __gmp_result;
2057 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub)
2058 #if ! defined (__GMP_FORCE_mpn_sub)
2062 mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)
2065 __GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);
2070 #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1)
2071 #if ! defined (__GMP_FORCE_mpn_sub_1)
2075 mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW
2078 __GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);
2083 #if defined (__cplusplus)
2088 /* Allow faster testing for negative, zero, and positive. */
2089 #define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
2090 #define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)
2091 #define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0)
2093 /* When using GCC, optimize certain common comparisons. */
2094 #if defined (__GNUC__)
2095 #define mpz_cmp_ui(Z,UI) \
2096 (__builtin_constant_p (UI) && (UI) == 0 \
2097 ? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))
2098 #define mpz_cmp_si(Z,SI) \
2099 (__builtin_constant_p (SI) && (SI) == 0 ? mpz_sgn (Z) \
2100 : __builtin_constant_p (SI) && (SI) > 0 \
2101 ? _mpz_cmp_ui (Z, __GMP_CAST (unsigned long int, SI)) \
2102 : _mpz_cmp_si (Z,SI))
2103 #define mpq_cmp_ui(Q,NUI,DUI) \
2104 (__builtin_constant_p (NUI) && (NUI) == 0 \
2105 ? mpq_sgn (Q) : _mpq_cmp_ui (Q,NUI,DUI))
2106 #define mpq_cmp_si(q,n,d) \
2107 (__builtin_constant_p ((n) >= 0) && (n) >= 0 \
2108 ? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d) \
2109 : _mpq_cmp_si (q, n, d))
2111 #define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI)
2112 #define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI)
2113 #define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI)
2114 #define mpq_cmp_si(q,n,d) _mpq_cmp_si(q,n,d)
2118 /* Using "&" rather than "&&" means these can come out branch-free. Every
2119 mpz_t has at least one limb allocated, so fetching the low limb is always
2121 #define mpz_odd_p(z) (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0]))
2122 #define mpz_even_p(z) (! mpz_odd_p (z))
2125 /**************** C++ routines ****************/
2128 __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr);
2129 __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr);
2130 __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr);
2131 __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr);
2132 __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr);
2133 __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr);
2137 /* Source-level compatibility with GMP 2 and earlier. */
2138 #define mpn_divmod(qp,np,nsize,dp,dsize) \
2139 mpn_divrem (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dp, dsize)
2141 /* Source-level compatibility with GMP 1. */
2142 #define mpz_mdiv mpz_fdiv_q
2143 #define mpz_mdivmod mpz_fdiv_qr
2144 #define mpz_mmod mpz_fdiv_r
2145 #define mpz_mdiv_ui mpz_fdiv_q_ui
2146 #define mpz_mdivmod_ui(q,r,n,d) \
2147 (((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d))
2148 #define mpz_mmod_ui(r,n,d) \
2149 (((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d))
2151 /* Useful synonyms, but not quite compatible with GMP 1. */
2152 #define mpz_div mpz_fdiv_q
2153 #define mpz_divmod mpz_fdiv_qr
2154 #define mpz_div_ui mpz_fdiv_q_ui
2155 #define mpz_divmod_ui mpz_fdiv_qr_ui
2156 #define mpz_div_2exp mpz_fdiv_q_2exp
2157 #define mpz_mod_2exp mpz_fdiv_r_2exp
2162 GMP_ERROR_UNSUPPORTED_ARGUMENT = 1,
2163 GMP_ERROR_DIVISION_BY_ZERO = 2,
2164 GMP_ERROR_SQRT_OF_NEGATIVE = 4,
2165 GMP_ERROR_INVALID_ARGUMENT = 8
2168 /* Major version number is the value of __GNU_MP__ too, above and in mp.h. */
2169 #define __GNU_MP_VERSION 4
2170 #define __GNU_MP_VERSION_MINOR 2
2171 #define __GNU_MP_VERSION_PATCHLEVEL 1
2174 #endif /* __GMP_H__ */