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