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