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