root/trunk/gmp/gmp.h

Revision 276, 80.9 kB (checked in by mp4, 4 years ago)

--

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