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