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