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