GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
/* Definitions for GNU multiple precision functions. -*- mode: c -*-12Copyright 1991, 1993-1997, 1999-2014 Free Software Foundation, Inc.34This file is part of the GNU MP Library.56The GNU MP Library is free software; you can redistribute it and/or modify7it under the terms of either:89* the GNU Lesser General Public License as published by the Free10Software Foundation; either version 3 of the License, or (at your11option) any later version.1213or1415* the GNU General Public License as published by the Free Software16Foundation; either version 2 of the License, or (at your option) any17later version.1819or both in parallel, as here.2021The GNU MP Library is distributed in the hope that it will be useful, but22WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY23or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License24for more details.2526You should have received copies of the GNU General Public License and the27GNU Lesser General Public License along with the GNU MP Library. If not,28see https://www.gnu.org/licenses/. */2930#ifndef __GMP_H__3132#if defined (__cplusplus)33#include <iosfwd> /* for std::istream, std::ostream, std::string */34#include <cstdio>35#endif363738/* Instantiated by configure. */39#if ! defined (__GMP_WITHIN_CONFIGURE)40#define __GMP_HAVE_HOST_CPU_FAMILY_power 041#define __GMP_HAVE_HOST_CPU_FAMILY_powerpc 042#define GMP_LIMB_BITS 6443#define GMP_NAIL_BITS 044#endif45#define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS)46#define GMP_NUMB_MASK ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS)47#define GMP_NUMB_MAX GMP_NUMB_MASK48#define GMP_NAIL_MASK (~ GMP_NUMB_MASK)495051/* The following (everything under ifndef __GNU_MP__) must be identical in52gmp.h and mp.h to allow both to be included in an application or during53the library build. */54#ifndef __GNU_MP__55#define __GNU_MP__ 55657#include <stddef.h> /* for size_t */5859/* Instantiated by configure. */60#if ! defined (__GMP_WITHIN_CONFIGURE)61/* #undef _LONG_LONG_LIMB */62#define __GMP_LIBGMP_DLL 063#endif646566/* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in67all other circumstances.6869When compiling objects for libgmp, __GMP_DECLSPEC is an export directive,70or when compiling for an application it's an import directive. The two71cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles72(and not defined from an application).7374__GMP_DECLSPEC_XX is similarly used for libgmpxx. __GMP_WITHIN_GMPXX75indicates when building libgmpxx, and in that case libgmpxx functions are76exports, but libgmp functions which might get called are imports.7778Libtool DLL_EXPORT define is not used.7980There's no attempt to support GMP built both static and DLL. Doing so81would mean applications would have to tell us which of the two is going82to be used when linking, and that seems very tedious and error prone if83using GMP by hand, and equally tedious from a package since autoconf and84automake don't give much help.8586__GMP_DECLSPEC is required on all documented global functions and87variables, the various internals in gmp-impl.h etc can be left unadorned.88But internals used by the test programs or speed measuring programs89should have __GMP_DECLSPEC, and certainly constants or variables must90have it or the wrong address will be resolved.9192In gcc __declspec can go at either the start or end of a prototype.9394In Microsoft C __declspec must go at the start, or after the type like95void __declspec(...) *foo()". There's no __dllexport or anything to96guard against someone foolish #defining dllexport. _export used to be97available, but no longer.9899In Borland C _export still exists, but needs to go after the type, like100"void _export foo();". Would have to change the __GMP_DECLSPEC syntax to101make use of that. Probably more trouble than it's worth. */102103#if defined (__GNUC__)104#define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__)105#define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__)106#endif107#if defined (_MSC_VER) || defined (__BORLANDC__)108#define __GMP_DECLSPEC_EXPORT __declspec(dllexport)109#define __GMP_DECLSPEC_IMPORT __declspec(dllimport)110#endif111#ifdef __WATCOMC__112#define __GMP_DECLSPEC_EXPORT __export113#define __GMP_DECLSPEC_IMPORT __import114#endif115#ifdef __IBMC__116#define __GMP_DECLSPEC_EXPORT _Export117#define __GMP_DECLSPEC_IMPORT _Import118#endif119120#if __GMP_LIBGMP_DLL121#ifdef __GMP_WITHIN_GMP122/* compiling to go into a DLL libgmp */123#define __GMP_DECLSPEC __GMP_DECLSPEC_EXPORT124#else125/* compiling to go into an application which will link to a DLL libgmp */126#define __GMP_DECLSPEC __GMP_DECLSPEC_IMPORT127#endif128#else129/* all other cases */130#define __GMP_DECLSPEC131#endif132133134#ifdef __GMP_SHORT_LIMB135typedef unsigned int mp_limb_t;136typedef int mp_limb_signed_t;137#else138#ifdef _LONG_LONG_LIMB139typedef unsigned long long int mp_limb_t;140typedef long long int mp_limb_signed_t;141#else142typedef unsigned long int mp_limb_t;143typedef long int mp_limb_signed_t;144#endif145#endif146typedef unsigned long int mp_bitcnt_t;147148/* For reference, note that the name __mpz_struct gets into C++ mangled149function names, which means although the "__" suggests an internal, we150must leave this name for binary compatibility. */151typedef struct152{153int _mp_alloc; /* Number of *limbs* allocated and pointed154to by the _mp_d field. */155int _mp_size; /* abs(_mp_size) is the number of limbs the156last field points to. If _mp_size is157negative this is a negative number. */158mp_limb_t *_mp_d; /* Pointer to the limbs. */159} __mpz_struct;160161#endif /* __GNU_MP__ */162163164typedef __mpz_struct MP_INT; /* gmp 1 source compatibility */165typedef __mpz_struct mpz_t[1];166167typedef mp_limb_t * mp_ptr;168typedef const mp_limb_t * mp_srcptr;169#if defined (_CRAY) && ! defined (_CRAYMPP)170/* plain `int' is much faster (48 bits) */171#define __GMP_MP_SIZE_T_INT 1172typedef int mp_size_t;173typedef int mp_exp_t;174#else175#define __GMP_MP_SIZE_T_INT 0176typedef long int mp_size_t;177typedef long int mp_exp_t;178#endif179180typedef struct181{182__mpz_struct _mp_num;183__mpz_struct _mp_den;184} __mpq_struct;185186typedef __mpq_struct MP_RAT; /* gmp 1 source compatibility */187typedef __mpq_struct mpq_t[1];188189typedef struct190{191int _mp_prec; /* Max precision, in number of `mp_limb_t's.192Set by mpf_init and modified by193mpf_set_prec. The area pointed to by the194_mp_d field contains `prec' + 1 limbs. */195int _mp_size; /* abs(_mp_size) is the number of limbs the196last field points to. If _mp_size is197negative this is a negative number. */198mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */199mp_limb_t *_mp_d; /* Pointer to the limbs. */200} __mpf_struct;201202/* typedef __mpf_struct MP_FLOAT; */203typedef __mpf_struct mpf_t[1];204205/* Available random number generation algorithms. */206typedef enum207{208GMP_RAND_ALG_DEFAULT = 0,209GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */210} gmp_randalg_t;211212/* Random state struct. */213typedef struct214{215mpz_t _mp_seed; /* _mp_d member points to state of the generator. */216gmp_randalg_t _mp_alg; /* Currently unused. */217union {218void *_mp_lc; /* Pointer to function pointers structure. */219} _mp_algdata;220} __gmp_randstate_struct;221typedef __gmp_randstate_struct gmp_randstate_t[1];222223/* Types for function declarations in gmp files. */224/* ??? Should not pollute user name space with these ??? */225typedef const __mpz_struct *mpz_srcptr;226typedef __mpz_struct *mpz_ptr;227typedef const __mpf_struct *mpf_srcptr;228typedef __mpf_struct *mpf_ptr;229typedef const __mpq_struct *mpq_srcptr;230typedef __mpq_struct *mpq_ptr;231232233/* This is not wanted in mp.h, so put it outside the __GNU_MP__ common234section. */235#if __GMP_LIBGMP_DLL236#ifdef __GMP_WITHIN_GMPXX237/* compiling to go into a DLL libgmpxx */238#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_EXPORT239#else240/* compiling to go into a application which will link to a DLL libgmpxx */241#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_IMPORT242#endif243#else244/* all other cases */245#define __GMP_DECLSPEC_XX246#endif247248249#ifndef __MPN250#define __MPN(x) __gmpn_##x251#endif252253/* For reference, "defined(EOF)" cannot be used here. In g++ 2.95.4,254<iostream> defines EOF but not FILE. */255#if defined (FILE) \256|| defined (H_STDIO) \257|| defined (_H_STDIO) /* AIX */ \258|| defined (_STDIO_H) /* glibc, Sun, SCO */ \259|| defined (_STDIO_H_) /* BSD, OSF */ \260|| defined (__STDIO_H) /* Borland */ \261|| defined (__STDIO_H__) /* IRIX */ \262|| defined (_STDIO_INCLUDED) /* HPUX */ \263|| defined (__dj_include_stdio_h_) /* DJGPP */ \264|| defined (_FILE_DEFINED) /* Microsoft */ \265|| defined (__STDIO__) /* Apple MPW MrC */ \266|| defined (_MSL_STDIO_H) /* Metrowerks */ \267|| defined (_STDIO_H_INCLUDED) /* QNX4 */ \268|| defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \269|| defined (__STDIO_LOADED) /* VMS */270#define _GMP_H_HAVE_FILE 1271#endif272273/* In ISO C, if a prototype involving "struct obstack *" is given without274that structure defined, then the struct is scoped down to just the275prototype, causing a conflict if it's subsequently defined for real. So276only give prototypes if we've got obstack.h. */277#if defined (_OBSTACK_H) /* glibc <obstack.h> */278#define _GMP_H_HAVE_OBSTACK 1279#endif280281/* The prototypes for gmp_vprintf etc are provided only if va_list is defined,282via an application having included <stdarg.h>. Usually va_list is a typedef283so can't be tested directly, but C99 specifies that va_start is a macro.284285<stdio.h> will define some sort of va_list for vprintf and vfprintf, but286let's not bother trying to use that since it's not standard and since287application uses for gmp_vprintf etc will almost certainly require the288whole <stdarg.h> anyway. */289290#ifdef va_start291#define _GMP_H_HAVE_VA_LIST 1292#endif293294/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */295#if defined (__GNUC__) && defined (__GNUC_MINOR__)296#define __GMP_GNUC_PREREQ(maj, min) \297((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))298#else299#define __GMP_GNUC_PREREQ(maj, min) 0300#endif301302/* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes". Basically303it means a function does nothing but examine its arguments and memory304(global or via arguments) to generate a return value, but changes nothing305and has no side-effects. __GMP_NO_ATTRIBUTE_CONST_PURE lets306tune/common.c etc turn this off when trying to write timing loops. */307#if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE)308#define __GMP_ATTRIBUTE_PURE __attribute__ ((__pure__))309#else310#define __GMP_ATTRIBUTE_PURE311#endif312313314/* __GMP_CAST allows us to use static_cast in C++, so our macros are clean315to "g++ -Wold-style-cast".316317Casts in "extern inline" code within an extern "C" block don't induce318these warnings, so __GMP_CAST only needs to be used on documented319macros. */320321#ifdef __cplusplus322#define __GMP_CAST(type, expr) (static_cast<type> (expr))323#else324#define __GMP_CAST(type, expr) ((type) (expr))325#endif326327328/* An empty "throw ()" means the function doesn't throw any C++ exceptions,329this can save some stack frame info in applications.330331Currently it's given only on functions which never divide-by-zero etc,332don't allocate memory, and are expected to never need to allocate memory.333This leaves open the possibility of a C++ throw from a future GMP334exceptions scheme.335336mpz_set_ui etc are omitted to leave open the lazy allocation scheme337described in doc/tasks.html. mpz_get_d etc are omitted to leave open338exceptions for float overflows.339340Note that __GMP_NOTHROW must be given on any inlines the same as on their341prototypes (for g++ at least, where they're used together). Note also342that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like343__GMP_ATTRIBUTE_PURE. */344345#if defined (__cplusplus)346#define __GMP_NOTHROW throw ()347#else348#define __GMP_NOTHROW349#endif350351352/* PORTME: What other compilers have a useful "extern inline"? "static353inline" would be an acceptable substitute if the compiler (or linker)354discards unused statics. */355356/* gcc has __inline__ in all modes, including strict ansi. Give a prototype357for an inline too, so as to correctly specify "dllimport" on windows, in358case the function is called rather than inlined.359GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99360inline semantics, unless -fgnu89-inline is used. */361#ifdef __GNUC__362#if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2) \363|| (defined __GNUC_GNU_INLINE__ && defined __cplusplus)364#define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__))365#else366#define __GMP_EXTERN_INLINE extern __inline__367#endif368#define __GMP_INLINE_PROTOTYPES 1369#endif370371/* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1372strict ANSI mode. Inlining is done even when not optimizing (ie. -O0373mode, which is the default), but an unnecessary local copy of foo is374emitted unless -O is used. "extern __inline" is accepted, but the375"extern" appears to be ignored, ie. it becomes a plain global function376but which is inlined within its file. Don't know if all old versions of377DEC C supported __inline, but as a start let's do the right thing for378current versions. */379#ifdef __DECC380#define __GMP_EXTERN_INLINE static __inline381#endif382383/* SCO OpenUNIX 8 cc supports "static inline foo()" but not in -Xc strict384ANSI mode (__STDC__ is 1 in that mode). Inlining only actually takes385place under -O. Without -O "foo" seems to be emitted whether it's used386or not, which is wasteful. "extern inline foo()" isn't useful, the387"extern" is apparently ignored, so foo is inlined if possible but also388emitted as a global, which causes multiple definition errors when389building a shared libgmp. */390#ifdef __SCO_VERSION__391#if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \392&& ! defined (__GMP_EXTERN_INLINE)393#define __GMP_EXTERN_INLINE static inline394#endif395#endif396397/* Microsoft's C compiler accepts __inline */398#ifdef _MSC_VER399#define __GMP_EXTERN_INLINE __inline400#endif401402/* Recent enough Sun C compilers want "inline" */403#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x560 \404&& ! defined (__GMP_EXTERN_INLINE)405#define __GMP_EXTERN_INLINE inline406#endif407408/* Somewhat older Sun C compilers want "static inline" */409#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x540 \410&& ! defined (__GMP_EXTERN_INLINE)411#define __GMP_EXTERN_INLINE static inline412#endif413414415/* C++ always has "inline" and since it's a normal feature the linker should416discard duplicate non-inlined copies, or if it doesn't then that's a417problem for everyone, not just GMP. */418#if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE)419#define __GMP_EXTERN_INLINE inline420#endif421422/* Don't do any inlining within a configure run, since if the compiler ends423up emitting copies of the code into the object file it can end up424demanding the various support routines (like mpn_popcount) for linking,425making the "alloca" test and perhaps others fail. And on hppa ia64 a426pre-release gcc 3.2 was seen not respecting the "extern" in "extern427__inline__", triggering this problem too. */428#if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE429#undef __GMP_EXTERN_INLINE430#endif431432/* By default, don't give a prototype when there's going to be an inline433version. Note in particular that Cray C++ objects to the combination of434prototype and inline. */435#ifdef __GMP_EXTERN_INLINE436#ifndef __GMP_INLINE_PROTOTYPES437#define __GMP_INLINE_PROTOTYPES 0438#endif439#else440#define __GMP_INLINE_PROTOTYPES 1441#endif442443444#define __GMP_ABS(x) ((x) >= 0 ? (x) : -(x))445#define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i))446447/* __GMP_USHRT_MAX is not "~ (unsigned short) 0" because short is promoted448to int by "~". It still needs to have the promoted type. */449#define __GMP_UINT_MAX (~ (unsigned) 0)450#define __GMP_ULONG_MAX (~ (unsigned long) 0)451#define __GMP_USHRT_MAX (0 + (unsigned short) ~0)452453454/* __builtin_expect is in gcc 3.0, and not in 2.95. */455#if __GMP_GNUC_PREREQ (3,0)456#define __GMP_LIKELY(cond) __builtin_expect ((cond) != 0, 1)457#define __GMP_UNLIKELY(cond) __builtin_expect ((cond) != 0, 0)458#else459#define __GMP_LIKELY(cond) (cond)460#define __GMP_UNLIKELY(cond) (cond)461#endif462463#ifdef _CRAY464#define __GMP_CRAY_Pragma(str) _Pragma (str)465#else466#define __GMP_CRAY_Pragma(str)467#endif468469470/* Allow direct user access to numerator and denominator of a mpq_t object. */471#define mpq_numref(Q) (&((Q)->_mp_num))472#define mpq_denref(Q) (&((Q)->_mp_den))473474475#if defined (__cplusplus)476extern "C" {477using std::FILE;478#endif479480#define mp_set_memory_functions __gmp_set_memory_functions481__GMP_DECLSPEC void mp_set_memory_functions (void *(*) (size_t),482void *(*) (void *, size_t, size_t),483void (*) (void *, size_t)) __GMP_NOTHROW;484485#define mp_get_memory_functions __gmp_get_memory_functions486__GMP_DECLSPEC void mp_get_memory_functions (void *(**) (size_t),487void *(**) (void *, size_t, size_t),488void (**) (void *, size_t)) __GMP_NOTHROW;489490#define mp_bits_per_limb __gmp_bits_per_limb491__GMP_DECLSPEC extern const int mp_bits_per_limb;492493#define gmp_errno __gmp_errno494__GMP_DECLSPEC extern int gmp_errno;495496#define gmp_version __gmp_version497__GMP_DECLSPEC extern const char * const gmp_version;498499500/**************** Random number routines. ****************/501502/* obsolete */503#define gmp_randinit __gmp_randinit504__GMP_DECLSPEC void gmp_randinit (gmp_randstate_t, gmp_randalg_t, ...);505506#define gmp_randinit_default __gmp_randinit_default507__GMP_DECLSPEC void gmp_randinit_default (gmp_randstate_t);508509#define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp510__GMP_DECLSPEC void gmp_randinit_lc_2exp (gmp_randstate_t, mpz_srcptr, unsigned long int, mp_bitcnt_t);511512#define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size513__GMP_DECLSPEC int gmp_randinit_lc_2exp_size (gmp_randstate_t, mp_bitcnt_t);514515#define gmp_randinit_mt __gmp_randinit_mt516__GMP_DECLSPEC void gmp_randinit_mt (gmp_randstate_t);517518#define gmp_randinit_set __gmp_randinit_set519__GMP_DECLSPEC void gmp_randinit_set (gmp_randstate_t, const __gmp_randstate_struct *);520521#define gmp_randseed __gmp_randseed522__GMP_DECLSPEC void gmp_randseed (gmp_randstate_t, mpz_srcptr);523524#define gmp_randseed_ui __gmp_randseed_ui525__GMP_DECLSPEC void gmp_randseed_ui (gmp_randstate_t, unsigned long int);526527#define gmp_randclear __gmp_randclear528__GMP_DECLSPEC void gmp_randclear (gmp_randstate_t);529530#define gmp_urandomb_ui __gmp_urandomb_ui531__GMP_DECLSPEC unsigned long gmp_urandomb_ui (gmp_randstate_t, unsigned long);532533#define gmp_urandomm_ui __gmp_urandomm_ui534__GMP_DECLSPEC unsigned long gmp_urandomm_ui (gmp_randstate_t, unsigned long);535536537/**************** Formatted output routines. ****************/538539#define gmp_asprintf __gmp_asprintf540__GMP_DECLSPEC int gmp_asprintf (char **, const char *, ...);541542#define gmp_fprintf __gmp_fprintf543#ifdef _GMP_H_HAVE_FILE544__GMP_DECLSPEC int gmp_fprintf (FILE *, const char *, ...);545#endif546547#define gmp_obstack_printf __gmp_obstack_printf548#if defined (_GMP_H_HAVE_OBSTACK)549__GMP_DECLSPEC int gmp_obstack_printf (struct obstack *, const char *, ...);550#endif551552#define gmp_obstack_vprintf __gmp_obstack_vprintf553#if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST)554__GMP_DECLSPEC int gmp_obstack_vprintf (struct obstack *, const char *, va_list);555#endif556557#define gmp_printf __gmp_printf558__GMP_DECLSPEC int gmp_printf (const char *, ...);559560#define gmp_snprintf __gmp_snprintf561__GMP_DECLSPEC int gmp_snprintf (char *, size_t, const char *, ...);562563#define gmp_sprintf __gmp_sprintf564__GMP_DECLSPEC int gmp_sprintf (char *, const char *, ...);565566#define gmp_vasprintf __gmp_vasprintf567#if defined (_GMP_H_HAVE_VA_LIST)568__GMP_DECLSPEC int gmp_vasprintf (char **, const char *, va_list);569#endif570571#define gmp_vfprintf __gmp_vfprintf572#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)573__GMP_DECLSPEC int gmp_vfprintf (FILE *, const char *, va_list);574#endif575576#define gmp_vprintf __gmp_vprintf577#if defined (_GMP_H_HAVE_VA_LIST)578__GMP_DECLSPEC int gmp_vprintf (const char *, va_list);579#endif580581#define gmp_vsnprintf __gmp_vsnprintf582#if defined (_GMP_H_HAVE_VA_LIST)583__GMP_DECLSPEC int gmp_vsnprintf (char *, size_t, const char *, va_list);584#endif585586#define gmp_vsprintf __gmp_vsprintf587#if defined (_GMP_H_HAVE_VA_LIST)588__GMP_DECLSPEC int gmp_vsprintf (char *, const char *, va_list);589#endif590591592/**************** Formatted input routines. ****************/593594#define gmp_fscanf __gmp_fscanf595#ifdef _GMP_H_HAVE_FILE596__GMP_DECLSPEC int gmp_fscanf (FILE *, const char *, ...);597#endif598599#define gmp_scanf __gmp_scanf600__GMP_DECLSPEC int gmp_scanf (const char *, ...);601602#define gmp_sscanf __gmp_sscanf603__GMP_DECLSPEC int gmp_sscanf (const char *, const char *, ...);604605#define gmp_vfscanf __gmp_vfscanf606#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)607__GMP_DECLSPEC int gmp_vfscanf (FILE *, const char *, va_list);608#endif609610#define gmp_vscanf __gmp_vscanf611#if defined (_GMP_H_HAVE_VA_LIST)612__GMP_DECLSPEC int gmp_vscanf (const char *, va_list);613#endif614615#define gmp_vsscanf __gmp_vsscanf616#if defined (_GMP_H_HAVE_VA_LIST)617__GMP_DECLSPEC int gmp_vsscanf (const char *, const char *, va_list);618#endif619620621/**************** Integer (i.e. Z) routines. ****************/622623#define _mpz_realloc __gmpz_realloc624#define mpz_realloc __gmpz_realloc625__GMP_DECLSPEC void *_mpz_realloc (mpz_ptr, mp_size_t);626627#define mpz_abs __gmpz_abs628#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs)629__GMP_DECLSPEC void mpz_abs (mpz_ptr, mpz_srcptr);630#endif631632#define mpz_add __gmpz_add633__GMP_DECLSPEC void mpz_add (mpz_ptr, mpz_srcptr, mpz_srcptr);634635#define mpz_add_ui __gmpz_add_ui636__GMP_DECLSPEC void mpz_add_ui (mpz_ptr, mpz_srcptr, unsigned long int);637638#define mpz_addmul __gmpz_addmul639__GMP_DECLSPEC void mpz_addmul (mpz_ptr, mpz_srcptr, mpz_srcptr);640641#define mpz_addmul_ui __gmpz_addmul_ui642__GMP_DECLSPEC void mpz_addmul_ui (mpz_ptr, mpz_srcptr, unsigned long int);643644#define mpz_and __gmpz_and645__GMP_DECLSPEC void mpz_and (mpz_ptr, mpz_srcptr, mpz_srcptr);646647#define mpz_array_init __gmpz_array_init648__GMP_DECLSPEC void mpz_array_init (mpz_ptr, mp_size_t, mp_size_t);649650#define mpz_bin_ui __gmpz_bin_ui651__GMP_DECLSPEC void mpz_bin_ui (mpz_ptr, mpz_srcptr, unsigned long int);652653#define mpz_bin_uiui __gmpz_bin_uiui654__GMP_DECLSPEC void mpz_bin_uiui (mpz_ptr, unsigned long int, unsigned long int);655656#define mpz_cdiv_q __gmpz_cdiv_q657__GMP_DECLSPEC void mpz_cdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);658659#define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp660__GMP_DECLSPEC void mpz_cdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);661662#define mpz_cdiv_q_ui __gmpz_cdiv_q_ui663__GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);664665#define mpz_cdiv_qr __gmpz_cdiv_qr666__GMP_DECLSPEC void mpz_cdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);667668#define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui669__GMP_DECLSPEC unsigned long int mpz_cdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);670671#define mpz_cdiv_r __gmpz_cdiv_r672__GMP_DECLSPEC void mpz_cdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);673674#define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp675__GMP_DECLSPEC void mpz_cdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);676677#define mpz_cdiv_r_ui __gmpz_cdiv_r_ui678__GMP_DECLSPEC unsigned long int mpz_cdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);679680#define mpz_cdiv_ui __gmpz_cdiv_ui681__GMP_DECLSPEC unsigned long int mpz_cdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;682683#define mpz_clear __gmpz_clear684__GMP_DECLSPEC void mpz_clear (mpz_ptr);685686#define mpz_clears __gmpz_clears687__GMP_DECLSPEC void mpz_clears (mpz_ptr, ...);688689#define mpz_clrbit __gmpz_clrbit690__GMP_DECLSPEC void mpz_clrbit (mpz_ptr, mp_bitcnt_t);691692#define mpz_cmp __gmpz_cmp693__GMP_DECLSPEC int mpz_cmp (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;694695#define mpz_cmp_d __gmpz_cmp_d696__GMP_DECLSPEC int mpz_cmp_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE;697698#define _mpz_cmp_si __gmpz_cmp_si699__GMP_DECLSPEC int _mpz_cmp_si (mpz_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;700701#define _mpz_cmp_ui __gmpz_cmp_ui702__GMP_DECLSPEC int _mpz_cmp_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;703704#define mpz_cmpabs __gmpz_cmpabs705__GMP_DECLSPEC int mpz_cmpabs (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;706707#define mpz_cmpabs_d __gmpz_cmpabs_d708__GMP_DECLSPEC int mpz_cmpabs_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE;709710#define mpz_cmpabs_ui __gmpz_cmpabs_ui711__GMP_DECLSPEC int mpz_cmpabs_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;712713#define mpz_com __gmpz_com714__GMP_DECLSPEC void mpz_com (mpz_ptr, mpz_srcptr);715716#define mpz_combit __gmpz_combit717__GMP_DECLSPEC void mpz_combit (mpz_ptr, mp_bitcnt_t);718719#define mpz_congruent_p __gmpz_congruent_p720__GMP_DECLSPEC int mpz_congruent_p (mpz_srcptr, mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;721722#define mpz_congruent_2exp_p __gmpz_congruent_2exp_p723__GMP_DECLSPEC int mpz_congruent_2exp_p (mpz_srcptr, mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;724725#define mpz_congruent_ui_p __gmpz_congruent_ui_p726__GMP_DECLSPEC int mpz_congruent_ui_p (mpz_srcptr, unsigned long, unsigned long) __GMP_ATTRIBUTE_PURE;727728#define mpz_divexact __gmpz_divexact729__GMP_DECLSPEC void mpz_divexact (mpz_ptr, mpz_srcptr, mpz_srcptr);730731#define mpz_divexact_ui __gmpz_divexact_ui732__GMP_DECLSPEC void mpz_divexact_ui (mpz_ptr, mpz_srcptr, unsigned long);733734#define mpz_divisible_p __gmpz_divisible_p735__GMP_DECLSPEC int mpz_divisible_p (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;736737#define mpz_divisible_ui_p __gmpz_divisible_ui_p738__GMP_DECLSPEC int mpz_divisible_ui_p (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE;739740#define mpz_divisible_2exp_p __gmpz_divisible_2exp_p741__GMP_DECLSPEC int mpz_divisible_2exp_p (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;742743#define mpz_dump __gmpz_dump744__GMP_DECLSPEC void mpz_dump (mpz_srcptr);745746#define mpz_export __gmpz_export747__GMP_DECLSPEC void *mpz_export (void *, size_t *, int, size_t, int, size_t, mpz_srcptr);748749#define mpz_fac_ui __gmpz_fac_ui750__GMP_DECLSPEC void mpz_fac_ui (mpz_ptr, unsigned long int);751752#define mpz_2fac_ui __gmpz_2fac_ui753__GMP_DECLSPEC void mpz_2fac_ui (mpz_ptr, unsigned long int);754755#define mpz_mfac_uiui __gmpz_mfac_uiui756__GMP_DECLSPEC void mpz_mfac_uiui (mpz_ptr, unsigned long int, unsigned long int);757758#define mpz_primorial_ui __gmpz_primorial_ui759__GMP_DECLSPEC void mpz_primorial_ui (mpz_ptr, unsigned long int);760761#define mpz_fdiv_q __gmpz_fdiv_q762__GMP_DECLSPEC void mpz_fdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);763764#define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp765__GMP_DECLSPEC void mpz_fdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);766767#define mpz_fdiv_q_ui __gmpz_fdiv_q_ui768__GMP_DECLSPEC unsigned long int mpz_fdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);769770#define mpz_fdiv_qr __gmpz_fdiv_qr771__GMP_DECLSPEC void mpz_fdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);772773#define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui774__GMP_DECLSPEC unsigned long int mpz_fdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);775776#define mpz_fdiv_r __gmpz_fdiv_r777__GMP_DECLSPEC void mpz_fdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);778779#define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp780__GMP_DECLSPEC void mpz_fdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);781782#define mpz_fdiv_r_ui __gmpz_fdiv_r_ui783__GMP_DECLSPEC unsigned long int mpz_fdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);784785#define mpz_fdiv_ui __gmpz_fdiv_ui786__GMP_DECLSPEC unsigned long int mpz_fdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;787788#define mpz_fib_ui __gmpz_fib_ui789__GMP_DECLSPEC void mpz_fib_ui (mpz_ptr, unsigned long int);790791#define mpz_fib2_ui __gmpz_fib2_ui792__GMP_DECLSPEC void mpz_fib2_ui (mpz_ptr, mpz_ptr, unsigned long int);793794#define mpz_fits_sint_p __gmpz_fits_sint_p795__GMP_DECLSPEC int mpz_fits_sint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;796797#define mpz_fits_slong_p __gmpz_fits_slong_p798__GMP_DECLSPEC int mpz_fits_slong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;799800#define mpz_fits_sshort_p __gmpz_fits_sshort_p801__GMP_DECLSPEC int mpz_fits_sshort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;802803#define mpz_fits_uint_p __gmpz_fits_uint_p804#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p)805__GMP_DECLSPEC int mpz_fits_uint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;806#endif807808#define mpz_fits_ulong_p __gmpz_fits_ulong_p809#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p)810__GMP_DECLSPEC int mpz_fits_ulong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;811#endif812813#define mpz_fits_ushort_p __gmpz_fits_ushort_p814#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p)815__GMP_DECLSPEC int mpz_fits_ushort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;816#endif817818#define mpz_gcd __gmpz_gcd819__GMP_DECLSPEC void mpz_gcd (mpz_ptr, mpz_srcptr, mpz_srcptr);820821#define mpz_gcd_ui __gmpz_gcd_ui822__GMP_DECLSPEC unsigned long int mpz_gcd_ui (mpz_ptr, mpz_srcptr, unsigned long int);823824#define mpz_gcdext __gmpz_gcdext825__GMP_DECLSPEC void mpz_gcdext (mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);826827#define mpz_get_d __gmpz_get_d828__GMP_DECLSPEC double mpz_get_d (mpz_srcptr) __GMP_ATTRIBUTE_PURE;829830#define mpz_get_d_2exp __gmpz_get_d_2exp831__GMP_DECLSPEC double mpz_get_d_2exp (signed long int *, mpz_srcptr);832833#define mpz_get_si __gmpz_get_si834__GMP_DECLSPEC /* signed */ long int mpz_get_si (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;835836#define mpz_get_str __gmpz_get_str837__GMP_DECLSPEC char *mpz_get_str (char *, int, mpz_srcptr);838839#define mpz_get_ui __gmpz_get_ui840#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui)841__GMP_DECLSPEC unsigned long int mpz_get_ui (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;842#endif843844#define mpz_getlimbn __gmpz_getlimbn845#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn)846__GMP_DECLSPEC mp_limb_t mpz_getlimbn (mpz_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;847#endif848849#define mpz_hamdist __gmpz_hamdist850__GMP_DECLSPEC mp_bitcnt_t mpz_hamdist (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;851852#define mpz_import __gmpz_import853__GMP_DECLSPEC void mpz_import (mpz_ptr, size_t, int, size_t, int, size_t, const void *);854855#define mpz_init __gmpz_init856__GMP_DECLSPEC void mpz_init (mpz_ptr);857858#define mpz_init2 __gmpz_init2859__GMP_DECLSPEC void mpz_init2 (mpz_ptr, mp_bitcnt_t);860861#define mpz_inits __gmpz_inits862__GMP_DECLSPEC void mpz_inits (mpz_ptr, ...);863864#define mpz_init_set __gmpz_init_set865__GMP_DECLSPEC void mpz_init_set (mpz_ptr, mpz_srcptr);866867#define mpz_init_set_d __gmpz_init_set_d868__GMP_DECLSPEC void mpz_init_set_d (mpz_ptr, double);869870#define mpz_init_set_si __gmpz_init_set_si871__GMP_DECLSPEC void mpz_init_set_si (mpz_ptr, signed long int);872873#define mpz_init_set_str __gmpz_init_set_str874__GMP_DECLSPEC int mpz_init_set_str (mpz_ptr, const char *, int);875876#define mpz_init_set_ui __gmpz_init_set_ui877__GMP_DECLSPEC void mpz_init_set_ui (mpz_ptr, unsigned long int);878879#define mpz_inp_raw __gmpz_inp_raw880#ifdef _GMP_H_HAVE_FILE881__GMP_DECLSPEC size_t mpz_inp_raw (mpz_ptr, FILE *);882#endif883884#define mpz_inp_str __gmpz_inp_str885#ifdef _GMP_H_HAVE_FILE886__GMP_DECLSPEC size_t mpz_inp_str (mpz_ptr, FILE *, int);887#endif888889#define mpz_invert __gmpz_invert890__GMP_DECLSPEC int mpz_invert (mpz_ptr, mpz_srcptr, mpz_srcptr);891892#define mpz_ior __gmpz_ior893__GMP_DECLSPEC void mpz_ior (mpz_ptr, mpz_srcptr, mpz_srcptr);894895#define mpz_jacobi __gmpz_jacobi896__GMP_DECLSPEC int mpz_jacobi (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;897898#define mpz_kronecker mpz_jacobi /* alias */899900#define mpz_kronecker_si __gmpz_kronecker_si901__GMP_DECLSPEC int mpz_kronecker_si (mpz_srcptr, long) __GMP_ATTRIBUTE_PURE;902903#define mpz_kronecker_ui __gmpz_kronecker_ui904__GMP_DECLSPEC int mpz_kronecker_ui (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE;905906#define mpz_si_kronecker __gmpz_si_kronecker907__GMP_DECLSPEC int mpz_si_kronecker (long, mpz_srcptr) __GMP_ATTRIBUTE_PURE;908909#define mpz_ui_kronecker __gmpz_ui_kronecker910__GMP_DECLSPEC int mpz_ui_kronecker (unsigned long, mpz_srcptr) __GMP_ATTRIBUTE_PURE;911912#define mpz_lcm __gmpz_lcm913__GMP_DECLSPEC void mpz_lcm (mpz_ptr, mpz_srcptr, mpz_srcptr);914915#define mpz_lcm_ui __gmpz_lcm_ui916__GMP_DECLSPEC void mpz_lcm_ui (mpz_ptr, mpz_srcptr, unsigned long);917918#define mpz_legendre mpz_jacobi /* alias */919920#define mpz_lucnum_ui __gmpz_lucnum_ui921__GMP_DECLSPEC void mpz_lucnum_ui (mpz_ptr, unsigned long int);922923#define mpz_lucnum2_ui __gmpz_lucnum2_ui924__GMP_DECLSPEC void mpz_lucnum2_ui (mpz_ptr, mpz_ptr, unsigned long int);925926#define mpz_millerrabin __gmpz_millerrabin927__GMP_DECLSPEC int mpz_millerrabin (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE;928929#define mpz_mod __gmpz_mod930__GMP_DECLSPEC void mpz_mod (mpz_ptr, mpz_srcptr, mpz_srcptr);931932#define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */933934#define mpz_mul __gmpz_mul935__GMP_DECLSPEC void mpz_mul (mpz_ptr, mpz_srcptr, mpz_srcptr);936937#define mpz_mul_2exp __gmpz_mul_2exp938__GMP_DECLSPEC void mpz_mul_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);939940#define mpz_mul_si __gmpz_mul_si941__GMP_DECLSPEC void mpz_mul_si (mpz_ptr, mpz_srcptr, long int);942943#define mpz_mul_ui __gmpz_mul_ui944__GMP_DECLSPEC void mpz_mul_ui (mpz_ptr, mpz_srcptr, unsigned long int);945946#define mpz_neg __gmpz_neg947#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg)948__GMP_DECLSPEC void mpz_neg (mpz_ptr, mpz_srcptr);949#endif950951#define mpz_nextprime __gmpz_nextprime952__GMP_DECLSPEC void mpz_nextprime (mpz_ptr, mpz_srcptr);953954#define mpz_out_raw __gmpz_out_raw955#ifdef _GMP_H_HAVE_FILE956__GMP_DECLSPEC size_t mpz_out_raw (FILE *, mpz_srcptr);957#endif958959#define mpz_out_str __gmpz_out_str960#ifdef _GMP_H_HAVE_FILE961__GMP_DECLSPEC size_t mpz_out_str (FILE *, int, mpz_srcptr);962#endif963964#define mpz_perfect_power_p __gmpz_perfect_power_p965__GMP_DECLSPEC int mpz_perfect_power_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE;966967#define mpz_perfect_square_p __gmpz_perfect_square_p968#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p)969__GMP_DECLSPEC int mpz_perfect_square_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE;970#endif971972#define mpz_popcount __gmpz_popcount973#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount)974__GMP_DECLSPEC mp_bitcnt_t mpz_popcount (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;975#endif976977#define mpz_pow_ui __gmpz_pow_ui978__GMP_DECLSPEC void mpz_pow_ui (mpz_ptr, mpz_srcptr, unsigned long int);979980#define mpz_powm __gmpz_powm981__GMP_DECLSPEC void mpz_powm (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr);982983#define mpz_powm_sec __gmpz_powm_sec984__GMP_DECLSPEC void mpz_powm_sec (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr);985986#define mpz_powm_ui __gmpz_powm_ui987__GMP_DECLSPEC void mpz_powm_ui (mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr);988989#define mpz_probab_prime_p __gmpz_probab_prime_p990__GMP_DECLSPEC int mpz_probab_prime_p (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE;991992#define mpz_random __gmpz_random993__GMP_DECLSPEC void mpz_random (mpz_ptr, mp_size_t);994995#define mpz_random2 __gmpz_random2996__GMP_DECLSPEC void mpz_random2 (mpz_ptr, mp_size_t);997998#define mpz_realloc2 __gmpz_realloc2999__GMP_DECLSPEC void mpz_realloc2 (mpz_ptr, mp_bitcnt_t);10001001#define mpz_remove __gmpz_remove1002__GMP_DECLSPEC mp_bitcnt_t mpz_remove (mpz_ptr, mpz_srcptr, mpz_srcptr);10031004#define mpz_root __gmpz_root1005__GMP_DECLSPEC int mpz_root (mpz_ptr, mpz_srcptr, unsigned long int);10061007#define mpz_rootrem __gmpz_rootrem1008__GMP_DECLSPEC void mpz_rootrem (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);10091010#define mpz_rrandomb __gmpz_rrandomb1011__GMP_DECLSPEC void mpz_rrandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t);10121013#define mpz_scan0 __gmpz_scan01014__GMP_DECLSPEC mp_bitcnt_t mpz_scan0 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;10151016#define mpz_scan1 __gmpz_scan11017__GMP_DECLSPEC mp_bitcnt_t mpz_scan1 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;10181019#define mpz_set __gmpz_set1020__GMP_DECLSPEC void mpz_set (mpz_ptr, mpz_srcptr);10211022#define mpz_set_d __gmpz_set_d1023__GMP_DECLSPEC void mpz_set_d (mpz_ptr, double);10241025#define mpz_set_f __gmpz_set_f1026__GMP_DECLSPEC void mpz_set_f (mpz_ptr, mpf_srcptr);10271028#define mpz_set_q __gmpz_set_q1029#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q)1030__GMP_DECLSPEC void mpz_set_q (mpz_ptr, mpq_srcptr);1031#endif10321033#define mpz_set_si __gmpz_set_si1034__GMP_DECLSPEC void mpz_set_si (mpz_ptr, signed long int);10351036#define mpz_set_str __gmpz_set_str1037__GMP_DECLSPEC int mpz_set_str (mpz_ptr, const char *, int);10381039#define mpz_set_ui __gmpz_set_ui1040__GMP_DECLSPEC void mpz_set_ui (mpz_ptr, unsigned long int);10411042#define mpz_setbit __gmpz_setbit1043__GMP_DECLSPEC void mpz_setbit (mpz_ptr, mp_bitcnt_t);10441045#define mpz_size __gmpz_size1046#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size)1047__GMP_DECLSPEC size_t mpz_size (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;1048#endif10491050#define mpz_sizeinbase __gmpz_sizeinbase1051__GMP_DECLSPEC size_t mpz_sizeinbase (mpz_srcptr, int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;10521053#define mpz_sqrt __gmpz_sqrt1054__GMP_DECLSPEC void mpz_sqrt (mpz_ptr, mpz_srcptr);10551056#define mpz_sqrtrem __gmpz_sqrtrem1057__GMP_DECLSPEC void mpz_sqrtrem (mpz_ptr, mpz_ptr, mpz_srcptr);10581059#define mpz_sub __gmpz_sub1060__GMP_DECLSPEC void mpz_sub (mpz_ptr, mpz_srcptr, mpz_srcptr);10611062#define mpz_sub_ui __gmpz_sub_ui1063__GMP_DECLSPEC void mpz_sub_ui (mpz_ptr, mpz_srcptr, unsigned long int);10641065#define mpz_ui_sub __gmpz_ui_sub1066__GMP_DECLSPEC void mpz_ui_sub (mpz_ptr, unsigned long int, mpz_srcptr);10671068#define mpz_submul __gmpz_submul1069__GMP_DECLSPEC void mpz_submul (mpz_ptr, mpz_srcptr, mpz_srcptr);10701071#define mpz_submul_ui __gmpz_submul_ui1072__GMP_DECLSPEC void mpz_submul_ui (mpz_ptr, mpz_srcptr, unsigned long int);10731074#define mpz_swap __gmpz_swap1075__GMP_DECLSPEC void mpz_swap (mpz_ptr, mpz_ptr) __GMP_NOTHROW;10761077#define mpz_tdiv_ui __gmpz_tdiv_ui1078__GMP_DECLSPEC unsigned long int mpz_tdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;10791080#define mpz_tdiv_q __gmpz_tdiv_q1081__GMP_DECLSPEC void mpz_tdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);10821083#define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp1084__GMP_DECLSPEC void mpz_tdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);10851086#define mpz_tdiv_q_ui __gmpz_tdiv_q_ui1087__GMP_DECLSPEC unsigned long int mpz_tdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);10881089#define mpz_tdiv_qr __gmpz_tdiv_qr1090__GMP_DECLSPEC void mpz_tdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);10911092#define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui1093__GMP_DECLSPEC unsigned long int mpz_tdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);10941095#define mpz_tdiv_r __gmpz_tdiv_r1096__GMP_DECLSPEC void mpz_tdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);10971098#define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp1099__GMP_DECLSPEC void mpz_tdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);11001101#define mpz_tdiv_r_ui __gmpz_tdiv_r_ui1102__GMP_DECLSPEC unsigned long int mpz_tdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);11031104#define mpz_tstbit __gmpz_tstbit1105__GMP_DECLSPEC int mpz_tstbit (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;11061107#define mpz_ui_pow_ui __gmpz_ui_pow_ui1108__GMP_DECLSPEC void mpz_ui_pow_ui (mpz_ptr, unsigned long int, unsigned long int);11091110#define mpz_urandomb __gmpz_urandomb1111__GMP_DECLSPEC void mpz_urandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t);11121113#define mpz_urandomm __gmpz_urandomm1114__GMP_DECLSPEC void mpz_urandomm (mpz_ptr, gmp_randstate_t, mpz_srcptr);11151116#define mpz_xor __gmpz_xor1117#define mpz_eor __gmpz_xor1118__GMP_DECLSPEC void mpz_xor (mpz_ptr, mpz_srcptr, mpz_srcptr);11191120#define mpz_limbs_read __gmpz_limbs_read1121__GMP_DECLSPEC mp_srcptr mpz_limbs_read (mpz_srcptr);11221123#define mpz_limbs_write __gmpz_limbs_write1124__GMP_DECLSPEC mp_ptr mpz_limbs_write (mpz_ptr, mp_size_t);11251126#define mpz_limbs_modify __gmpz_limbs_modify1127__GMP_DECLSPEC mp_ptr mpz_limbs_modify (mpz_ptr, mp_size_t);11281129#define mpz_limbs_finish __gmpz_limbs_finish1130__GMP_DECLSPEC void mpz_limbs_finish (mpz_ptr, mp_size_t);11311132#define mpz_roinit_n __gmpz_roinit_n1133__GMP_DECLSPEC mpz_srcptr mpz_roinit_n (mpz_ptr, mp_srcptr, mp_size_t);11341135#define MPZ_ROINIT_N(xp, xs) {{0, (xs),(xp) }}11361137/**************** Rational (i.e. Q) routines. ****************/11381139#define mpq_abs __gmpq_abs1140#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs)1141__GMP_DECLSPEC void mpq_abs (mpq_ptr, mpq_srcptr);1142#endif11431144#define mpq_add __gmpq_add1145__GMP_DECLSPEC void mpq_add (mpq_ptr, mpq_srcptr, mpq_srcptr);11461147#define mpq_canonicalize __gmpq_canonicalize1148__GMP_DECLSPEC void mpq_canonicalize (mpq_ptr);11491150#define mpq_clear __gmpq_clear1151__GMP_DECLSPEC void mpq_clear (mpq_ptr);11521153#define mpq_clears __gmpq_clears1154__GMP_DECLSPEC void mpq_clears (mpq_ptr, ...);11551156#define mpq_cmp __gmpq_cmp1157__GMP_DECLSPEC int mpq_cmp (mpq_srcptr, mpq_srcptr) __GMP_ATTRIBUTE_PURE;11581159#define _mpq_cmp_si __gmpq_cmp_si1160__GMP_DECLSPEC int _mpq_cmp_si (mpq_srcptr, long, unsigned long) __GMP_ATTRIBUTE_PURE;11611162#define _mpq_cmp_ui __gmpq_cmp_ui1163__GMP_DECLSPEC int _mpq_cmp_ui (mpq_srcptr, unsigned long int, unsigned long int) __GMP_ATTRIBUTE_PURE;11641165#define mpq_div __gmpq_div1166__GMP_DECLSPEC void mpq_div (mpq_ptr, mpq_srcptr, mpq_srcptr);11671168#define mpq_div_2exp __gmpq_div_2exp1169__GMP_DECLSPEC void mpq_div_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t);11701171#define mpq_equal __gmpq_equal1172__GMP_DECLSPEC int mpq_equal (mpq_srcptr, mpq_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;11731174#define mpq_get_num __gmpq_get_num1175__GMP_DECLSPEC void mpq_get_num (mpz_ptr, mpq_srcptr);11761177#define mpq_get_den __gmpq_get_den1178__GMP_DECLSPEC void mpq_get_den (mpz_ptr, mpq_srcptr);11791180#define mpq_get_d __gmpq_get_d1181__GMP_DECLSPEC double mpq_get_d (mpq_srcptr) __GMP_ATTRIBUTE_PURE;11821183#define mpq_get_str __gmpq_get_str1184__GMP_DECLSPEC char *mpq_get_str (char *, int, mpq_srcptr);11851186#define mpq_init __gmpq_init1187__GMP_DECLSPEC void mpq_init (mpq_ptr);11881189#define mpq_inits __gmpq_inits1190__GMP_DECLSPEC void mpq_inits (mpq_ptr, ...);11911192#define mpq_inp_str __gmpq_inp_str1193#ifdef _GMP_H_HAVE_FILE1194__GMP_DECLSPEC size_t mpq_inp_str (mpq_ptr, FILE *, int);1195#endif11961197#define mpq_inv __gmpq_inv1198__GMP_DECLSPEC void mpq_inv (mpq_ptr, mpq_srcptr);11991200#define mpq_mul __gmpq_mul1201__GMP_DECLSPEC void mpq_mul (mpq_ptr, mpq_srcptr, mpq_srcptr);12021203#define mpq_mul_2exp __gmpq_mul_2exp1204__GMP_DECLSPEC void mpq_mul_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t);12051206#define mpq_neg __gmpq_neg1207#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg)1208__GMP_DECLSPEC void mpq_neg (mpq_ptr, mpq_srcptr);1209#endif12101211#define mpq_out_str __gmpq_out_str1212#ifdef _GMP_H_HAVE_FILE1213__GMP_DECLSPEC size_t mpq_out_str (FILE *, int, mpq_srcptr);1214#endif12151216#define mpq_set __gmpq_set1217__GMP_DECLSPEC void mpq_set (mpq_ptr, mpq_srcptr);12181219#define mpq_set_d __gmpq_set_d1220__GMP_DECLSPEC void mpq_set_d (mpq_ptr, double);12211222#define mpq_set_den __gmpq_set_den1223__GMP_DECLSPEC void mpq_set_den (mpq_ptr, mpz_srcptr);12241225#define mpq_set_f __gmpq_set_f1226__GMP_DECLSPEC void mpq_set_f (mpq_ptr, mpf_srcptr);12271228#define mpq_set_num __gmpq_set_num1229__GMP_DECLSPEC void mpq_set_num (mpq_ptr, mpz_srcptr);12301231#define mpq_set_si __gmpq_set_si1232__GMP_DECLSPEC void mpq_set_si (mpq_ptr, signed long int, unsigned long int);12331234#define mpq_set_str __gmpq_set_str1235__GMP_DECLSPEC int mpq_set_str (mpq_ptr, const char *, int);12361237#define mpq_set_ui __gmpq_set_ui1238__GMP_DECLSPEC void mpq_set_ui (mpq_ptr, unsigned long int, unsigned long int);12391240#define mpq_set_z __gmpq_set_z1241__GMP_DECLSPEC void mpq_set_z (mpq_ptr, mpz_srcptr);12421243#define mpq_sub __gmpq_sub1244__GMP_DECLSPEC void mpq_sub (mpq_ptr, mpq_srcptr, mpq_srcptr);12451246#define mpq_swap __gmpq_swap1247__GMP_DECLSPEC void mpq_swap (mpq_ptr, mpq_ptr) __GMP_NOTHROW;124812491250/**************** Float (i.e. F) routines. ****************/12511252#define mpf_abs __gmpf_abs1253__GMP_DECLSPEC void mpf_abs (mpf_ptr, mpf_srcptr);12541255#define mpf_add __gmpf_add1256__GMP_DECLSPEC void mpf_add (mpf_ptr, mpf_srcptr, mpf_srcptr);12571258#define mpf_add_ui __gmpf_add_ui1259__GMP_DECLSPEC void mpf_add_ui (mpf_ptr, mpf_srcptr, unsigned long int);1260#define mpf_ceil __gmpf_ceil1261__GMP_DECLSPEC void mpf_ceil (mpf_ptr, mpf_srcptr);12621263#define mpf_clear __gmpf_clear1264__GMP_DECLSPEC void mpf_clear (mpf_ptr);12651266#define mpf_clears __gmpf_clears1267__GMP_DECLSPEC void mpf_clears (mpf_ptr, ...);12681269#define mpf_cmp __gmpf_cmp1270__GMP_DECLSPEC int mpf_cmp (mpf_srcptr, mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;12711272#define mpf_cmp_d __gmpf_cmp_d1273__GMP_DECLSPEC int mpf_cmp_d (mpf_srcptr, double) __GMP_ATTRIBUTE_PURE;12741275#define mpf_cmp_si __gmpf_cmp_si1276__GMP_DECLSPEC int mpf_cmp_si (mpf_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;12771278#define mpf_cmp_ui __gmpf_cmp_ui1279__GMP_DECLSPEC int mpf_cmp_ui (mpf_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;12801281#define mpf_div __gmpf_div1282__GMP_DECLSPEC void mpf_div (mpf_ptr, mpf_srcptr, mpf_srcptr);12831284#define mpf_div_2exp __gmpf_div_2exp1285__GMP_DECLSPEC void mpf_div_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t);12861287#define mpf_div_ui __gmpf_div_ui1288__GMP_DECLSPEC void mpf_div_ui (mpf_ptr, mpf_srcptr, unsigned long int);12891290#define mpf_dump __gmpf_dump1291__GMP_DECLSPEC void mpf_dump (mpf_srcptr);12921293#define mpf_eq __gmpf_eq1294__GMP_DECLSPEC int mpf_eq (mpf_srcptr, mpf_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;12951296#define mpf_fits_sint_p __gmpf_fits_sint_p1297__GMP_DECLSPEC int mpf_fits_sint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;12981299#define mpf_fits_slong_p __gmpf_fits_slong_p1300__GMP_DECLSPEC int mpf_fits_slong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13011302#define mpf_fits_sshort_p __gmpf_fits_sshort_p1303__GMP_DECLSPEC int mpf_fits_sshort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13041305#define mpf_fits_uint_p __gmpf_fits_uint_p1306__GMP_DECLSPEC int mpf_fits_uint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13071308#define mpf_fits_ulong_p __gmpf_fits_ulong_p1309__GMP_DECLSPEC int mpf_fits_ulong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13101311#define mpf_fits_ushort_p __gmpf_fits_ushort_p1312__GMP_DECLSPEC int mpf_fits_ushort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13131314#define mpf_floor __gmpf_floor1315__GMP_DECLSPEC void mpf_floor (mpf_ptr, mpf_srcptr);13161317#define mpf_get_d __gmpf_get_d1318__GMP_DECLSPEC double mpf_get_d (mpf_srcptr) __GMP_ATTRIBUTE_PURE;13191320#define mpf_get_d_2exp __gmpf_get_d_2exp1321__GMP_DECLSPEC double mpf_get_d_2exp (signed long int *, mpf_srcptr);13221323#define mpf_get_default_prec __gmpf_get_default_prec1324__GMP_DECLSPEC mp_bitcnt_t mpf_get_default_prec (void) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13251326#define mpf_get_prec __gmpf_get_prec1327__GMP_DECLSPEC mp_bitcnt_t mpf_get_prec (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13281329#define mpf_get_si __gmpf_get_si1330__GMP_DECLSPEC long mpf_get_si (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13311332#define mpf_get_str __gmpf_get_str1333__GMP_DECLSPEC char *mpf_get_str (char *, mp_exp_t *, int, size_t, mpf_srcptr);13341335#define mpf_get_ui __gmpf_get_ui1336__GMP_DECLSPEC unsigned long mpf_get_ui (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13371338#define mpf_init __gmpf_init1339__GMP_DECLSPEC void mpf_init (mpf_ptr);13401341#define mpf_init2 __gmpf_init21342__GMP_DECLSPEC void mpf_init2 (mpf_ptr, mp_bitcnt_t);13431344#define mpf_inits __gmpf_inits1345__GMP_DECLSPEC void mpf_inits (mpf_ptr, ...);13461347#define mpf_init_set __gmpf_init_set1348__GMP_DECLSPEC void mpf_init_set (mpf_ptr, mpf_srcptr);13491350#define mpf_init_set_d __gmpf_init_set_d1351__GMP_DECLSPEC void mpf_init_set_d (mpf_ptr, double);13521353#define mpf_init_set_si __gmpf_init_set_si1354__GMP_DECLSPEC void mpf_init_set_si (mpf_ptr, signed long int);13551356#define mpf_init_set_str __gmpf_init_set_str1357__GMP_DECLSPEC int mpf_init_set_str (mpf_ptr, const char *, int);13581359#define mpf_init_set_ui __gmpf_init_set_ui1360__GMP_DECLSPEC void mpf_init_set_ui (mpf_ptr, unsigned long int);13611362#define mpf_inp_str __gmpf_inp_str1363#ifdef _GMP_H_HAVE_FILE1364__GMP_DECLSPEC size_t mpf_inp_str (mpf_ptr, FILE *, int);1365#endif13661367#define mpf_integer_p __gmpf_integer_p1368__GMP_DECLSPEC int mpf_integer_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13691370#define mpf_mul __gmpf_mul1371__GMP_DECLSPEC void mpf_mul (mpf_ptr, mpf_srcptr, mpf_srcptr);13721373#define mpf_mul_2exp __gmpf_mul_2exp1374__GMP_DECLSPEC void mpf_mul_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t);13751376#define mpf_mul_ui __gmpf_mul_ui1377__GMP_DECLSPEC void mpf_mul_ui (mpf_ptr, mpf_srcptr, unsigned long int);13781379#define mpf_neg __gmpf_neg1380__GMP_DECLSPEC void mpf_neg (mpf_ptr, mpf_srcptr);13811382#define mpf_out_str __gmpf_out_str1383#ifdef _GMP_H_HAVE_FILE1384__GMP_DECLSPEC size_t mpf_out_str (FILE *, int, size_t, mpf_srcptr);1385#endif13861387#define mpf_pow_ui __gmpf_pow_ui1388__GMP_DECLSPEC void mpf_pow_ui (mpf_ptr, mpf_srcptr, unsigned long int);13891390#define mpf_random2 __gmpf_random21391__GMP_DECLSPEC void mpf_random2 (mpf_ptr, mp_size_t, mp_exp_t);13921393#define mpf_reldiff __gmpf_reldiff1394__GMP_DECLSPEC void mpf_reldiff (mpf_ptr, mpf_srcptr, mpf_srcptr);13951396#define mpf_set __gmpf_set1397__GMP_DECLSPEC void mpf_set (mpf_ptr, mpf_srcptr);13981399#define mpf_set_d __gmpf_set_d1400__GMP_DECLSPEC void mpf_set_d (mpf_ptr, double);14011402#define mpf_set_default_prec __gmpf_set_default_prec1403__GMP_DECLSPEC void mpf_set_default_prec (mp_bitcnt_t) __GMP_NOTHROW;14041405#define mpf_set_prec __gmpf_set_prec1406__GMP_DECLSPEC void mpf_set_prec (mpf_ptr, mp_bitcnt_t);14071408#define mpf_set_prec_raw __gmpf_set_prec_raw1409__GMP_DECLSPEC void mpf_set_prec_raw (mpf_ptr, mp_bitcnt_t) __GMP_NOTHROW;14101411#define mpf_set_q __gmpf_set_q1412__GMP_DECLSPEC void mpf_set_q (mpf_ptr, mpq_srcptr);14131414#define mpf_set_si __gmpf_set_si1415__GMP_DECLSPEC void mpf_set_si (mpf_ptr, signed long int);14161417#define mpf_set_str __gmpf_set_str1418__GMP_DECLSPEC int mpf_set_str (mpf_ptr, const char *, int);14191420#define mpf_set_ui __gmpf_set_ui1421__GMP_DECLSPEC void mpf_set_ui (mpf_ptr, unsigned long int);14221423#define mpf_set_z __gmpf_set_z1424__GMP_DECLSPEC void mpf_set_z (mpf_ptr, mpz_srcptr);14251426#define mpf_size __gmpf_size1427__GMP_DECLSPEC size_t mpf_size (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;14281429#define mpf_sqrt __gmpf_sqrt1430__GMP_DECLSPEC void mpf_sqrt (mpf_ptr, mpf_srcptr);14311432#define mpf_sqrt_ui __gmpf_sqrt_ui1433__GMP_DECLSPEC void mpf_sqrt_ui (mpf_ptr, unsigned long int);14341435#define mpf_sub __gmpf_sub1436__GMP_DECLSPEC void mpf_sub (mpf_ptr, mpf_srcptr, mpf_srcptr);14371438#define mpf_sub_ui __gmpf_sub_ui1439__GMP_DECLSPEC void mpf_sub_ui (mpf_ptr, mpf_srcptr, unsigned long int);14401441#define mpf_swap __gmpf_swap1442__GMP_DECLSPEC void mpf_swap (mpf_ptr, mpf_ptr) __GMP_NOTHROW;14431444#define mpf_trunc __gmpf_trunc1445__GMP_DECLSPEC void mpf_trunc (mpf_ptr, mpf_srcptr);14461447#define mpf_ui_div __gmpf_ui_div1448__GMP_DECLSPEC void mpf_ui_div (mpf_ptr, unsigned long int, mpf_srcptr);14491450#define mpf_ui_sub __gmpf_ui_sub1451__GMP_DECLSPEC void mpf_ui_sub (mpf_ptr, unsigned long int, mpf_srcptr);14521453#define mpf_urandomb __gmpf_urandomb1454__GMP_DECLSPEC void mpf_urandomb (mpf_t, gmp_randstate_t, mp_bitcnt_t);145514561457/************ Low level positive-integer (i.e. N) routines. ************/14581459/* This is ugly, but we need to make user calls reach the prefixed function. */14601461#define mpn_add __MPN(add)1462#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add)1463__GMP_DECLSPEC mp_limb_t mpn_add (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);1464#endif14651466#define mpn_add_1 __MPN(add_1)1467#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1)1468__GMP_DECLSPEC mp_limb_t mpn_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW;1469#endif14701471#define mpn_add_n __MPN(add_n)1472__GMP_DECLSPEC mp_limb_t mpn_add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);14731474#define mpn_addmul_1 __MPN(addmul_1)1475__GMP_DECLSPEC mp_limb_t mpn_addmul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);14761477#define mpn_cmp __MPN(cmp)1478#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp)1479__GMP_DECLSPEC int mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;1480#endif14811482#define mpn_divexact_by3(dst,src,size) \1483mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0))14841485#define mpn_divexact_by3c __MPN(divexact_by3c)1486__GMP_DECLSPEC mp_limb_t mpn_divexact_by3c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);14871488#define mpn_divmod_1(qp,np,nsize,dlimb) \1489mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb)14901491#define mpn_divrem __MPN(divrem)1492__GMP_DECLSPEC mp_limb_t mpn_divrem (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t);14931494#define mpn_divrem_1 __MPN(divrem_1)1495__GMP_DECLSPEC mp_limb_t mpn_divrem_1 (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t);14961497#define mpn_divrem_2 __MPN(divrem_2)1498__GMP_DECLSPEC mp_limb_t mpn_divrem_2 (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr);14991500#define mpn_div_qr_1 __MPN(div_qr_1)1501__GMP_DECLSPEC mp_limb_t mpn_div_qr_1 (mp_ptr, mp_limb_t *, mp_srcptr, mp_size_t, mp_limb_t);15021503#define mpn_div_qr_2 __MPN(div_qr_2)1504__GMP_DECLSPEC mp_limb_t mpn_div_qr_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr);15051506#define mpn_gcd __MPN(gcd)1507__GMP_DECLSPEC mp_size_t mpn_gcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t);15081509#define mpn_gcd_1 __MPN(gcd_1)1510__GMP_DECLSPEC mp_limb_t mpn_gcd_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;15111512#define mpn_gcdext_1 __MPN(gcdext_1)1513__GMP_DECLSPEC mp_limb_t mpn_gcdext_1 (mp_limb_signed_t *, mp_limb_signed_t *, mp_limb_t, mp_limb_t);15141515#define mpn_gcdext __MPN(gcdext)1516__GMP_DECLSPEC mp_size_t mpn_gcdext (mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_size_t, mp_ptr, mp_size_t);15171518#define mpn_get_str __MPN(get_str)1519__GMP_DECLSPEC size_t mpn_get_str (unsigned char *, int, mp_ptr, mp_size_t);15201521#define mpn_hamdist __MPN(hamdist)1522__GMP_DECLSPEC mp_bitcnt_t mpn_hamdist (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;15231524#define mpn_lshift __MPN(lshift)1525__GMP_DECLSPEC mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);15261527#define mpn_mod_1 __MPN(mod_1)1528__GMP_DECLSPEC mp_limb_t mpn_mod_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;15291530#define mpn_mul __MPN(mul)1531__GMP_DECLSPEC mp_limb_t mpn_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);15321533#define mpn_mul_1 __MPN(mul_1)1534__GMP_DECLSPEC mp_limb_t mpn_mul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);15351536#define mpn_mul_n __MPN(mul_n)1537__GMP_DECLSPEC void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);15381539#define mpn_sqr __MPN(sqr)1540__GMP_DECLSPEC void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t);15411542#define mpn_neg __MPN(neg)1543#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_neg)1544__GMP_DECLSPEC mp_limb_t mpn_neg (mp_ptr, mp_srcptr, mp_size_t);1545#endif15461547#define mpn_com __MPN(com)1548#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_com)1549__GMP_DECLSPEC void mpn_com (mp_ptr, mp_srcptr, mp_size_t);1550#endif15511552#define mpn_perfect_square_p __MPN(perfect_square_p)1553__GMP_DECLSPEC int mpn_perfect_square_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE;15541555#define mpn_perfect_power_p __MPN(perfect_power_p)1556__GMP_DECLSPEC int mpn_perfect_power_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE;15571558#define mpn_popcount __MPN(popcount)1559__GMP_DECLSPEC mp_bitcnt_t mpn_popcount (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;15601561#define mpn_pow_1 __MPN(pow_1)1562__GMP_DECLSPEC mp_size_t mpn_pow_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);15631564/* undocumented now, but retained here for upward compatibility */1565#define mpn_preinv_mod_1 __MPN(preinv_mod_1)1566__GMP_DECLSPEC mp_limb_t mpn_preinv_mod_1 (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;15671568#define mpn_random __MPN(random)1569__GMP_DECLSPEC void mpn_random (mp_ptr, mp_size_t);15701571#define mpn_random2 __MPN(random2)1572__GMP_DECLSPEC void mpn_random2 (mp_ptr, mp_size_t);15731574#define mpn_rshift __MPN(rshift)1575__GMP_DECLSPEC mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);15761577#define mpn_scan0 __MPN(scan0)1578__GMP_DECLSPEC mp_bitcnt_t mpn_scan0 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;15791580#define mpn_scan1 __MPN(scan1)1581__GMP_DECLSPEC mp_bitcnt_t mpn_scan1 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;15821583#define mpn_set_str __MPN(set_str)1584__GMP_DECLSPEC mp_size_t mpn_set_str (mp_ptr, const unsigned char *, size_t, int);15851586#define mpn_sizeinbase __MPN(sizeinbase)1587__GMP_DECLSPEC size_t mpn_sizeinbase (mp_srcptr, mp_size_t, int);15881589#define mpn_sqrtrem __MPN(sqrtrem)1590__GMP_DECLSPEC mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t);15911592#define mpn_sub __MPN(sub)1593#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub)1594__GMP_DECLSPEC mp_limb_t mpn_sub (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);1595#endif15961597#define mpn_sub_1 __MPN(sub_1)1598#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1)1599__GMP_DECLSPEC mp_limb_t mpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW;1600#endif16011602#define mpn_sub_n __MPN(sub_n)1603__GMP_DECLSPEC mp_limb_t mpn_sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);16041605#define mpn_submul_1 __MPN(submul_1)1606__GMP_DECLSPEC mp_limb_t mpn_submul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);16071608#define mpn_tdiv_qr __MPN(tdiv_qr)1609__GMP_DECLSPEC void mpn_tdiv_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);16101611#define mpn_and_n __MPN(and_n)1612__GMP_DECLSPEC void mpn_and_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);1613#define mpn_andn_n __MPN(andn_n)1614__GMP_DECLSPEC void mpn_andn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);1615#define mpn_nand_n __MPN(nand_n)1616__GMP_DECLSPEC void mpn_nand_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);1617#define mpn_ior_n __MPN(ior_n)1618__GMP_DECLSPEC void mpn_ior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);1619#define mpn_iorn_n __MPN(iorn_n)1620__GMP_DECLSPEC void mpn_iorn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);1621#define mpn_nior_n __MPN(nior_n)1622__GMP_DECLSPEC void mpn_nior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);1623#define mpn_xor_n __MPN(xor_n)1624__GMP_DECLSPEC void mpn_xor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);1625#define mpn_xnor_n __MPN(xnor_n)1626__GMP_DECLSPEC void mpn_xnor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);16271628#define mpn_copyi __MPN(copyi)1629__GMP_DECLSPEC void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t);1630#define mpn_copyd __MPN(copyd)1631__GMP_DECLSPEC void mpn_copyd (mp_ptr, mp_srcptr, mp_size_t);1632#define mpn_zero __MPN(zero)1633__GMP_DECLSPEC void mpn_zero (mp_ptr, mp_size_t);16341635#define mpn_cnd_add_n __MPN(cnd_add_n)1636__GMP_DECLSPEC mp_limb_t mpn_cnd_add_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);1637#define mpn_cnd_sub_n __MPN(cnd_sub_n)1638__GMP_DECLSPEC mp_limb_t mpn_cnd_sub_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);16391640#define mpn_sec_add_1 __MPN(sec_add_1)1641__GMP_DECLSPEC mp_limb_t mpn_sec_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);1642#define mpn_sec_add_1_itch __MPN(sec_add_1_itch)1643__GMP_DECLSPEC mp_size_t mpn_sec_add_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;16441645#define mpn_sec_sub_1 __MPN(sec_sub_1)1646__GMP_DECLSPEC mp_limb_t mpn_sec_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);1647#define mpn_sec_sub_1_itch __MPN(sec_sub_1_itch)1648__GMP_DECLSPEC mp_size_t mpn_sec_sub_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;16491650#define mpn_sec_mul __MPN(sec_mul)1651__GMP_DECLSPEC void mpn_sec_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);1652#define mpn_sec_mul_itch __MPN(sec_mul_itch)1653__GMP_DECLSPEC mp_size_t mpn_sec_mul_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;16541655#define mpn_sec_sqr __MPN(sec_sqr)1656__GMP_DECLSPEC void mpn_sec_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr);1657#define mpn_sec_sqr_itch __MPN(sec_sqr_itch)1658__GMP_DECLSPEC mp_size_t mpn_sec_sqr_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;16591660#define mpn_sec_powm __MPN(sec_powm)1661__GMP_DECLSPEC void mpn_sec_powm (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_bitcnt_t, mp_srcptr, mp_size_t, mp_ptr);1662#define mpn_sec_powm_itch __MPN(sec_powm_itch)1663__GMP_DECLSPEC mp_size_t mpn_sec_powm_itch (mp_size_t, mp_bitcnt_t, mp_size_t) __GMP_ATTRIBUTE_PURE;16641665#define mpn_sec_tabselect __MPN(sec_tabselect)1666__GMP_DECLSPEC void mpn_sec_tabselect (volatile mp_limb_t *, volatile const mp_limb_t *, mp_size_t, mp_size_t, mp_size_t);16671668#define mpn_sec_div_qr __MPN(sec_div_qr)1669__GMP_DECLSPEC mp_limb_t mpn_sec_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);1670#define mpn_sec_div_qr_itch __MPN(sec_div_qr_itch)1671__GMP_DECLSPEC mp_size_t mpn_sec_div_qr_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;1672#define mpn_sec_div_r __MPN(sec_div_r)1673__GMP_DECLSPEC void mpn_sec_div_r (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);1674#define mpn_sec_div_r_itch __MPN(sec_div_r_itch)1675__GMP_DECLSPEC mp_size_t mpn_sec_div_r_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;16761677#define mpn_sec_invert __MPN(sec_invert)1678__GMP_DECLSPEC int mpn_sec_invert (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_bitcnt_t, mp_ptr);1679#define mpn_sec_invert_itch __MPN(sec_invert_itch)1680__GMP_DECLSPEC mp_size_t mpn_sec_invert_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;168116821683/**************** mpz inlines ****************/16841685/* The following are provided as inlines where possible, but always exist as1686library functions too, for binary compatibility.16871688Within gmp itself this inlining generally isn't relied on, since it1689doesn't get done for all compilers, whereas if something is worth1690inlining then it's worth arranging always.16911692There are two styles of inlining here. When the same bit of code is1693wanted for the inline as for the library version, then __GMP_FORCE_foo1694arranges for that code to be emitted and the __GMP_EXTERN_INLINE1695directive suppressed, eg. mpz_fits_uint_p. When a different bit of code1696is wanted for the inline than for the library version, then1697__GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs. */16981699#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs)1700__GMP_EXTERN_INLINE void1701mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)1702{1703if (__gmp_w != __gmp_u)1704mpz_set (__gmp_w, __gmp_u);1705__gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size);1706}1707#endif17081709#if GMP_NAIL_BITS == 01710#define __GMPZ_FITS_UTYPE_P(z,maxval) \1711mp_size_t __gmp_n = z->_mp_size; \1712mp_ptr __gmp_p = z->_mp_d; \1713return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval));1714#else1715#define __GMPZ_FITS_UTYPE_P(z,maxval) \1716mp_size_t __gmp_n = z->_mp_size; \1717mp_ptr __gmp_p = z->_mp_d; \1718return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval) \1719|| (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS)));1720#endif17211722#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p)1723#if ! defined (__GMP_FORCE_mpz_fits_uint_p)1724__GMP_EXTERN_INLINE1725#endif1726int1727mpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW1728{1729__GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_UINT_MAX);1730}1731#endif17321733#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p)1734#if ! defined (__GMP_FORCE_mpz_fits_ulong_p)1735__GMP_EXTERN_INLINE1736#endif1737int1738mpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW1739{1740__GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_ULONG_MAX);1741}1742#endif17431744#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p)1745#if ! defined (__GMP_FORCE_mpz_fits_ushort_p)1746__GMP_EXTERN_INLINE1747#endif1748int1749mpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW1750{1751__GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_USHRT_MAX);1752}1753#endif17541755#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui)1756#if ! defined (__GMP_FORCE_mpz_get_ui)1757__GMP_EXTERN_INLINE1758#endif1759unsigned long1760mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW1761{1762mp_ptr __gmp_p = __gmp_z->_mp_d;1763mp_size_t __gmp_n = __gmp_z->_mp_size;1764mp_limb_t __gmp_l = __gmp_p[0];1765/* This is a "#if" rather than a plain "if" so as to avoid gcc warnings1766about "<< GMP_NUMB_BITS" exceeding the type size, and to avoid Borland1767C++ 6.0 warnings about condition always true for something like1768"__GMP_ULONG_MAX < GMP_NUMB_MASK". */1769#if GMP_NAIL_BITS == 0 || defined (_LONG_LONG_LIMB)1770/* limb==long and no nails, or limb==longlong, one limb is enough */1771return (__gmp_n != 0 ? __gmp_l : 0);1772#else1773/* limb==long and nails, need two limbs when available */1774__gmp_n = __GMP_ABS (__gmp_n);1775if (__gmp_n <= 1)1776return (__gmp_n != 0 ? __gmp_l : 0);1777else1778return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS);1779#endif1780}1781#endif17821783#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn)1784#if ! defined (__GMP_FORCE_mpz_getlimbn)1785__GMP_EXTERN_INLINE1786#endif1787mp_limb_t1788mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW1789{1790mp_limb_t __gmp_result = 0;1791if (__GMP_LIKELY (__gmp_n >= 0 && __gmp_n < __GMP_ABS (__gmp_z->_mp_size)))1792__gmp_result = __gmp_z->_mp_d[__gmp_n];1793return __gmp_result;1794}1795#endif17961797#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg)1798__GMP_EXTERN_INLINE void1799mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)1800{1801if (__gmp_w != __gmp_u)1802mpz_set (__gmp_w, __gmp_u);1803__gmp_w->_mp_size = - __gmp_w->_mp_size;1804}1805#endif18061807#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p)1808#if ! defined (__GMP_FORCE_mpz_perfect_square_p)1809__GMP_EXTERN_INLINE1810#endif1811int1812mpz_perfect_square_p (mpz_srcptr __gmp_a)1813{1814mp_size_t __gmp_asize;1815int __gmp_result;18161817__gmp_asize = __gmp_a->_mp_size;1818__gmp_result = (__gmp_asize >= 0); /* zero is a square, negatives are not */1819if (__GMP_LIKELY (__gmp_asize > 0))1820__gmp_result = mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize);1821return __gmp_result;1822}1823#endif18241825#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount)1826#if ! defined (__GMP_FORCE_mpz_popcount)1827__GMP_EXTERN_INLINE1828#endif1829mp_bitcnt_t1830mpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW1831{1832mp_size_t __gmp_usize;1833mp_bitcnt_t __gmp_result;18341835__gmp_usize = __gmp_u->_mp_size;1836__gmp_result = (__gmp_usize < 0 ? __GMP_ULONG_MAX : 0);1837if (__GMP_LIKELY (__gmp_usize > 0))1838__gmp_result = mpn_popcount (__gmp_u->_mp_d, __gmp_usize);1839return __gmp_result;1840}1841#endif18421843#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q)1844#if ! defined (__GMP_FORCE_mpz_set_q)1845__GMP_EXTERN_INLINE1846#endif1847void1848mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u)1849{1850mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u));1851}1852#endif18531854#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size)1855#if ! defined (__GMP_FORCE_mpz_size)1856__GMP_EXTERN_INLINE1857#endif1858size_t1859mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW1860{1861return __GMP_ABS (__gmp_z->_mp_size);1862}1863#endif186418651866/**************** mpq inlines ****************/18671868#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs)1869__GMP_EXTERN_INLINE void1870mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)1871{1872if (__gmp_w != __gmp_u)1873mpq_set (__gmp_w, __gmp_u);1874__gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size);1875}1876#endif18771878#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg)1879__GMP_EXTERN_INLINE void1880mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)1881{1882if (__gmp_w != __gmp_u)1883mpq_set (__gmp_w, __gmp_u);1884__gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size;1885}1886#endif188718881889/**************** mpn inlines ****************/18901891/* The comments with __GMPN_ADD_1 below apply here too.18921893The test for FUNCTION returning 0 should predict well. If it's assumed1894{yp,ysize} will usually have a random number of bits then the high limb1895won't be full and a carry out will occur a good deal less than 50% of the1896time.18971898ysize==0 isn't a documented feature, but is used internally in a few1899places.19001901Producing cout last stops it using up a register during the main part of1902the calculation, though gcc (as of 3.0) on an "if (mpn_add (...))"1903doesn't seem able to move the true and false legs of the conditional up1904to the two places cout is generated. */19051906#define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST) \1907do { \1908mp_size_t __gmp_i; \1909mp_limb_t __gmp_x; \1910\1911/* ASSERT ((ysize) >= 0); */ \1912/* ASSERT ((xsize) >= (ysize)); */ \1913/* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */ \1914/* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */ \1915\1916__gmp_i = (ysize); \1917if (__gmp_i != 0) \1918{ \1919if (FUNCTION (wp, xp, yp, __gmp_i)) \1920{ \1921do \1922{ \1923if (__gmp_i >= (xsize)) \1924{ \1925(cout) = 1; \1926goto __gmp_done; \1927} \1928__gmp_x = (xp)[__gmp_i]; \1929} \1930while (TEST); \1931} \1932} \1933if ((wp) != (xp)) \1934__GMPN_COPY_REST (wp, xp, xsize, __gmp_i); \1935(cout) = 0; \1936__gmp_done: \1937; \1938} while (0)19391940#define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize) \1941__GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n, \1942(((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0))1943#define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize) \1944__GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n, \1945(((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0))194619471948/* The use of __gmp_i indexing is designed to ensure a compile time src==dst1949remains nice and clear to the compiler, so that __GMPN_COPY_REST can1950disappear, and the load/add/store gets a chance to become a1951read-modify-write on CISC CPUs.19521953Alternatives:19541955Using a pair of pointers instead of indexing would be possible, but gcc1956isn't able to recognise compile-time src==dst in that case, even when the1957pointers are incremented more or less together. Other compilers would1958very likely have similar difficulty.19591960gcc could use "if (__builtin_constant_p(src==dst) && src==dst)" or1961similar to detect a compile-time src==dst. This works nicely on gcc19622.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems1963to be always false, for a pointer p. But the current code form seems1964good enough for src==dst anyway.19651966gcc on x86 as usual doesn't give particularly good flags handling for the1967carry/borrow detection. It's tempting to want some multi instruction asm1968blocks to help it, and this was tried, but in truth there's only a few1969instructions to save and any gain is all too easily lost by register1970juggling setting up for the asm. */19711972#if GMP_NAIL_BITS == 01973#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \1974do { \1975mp_size_t __gmp_i; \1976mp_limb_t __gmp_x, __gmp_r; \1977\1978/* ASSERT ((n) >= 1); */ \1979/* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \1980\1981__gmp_x = (src)[0]; \1982__gmp_r = __gmp_x OP (v); \1983(dst)[0] = __gmp_r; \1984if (CB (__gmp_r, __gmp_x, (v))) \1985{ \1986(cout) = 1; \1987for (__gmp_i = 1; __gmp_i < (n);) \1988{ \1989__gmp_x = (src)[__gmp_i]; \1990__gmp_r = __gmp_x OP 1; \1991(dst)[__gmp_i] = __gmp_r; \1992++__gmp_i; \1993if (!CB (__gmp_r, __gmp_x, 1)) \1994{ \1995if ((src) != (dst)) \1996__GMPN_COPY_REST (dst, src, n, __gmp_i); \1997(cout) = 0; \1998break; \1999} \2000} \2001} \2002else \2003{ \2004if ((src) != (dst)) \2005__GMPN_COPY_REST (dst, src, n, 1); \2006(cout) = 0; \2007} \2008} while (0)2009#endif20102011#if GMP_NAIL_BITS >= 12012#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \2013do { \2014mp_size_t __gmp_i; \2015mp_limb_t __gmp_x, __gmp_r; \2016\2017/* ASSERT ((n) >= 1); */ \2018/* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \2019\2020__gmp_x = (src)[0]; \2021__gmp_r = __gmp_x OP (v); \2022(dst)[0] = __gmp_r & GMP_NUMB_MASK; \2023if (__gmp_r >> GMP_NUMB_BITS != 0) \2024{ \2025(cout) = 1; \2026for (__gmp_i = 1; __gmp_i < (n);) \2027{ \2028__gmp_x = (src)[__gmp_i]; \2029__gmp_r = __gmp_x OP 1; \2030(dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK; \2031++__gmp_i; \2032if (__gmp_r >> GMP_NUMB_BITS == 0) \2033{ \2034if ((src) != (dst)) \2035__GMPN_COPY_REST (dst, src, n, __gmp_i); \2036(cout) = 0; \2037break; \2038} \2039} \2040} \2041else \2042{ \2043if ((src) != (dst)) \2044__GMPN_COPY_REST (dst, src, n, 1); \2045(cout) = 0; \2046} \2047} while (0)2048#endif20492050#define __GMPN_ADDCB(r,x,y) ((r) < (y))2051#define __GMPN_SUBCB(r,x,y) ((x) < (y))20522053#define __GMPN_ADD_1(cout, dst, src, n, v) \2054__GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB)2055#define __GMPN_SUB_1(cout, dst, src, n, v) \2056__GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB)205720582059/* Compare {xp,size} and {yp,size}, setting "result" to positive, zero or2060negative. size==0 is allowed. On random data usually only one limb will2061need to be examined to get a result, so it's worth having it inline. */2062#define __GMPN_CMP(result, xp, yp, size) \2063do { \2064mp_size_t __gmp_i; \2065mp_limb_t __gmp_x, __gmp_y; \2066\2067/* ASSERT ((size) >= 0); */ \2068\2069(result) = 0; \2070__gmp_i = (size); \2071while (--__gmp_i >= 0) \2072{ \2073__gmp_x = (xp)[__gmp_i]; \2074__gmp_y = (yp)[__gmp_i]; \2075if (__gmp_x != __gmp_y) \2076{ \2077/* Cannot use __gmp_x - __gmp_y, may overflow an "int" */ \2078(result) = (__gmp_x > __gmp_y ? 1 : -1); \2079break; \2080} \2081} \2082} while (0)208320842085#if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST)2086#define __GMPN_COPY_REST(dst, src, size, start) \2087do { \2088/* ASSERT ((start) >= 0); */ \2089/* ASSERT ((start) <= (size)); */ \2090__GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \2091} while (0)2092#endif20932094/* Copy {src,size} to {dst,size}, starting at "start". This is designed to2095keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1,2096__GMPN_ADD, etc. */2097#if ! defined (__GMPN_COPY_REST)2098#define __GMPN_COPY_REST(dst, src, size, start) \2099do { \2100mp_size_t __gmp_j; \2101/* ASSERT ((size) >= 0); */ \2102/* ASSERT ((start) >= 0); */ \2103/* ASSERT ((start) <= (size)); */ \2104/* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */ \2105__GMP_CRAY_Pragma ("_CRI ivdep"); \2106for (__gmp_j = (start); __gmp_j < (size); __gmp_j++) \2107(dst)[__gmp_j] = (src)[__gmp_j]; \2108} while (0)2109#endif21102111/* Enhancement: Use some of the smarter code from gmp-impl.h. Maybe use2112mpn_copyi if there's a native version, and if we don't mind demanding2113binary compatibility for it (on targets which use it). */21142115#if ! defined (__GMPN_COPY)2116#define __GMPN_COPY(dst, src, size) __GMPN_COPY_REST (dst, src, size, 0)2117#endif211821192120#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add)2121#if ! defined (__GMP_FORCE_mpn_add)2122__GMP_EXTERN_INLINE2123#endif2124mp_limb_t2125mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)2126{2127mp_limb_t __gmp_c;2128__GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);2129return __gmp_c;2130}2131#endif21322133#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1)2134#if ! defined (__GMP_FORCE_mpn_add_1)2135__GMP_EXTERN_INLINE2136#endif2137mp_limb_t2138mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW2139{2140mp_limb_t __gmp_c;2141__GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);2142return __gmp_c;2143}2144#endif21452146#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp)2147#if ! defined (__GMP_FORCE_mpn_cmp)2148__GMP_EXTERN_INLINE2149#endif2150int2151mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW2152{2153int __gmp_result;2154__GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size);2155return __gmp_result;2156}2157#endif21582159#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub)2160#if ! defined (__GMP_FORCE_mpn_sub)2161__GMP_EXTERN_INLINE2162#endif2163mp_limb_t2164mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)2165{2166mp_limb_t __gmp_c;2167__GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);2168return __gmp_c;2169}2170#endif21712172#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1)2173#if ! defined (__GMP_FORCE_mpn_sub_1)2174__GMP_EXTERN_INLINE2175#endif2176mp_limb_t2177mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW2178{2179mp_limb_t __gmp_c;2180__GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);2181return __gmp_c;2182}2183#endif21842185#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_neg)2186#if ! defined (__GMP_FORCE_mpn_neg)2187__GMP_EXTERN_INLINE2188#endif2189mp_limb_t2190mpn_neg (mp_ptr __gmp_rp, mp_srcptr __gmp_up, mp_size_t __gmp_n)2191{2192mp_limb_t __gmp_ul, __gmp_cy;2193__gmp_cy = 0;2194do {2195__gmp_ul = *__gmp_up++;2196*__gmp_rp++ = -__gmp_ul - __gmp_cy;2197__gmp_cy |= __gmp_ul != 0;2198} while (--__gmp_n != 0);2199return __gmp_cy;2200}2201#endif22022203#if defined (__cplusplus)2204}2205#endif220622072208/* Allow faster testing for negative, zero, and positive. */2209#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)2210#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)2211#define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0)22122213/* When using GCC, optimize certain common comparisons. */2214#if defined (__GNUC__) && __GNUC__ >= 22215#define mpz_cmp_ui(Z,UI) \2216(__builtin_constant_p (UI) && (UI) == 0 \2217? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))2218#define mpz_cmp_si(Z,SI) \2219(__builtin_constant_p ((SI) >= 0) && (SI) >= 0 \2220? mpz_cmp_ui (Z, __GMP_CAST (unsigned long, SI)) \2221: _mpz_cmp_si (Z,SI))2222#define mpq_cmp_ui(Q,NUI,DUI) \2223(__builtin_constant_p (NUI) && (NUI) == 0 ? mpq_sgn (Q) \2224: __builtin_constant_p ((NUI) == (DUI)) && (NUI) == (DUI) \2225? mpz_cmp (mpq_numref (Q), mpq_denref (Q)) \2226: _mpq_cmp_ui (Q,NUI,DUI))2227#define mpq_cmp_si(q,n,d) \2228(__builtin_constant_p ((n) >= 0) && (n) >= 0 \2229? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d) \2230: _mpq_cmp_si (q, n, d))2231#else2232#define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI)2233#define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI)2234#define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI)2235#define mpq_cmp_si(q,n,d) _mpq_cmp_si(q,n,d)2236#endif223722382239/* Using "&" rather than "&&" means these can come out branch-free. Every2240mpz_t has at least one limb allocated, so fetching the low limb is always2241allowed. */2242#define mpz_odd_p(z) (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0]))2243#define mpz_even_p(z) (! mpz_odd_p (z))224422452246/**************** C++ routines ****************/22472248#ifdef __cplusplus2249__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr);2250__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr);2251__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr);2252__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr);2253__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr);2254__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr);2255#endif225622572258/* Source-level compatibility with GMP 2 and earlier. */2259#define mpn_divmod(qp,np,nsize,dp,dsize) \2260mpn_divrem (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dp, dsize)22612262/* Source-level compatibility with GMP 1. */2263#define mpz_mdiv mpz_fdiv_q2264#define mpz_mdivmod mpz_fdiv_qr2265#define mpz_mmod mpz_fdiv_r2266#define mpz_mdiv_ui mpz_fdiv_q_ui2267#define mpz_mdivmod_ui(q,r,n,d) \2268(((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d))2269#define mpz_mmod_ui(r,n,d) \2270(((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d))22712272/* Useful synonyms, but not quite compatible with GMP 1. */2273#define mpz_div mpz_fdiv_q2274#define mpz_divmod mpz_fdiv_qr2275#define mpz_div_ui mpz_fdiv_q_ui2276#define mpz_divmod_ui mpz_fdiv_qr_ui2277#define mpz_div_2exp mpz_fdiv_q_2exp2278#define mpz_mod_2exp mpz_fdiv_r_2exp22792280enum2281{2282GMP_ERROR_NONE = 0,2283GMP_ERROR_UNSUPPORTED_ARGUMENT = 1,2284GMP_ERROR_DIVISION_BY_ZERO = 2,2285GMP_ERROR_SQRT_OF_NEGATIVE = 4,2286GMP_ERROR_INVALID_ARGUMENT = 82287};22882289/* Define CC and CFLAGS which were used to build this version of GMP */2290#define __GMP_CC "gcc"2291#define __GMP_CFLAGS "-Wall -g -O2 -g -O2 "22922293/* Major version number is the value of __GNU_MP__ too, above and in mp.h. */2294#define __GNU_MP_VERSION 62295#define __GNU_MP_VERSION_MINOR 02296#define __GNU_MP_VERSION_PATCHLEVEL 02297#define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL)22982299#define __GMP_H__2300#endif /* __GMP_H__ */230123022303