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