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