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