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, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,32004, 2005, 2006 Free Software Foundation, Inc.45This file is part of the GNU MP Library.67The GNU MP Library is free software; you can redistribute it and/or modify8it under the terms of the GNU Lesser General Public License as published by9the Free Software Foundation; either version 2.1 of the License, or (at your10option) any later version.1112The GNU MP Library is distributed in the hope that it will be useful, but13WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY14or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public15License for more details.1617You should have received a copy of the GNU Lesser General Public License18along with the GNU MP Library; see the file COPYING.LIB. If not, write to19the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,20MA 02110-1301, USA. */2122#ifndef __GMP_H__2324#if defined (__cplusplus)25#include <iosfwd> /* for std::istream, std::ostream, std::string */26#endif272829/* Instantiated by configure. */30#if ! defined (__GMP_WITHIN_CONFIGURE)31#define __GMP_BITS_PER_MP_LIMB 6432#define __GMP_HAVE_HOST_CPU_FAMILY_power 033#define __GMP_HAVE_HOST_CPU_FAMILY_powerpc 034#define GMP_LIMB_BITS 6435#define GMP_NAIL_BITS 036#endif37#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_MASK40#define GMP_NAIL_MASK (~ GMP_NUMB_MASK)414243/* The following (everything under ifndef __GNU_MP__) must be identical in44gmp.h and mp.h to allow both to be included in an application or during45the library build. */46#ifndef __GNU_MP__47#define __GNU_MP__ 44849#define __need_size_t /* tell gcc stddef.h we only want size_t */50#if defined (__cplusplus)51#include <cstddef> /* for size_t */52#else53#include <stddef.h> /* for size_t */54#endif55#undef __need_size_t5657/* Instantiated by configure. */58#if ! defined (__GMP_WITHIN_CONFIGURE)59/* #undef _LONG_LONG_LIMB */60#define __GMP_LIBGMP_DLL 061#endif626364/* __STDC__ - some ANSI compilers define this only to 0, hence the use of65"defined" and not "__STDC__-0". In particular Sun workshop C 5.066sets __STDC__ to 0, but requires "##" for token pasting.6768_AIX - gnu ansidecl.h asserts that all known AIX compilers are ANSI but69don't always define __STDC__.7071__DECC - current versions of DEC C (5.9 for instance) for alpha are ANSI,72but don't define __STDC__ in their default mode. Don't know if old73versions might have been K&R, but let's not worry about that unless74someone is still using one.7576_mips - gnu ansidecl.h says the RISC/OS MIPS compiler is ANSI in SVR477mode, but doesn't define __STDC__.7879_MSC_VER - Microsoft C is ANSI, but __STDC__ is undefined unless the /Za80option is given (in which case it's 1).8182_WIN32 - tested for by gnu ansidecl.h, no doubt on the assumption that83all w32 compilers are ansi.8485Note: This same set of tests is used by gen-psqr.c and86demos/expr/expr-impl.h, so if anything needs adding, then be sure to87update those too. */8889#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 197#define __GMP_HAVE_PROTOTYPES 198#define __GMP_HAVE_TOKEN_PASTE 199#else100#define __GMP_HAVE_CONST 0101#define __GMP_HAVE_PROTOTYPES 0102#define __GMP_HAVE_TOKEN_PASTE 0103#endif104105106#if __GMP_HAVE_CONST107#define __gmp_const const108#define __gmp_signed signed109#else110#define __gmp_const111#define __gmp_signed112#endif113114115/* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in116all other circumstances.117118When compiling objects for libgmp, __GMP_DECLSPEC is an export directive,119or when compiling for an application it's an import directive. The two120cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles121(and not defined from an application).122123__GMP_DECLSPEC_XX is similarly used for libgmpxx. __GMP_WITHIN_GMPXX124indicates when building libgmpxx, and in that case libgmpxx functions are125exports, but libgmp functions which might get called are imports.126127libmp.la uses __GMP_DECLSPEC, just as if it were libgmp.la. libgmp and128libmp don't call each other, so there's no conflict or confusion.129130Libtool DLL_EXPORT define is not used.131132There's no attempt to support GMP built both static and DLL. Doing so133would mean applications would have to tell us which of the two is going134to be used when linking, and that seems very tedious and error prone if135using GMP by hand, and equally tedious from a package since autoconf and136automake don't give much help.137138__GMP_DECLSPEC is required on all documented global functions and139variables, the various internals in gmp-impl.h etc can be left unadorned.140But internals used by the test programs or speed measuring programs141should have __GMP_DECLSPEC, and certainly constants or variables must142have it or the wrong address will be resolved.143144In gcc __declspec can go at either the start or end of a prototype.145146In Microsoft C __declspec must go at the start, or after the type like147void __declspec(...) *foo()". There's no __dllexport or anything to148guard against someone foolish #defining dllexport. _export used to be149available, but no longer.150151In Borland C _export still exists, but needs to go after the type, like152"void _export foo();". Would have to change the __GMP_DECLSPEC syntax to153make use of that. Probably more trouble than it's worth. */154155#if defined (__GNUC__)156#define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__)157#define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__)158#endif159#if defined (_MSC_VER) || defined (__BORLANDC__)160#define __GMP_DECLSPEC_EXPORT __declspec(dllexport)161#define __GMP_DECLSPEC_IMPORT __declspec(dllimport)162#endif163#ifdef __WATCOMC__164#define __GMP_DECLSPEC_EXPORT __export165#define __GMP_DECLSPEC_IMPORT __import166#endif167#ifdef __IBMC__168#define __GMP_DECLSPEC_EXPORT _Export169#define __GMP_DECLSPEC_IMPORT _Import170#endif171172#if __GMP_LIBGMP_DLL173#if __GMP_WITHIN_GMP174/* compiling to go into a DLL libgmp */175#define __GMP_DECLSPEC __GMP_DECLSPEC_EXPORT176#else177/* compiling to go into an application which will link to a DLL libgmp */178#define __GMP_DECLSPEC __GMP_DECLSPEC_IMPORT179#endif180#else181/* all other cases */182#define __GMP_DECLSPEC183#endif184185186#ifdef __GMP_SHORT_LIMB187typedef unsigned int mp_limb_t;188typedef int mp_limb_signed_t;189#else190#ifdef _LONG_LONG_LIMB191typedef unsigned long long int mp_limb_t;192typedef long long int mp_limb_signed_t;193#else194typedef unsigned long int mp_limb_t;195typedef long int mp_limb_signed_t;196#endif197#endif198199/* For reference, note that the name __mpz_struct gets into C++ mangled200function names, which means although the "__" suggests an internal, we201must leave this name for binary compatibility. */202typedef struct203{204int _mp_alloc; /* Number of *limbs* allocated and pointed205to by the _mp_d field. */206int _mp_size; /* abs(_mp_size) is the number of limbs the207last field points to. If _mp_size is208negative this is a negative number. */209mp_limb_t *_mp_d; /* Pointer to the limbs. */210} __mpz_struct;211212#endif /* __GNU_MP__ */213214215typedef __mpz_struct MP_INT; /* gmp 1 source compatibility */216typedef __mpz_struct mpz_t[1];217218typedef mp_limb_t * mp_ptr;219typedef __gmp_const mp_limb_t * mp_srcptr;220#if defined (_CRAY) && ! defined (_CRAYMPP)221/* plain `int' is much faster (48 bits) */222#define __GMP_MP_SIZE_T_INT 1223typedef int mp_size_t;224typedef int mp_exp_t;225#else226#define __GMP_MP_SIZE_T_INT 0227typedef long int mp_size_t;228typedef long int mp_exp_t;229#endif230231typedef struct232{233__mpz_struct _mp_num;234__mpz_struct _mp_den;235} __mpq_struct;236237typedef __mpq_struct MP_RAT; /* gmp 1 source compatibility */238typedef __mpq_struct mpq_t[1];239240typedef struct241{242int _mp_prec; /* Max precision, in number of `mp_limb_t's.243Set by mpf_init and modified by244mpf_set_prec. The area pointed to by the245_mp_d field contains `prec' + 1 limbs. */246int _mp_size; /* abs(_mp_size) is the number of limbs the247last field points to. If _mp_size is248negative this is a negative number. */249mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */250mp_limb_t *_mp_d; /* Pointer to the limbs. */251} __mpf_struct;252253/* typedef __mpf_struct MP_FLOAT; */254typedef __mpf_struct mpf_t[1];255256/* Available random number generation algorithms. */257typedef enum258{259GMP_RAND_ALG_DEFAULT = 0,260GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */261} gmp_randalg_t;262263/* Random state struct. */264typedef struct265{266mpz_t _mp_seed; /* _mp_d member points to state of the generator. */267gmp_randalg_t _mp_alg; /* Currently unused. */268union {269void *_mp_lc; /* Pointer to function pointers structure. */270} _mp_algdata;271} __gmp_randstate_struct;272typedef __gmp_randstate_struct gmp_randstate_t[1];273274/* Types for function declarations in gmp files. */275/* ??? Should not pollute user name space with these ??? */276typedef __gmp_const __mpz_struct *mpz_srcptr;277typedef __mpz_struct *mpz_ptr;278typedef __gmp_const __mpf_struct *mpf_srcptr;279typedef __mpf_struct *mpf_ptr;280typedef __gmp_const __mpq_struct *mpq_srcptr;281typedef __mpq_struct *mpq_ptr;282283284/* This is not wanted in mp.h, so put it outside the __GNU_MP__ common285section. */286#if __GMP_LIBGMP_DLL287#if __GMP_WITHIN_GMPXX288/* compiling to go into a DLL libgmpxx */289#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_EXPORT290#else291/* compiling to go into a application which will link to a DLL libgmpxx */292#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_IMPORT293#endif294#else295/* all other cases */296#define __GMP_DECLSPEC_XX297#endif298299300#if __GMP_HAVE_PROTOTYPES301#define __GMP_PROTO(x) x302#else303#define __GMP_PROTO(x) ()304#endif305306#ifndef __MPN307#if __GMP_HAVE_TOKEN_PASTE308#define __MPN(x) __gmpn_##x309#else310#define __MPN(x) __gmpn_/**/x311#endif312#endif313314/* For reference, "defined(EOF)" cannot be used here. In g++ 2.95.4,315<iostream> defines EOF but not FILE. */316#if defined (FILE) \317|| defined (H_STDIO) \318|| defined (_H_STDIO) /* AIX */ \319|| defined (_STDIO_H) /* glibc, Sun, SCO */ \320|| defined (_STDIO_H_) /* BSD, OSF */ \321|| defined (__STDIO_H) /* Borland */ \322|| defined (__STDIO_H__) /* IRIX */ \323|| defined (_STDIO_INCLUDED) /* HPUX */ \324|| defined (__dj_include_stdio_h_) /* DJGPP */ \325|| defined (_FILE_DEFINED) /* Microsoft */ \326|| defined (__STDIO__) /* Apple MPW MrC */ \327|| defined (_MSL_STDIO_H) /* Metrowerks */ \328|| defined (_STDIO_H_INCLUDED) /* QNX4 */ \329|| defined (_ISO_STDIO_ISO_H) /* Sun C++ */330#define _GMP_H_HAVE_FILE 1331#endif332333/* In ISO C, if a prototype involving "struct obstack *" is given without334that structure defined, then the struct is scoped down to just the335prototype, causing a conflict if it's subsequently defined for real. So336only give prototypes if we've got obstack.h. */337#if defined (_OBSTACK_H) /* glibc <obstack.h> */338#define _GMP_H_HAVE_OBSTACK 1339#endif340341/* The prototypes for gmp_vprintf etc are provided only if va_list is342available, via an application having included <stdarg.h> or <varargs.h>.343Usually va_list is a typedef so can't be tested directly, but C99344specifies that va_start is a macro (and it was normally a macro on past345systems too), so look for that.346347<stdio.h> will define some sort of va_list for vprintf and vfprintf, but348let's not bother trying to use that since it's not standard and since349application uses for gmp_vprintf etc will almost certainly require the350whole <stdarg.h> or <varargs.h> anyway. */351352#ifdef va_start353#define _GMP_H_HAVE_VA_LIST 1354#endif355356/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */357#if defined (__GNUC__) && defined (__GNUC_MINOR__)358#define __GMP_GNUC_PREREQ(maj, min) \359((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))360#else361#define __GMP_GNUC_PREREQ(maj, min) 0362#endif363364/* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes". Basically365it means a function does nothing but examine its arguments and memory366(global or via arguments) to generate a return value, but changes nothing367and has no side-effects. __GMP_NO_ATTRIBUTE_CONST_PURE lets368tune/common.c etc turn this off when trying to write timing loops. */369#if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE)370#define __GMP_ATTRIBUTE_PURE __attribute__ ((__pure__))371#else372#define __GMP_ATTRIBUTE_PURE373#endif374375376/* __GMP_CAST allows us to use static_cast in C++, so our macros are clean377to "g++ -Wold-style-cast".378379Casts in "extern inline" code within an extern "C" block don't induce380these warnings, so __GMP_CAST only needs to be used on documented381macros. */382383#ifdef __cplusplus384#define __GMP_CAST(type, expr) (static_cast<type> (expr))385#else386#define __GMP_CAST(type, expr) ((type) (expr))387#endif388389390/* An empty "throw ()" means the function doesn't throw any C++ exceptions,391this can save some stack frame info in applications.392393Currently it's given only on functions which never divide-by-zero etc,394don't allocate memory, and are expected to never need to allocate memory.395This leaves open the possibility of a C++ throw from a future GMP396exceptions scheme.397398mpz_set_ui etc are omitted to leave open the lazy allocation scheme399described in doc/tasks.html. mpz_get_d etc are omitted to leave open400exceptions for float overflows.401402Note that __GMP_NOTHROW must be given on any inlines the same as on their403prototypes (for g++ at least, where they're used together). Note also404that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like405__GMP_ATTRIBUTE_PURE. */406407#if defined (__cplusplus)408#define __GMP_NOTHROW throw ()409#else410#define __GMP_NOTHROW411#endif412413414/* PORTME: What other compilers have a useful "extern inline"? "static415inline" would be an acceptable substitute if the compiler (or linker)416discards unused statics. */417418/* gcc has __inline__ in all modes, including strict ansi. Give a prototype419for an inline too, so as to correctly specify "dllimport" on windows, in420case the function is called rather than inlined. */421#ifdef __GNUC__422#define __GMP_EXTERN_INLINE extern __inline__423#define __GMP_INLINE_PROTOTYPES 1424#endif425426/* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1427strict ANSI mode. Inlining is done even when not optimizing (ie. -O0428mode, which is the default), but an unnecessary local copy of foo is429emitted unless -O is used. "extern __inline" is accepted, but the430"extern" appears to be ignored, ie. it becomes a plain global function431but which is inlined within its file. Don't know if all old versions of432DEC C supported __inline, but as a start let's do the right thing for433current versions. */434#ifdef __DECC435#define __GMP_EXTERN_INLINE static __inline436#endif437438/* SCO OpenUNIX 8 cc supports "static inline foo()" but not in -Xc strict439ANSI mode (__STDC__ is 1 in that mode). Inlining only actually takes440place under -O. Without -O "foo" seems to be emitted whether it's used441or not, which is wasteful. "extern inline foo()" isn't useful, the442"extern" is apparently ignored, so foo is inlined if possible but also443emitted as a global, which causes multiple definition errors when444building a shared libgmp. */445#ifdef __SCO_VERSION__446#if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \447&& ! defined (__GMP_EXTERN_INLINE)448#define __GMP_EXTERN_INLINE static inline449#endif450#endif451452/* C++ always has "inline" and since it's a normal feature the linker should453discard duplicate non-inlined copies, or if it doesn't then that's a454problem for everyone, not just GMP. */455#if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE)456#define __GMP_EXTERN_INLINE inline457#endif458459/* Don't do any inlining within a configure run, since if the compiler ends460up emitting copies of the code into the object file it can end up461demanding the various support routines (like mpn_popcount) for linking,462making the "alloca" test and perhaps others fail. And on hppa ia64 a463pre-release gcc 3.2 was seen not respecting the "extern" in "extern464__inline__", triggering this problem too. */465#if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE466#undef __GMP_EXTERN_INLINE467#endif468469/* By default, don't give a prototype when there's going to be an inline470version. Note in particular that Cray C++ objects to the combination of471prototype and inline. */472#ifdef __GMP_EXTERN_INLINE473#ifndef __GMP_INLINE_PROTOTYPES474#define __GMP_INLINE_PROTOTYPES 0475#endif476#else477#define __GMP_INLINE_PROTOTYPES 1478#endif479480481#define __GMP_ABS(x) ((x) >= 0 ? (x) : -(x))482#define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i))483484/* __GMP_USHRT_MAX is not "~ (unsigned short) 0" because short is promoted485to int by "~". */486#define __GMP_UINT_MAX (~ (unsigned) 0)487#define __GMP_ULONG_MAX (~ (unsigned long) 0)488#define __GMP_USHRT_MAX ((unsigned short) ~0)489490491/* __builtin_expect is in gcc 3.0, and not in 2.95. */492#if __GMP_GNUC_PREREQ (3,0)493#define __GMP_LIKELY(cond) __builtin_expect ((cond) != 0, 1)494#define __GMP_UNLIKELY(cond) __builtin_expect ((cond) != 0, 0)495#else496#define __GMP_LIKELY(cond) (cond)497#define __GMP_UNLIKELY(cond) (cond)498#endif499500#ifdef _CRAY501#define __GMP_CRAY_Pragma(str) _Pragma (str)502#else503#define __GMP_CRAY_Pragma(str)504#endif505506507/* Allow direct user access to numerator and denominator of a mpq_t object. */508#define mpq_numref(Q) (&((Q)->_mp_num))509#define mpq_denref(Q) (&((Q)->_mp_den))510511512#if defined (__cplusplus)513extern "C" {514using std::FILE;515#endif516517#define mp_set_memory_functions __gmp_set_memory_functions518__GMP_DECLSPEC void mp_set_memory_functions __GMP_PROTO ((void *(*) (size_t),519void *(*) (void *, size_t, size_t),520void (*) (void *, size_t))) __GMP_NOTHROW;521522#define mp_get_memory_functions __gmp_get_memory_functions523__GMP_DECLSPEC void mp_get_memory_functions __GMP_PROTO ((void *(**) (size_t),524void *(**) (void *, size_t, size_t),525void (**) (void *, size_t))) __GMP_NOTHROW;526527#define mp_bits_per_limb __gmp_bits_per_limb528__GMP_DECLSPEC extern __gmp_const int mp_bits_per_limb;529530#define gmp_errno __gmp_errno531__GMP_DECLSPEC extern int gmp_errno;532533#define gmp_version __gmp_version534__GMP_DECLSPEC extern __gmp_const char * __gmp_const gmp_version;535536537/**************** Random number routines. ****************/538539/* obsolete */540#define gmp_randinit __gmp_randinit541__GMP_DECLSPEC void gmp_randinit __GMP_PROTO ((gmp_randstate_t, gmp_randalg_t, ...));542543#define gmp_randinit_default __gmp_randinit_default544__GMP_DECLSPEC void gmp_randinit_default __GMP_PROTO ((gmp_randstate_t));545546#define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp547__GMP_DECLSPEC void gmp_randinit_lc_2exp __GMP_PROTO ((gmp_randstate_t,548mpz_srcptr, unsigned long int,549unsigned long int));550551#define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size552__GMP_DECLSPEC int gmp_randinit_lc_2exp_size __GMP_PROTO ((gmp_randstate_t, unsigned long));553554#define gmp_randinit_mt __gmp_randinit_mt555__GMP_DECLSPEC void gmp_randinit_mt __GMP_PROTO ((gmp_randstate_t));556557#define gmp_randinit_set __gmp_randinit_set558void gmp_randinit_set __GMP_PROTO ((gmp_randstate_t, __gmp_const __gmp_randstate_struct *));559560#define gmp_randseed __gmp_randseed561__GMP_DECLSPEC void gmp_randseed __GMP_PROTO ((gmp_randstate_t, mpz_srcptr));562563#define gmp_randseed_ui __gmp_randseed_ui564__GMP_DECLSPEC void gmp_randseed_ui __GMP_PROTO ((gmp_randstate_t, unsigned long int));565566#define gmp_randclear __gmp_randclear567__GMP_DECLSPEC void gmp_randclear __GMP_PROTO ((gmp_randstate_t));568569#define gmp_urandomb_ui __gmp_urandomb_ui570unsigned long gmp_urandomb_ui __GMP_PROTO ((gmp_randstate_t, unsigned long));571572#define gmp_urandomm_ui __gmp_urandomm_ui573unsigned long gmp_urandomm_ui __GMP_PROTO ((gmp_randstate_t, unsigned long));574575576/**************** Formatted output routines. ****************/577578#define gmp_asprintf __gmp_asprintf579__GMP_DECLSPEC int gmp_asprintf __GMP_PROTO ((char **, __gmp_const char *, ...));580581#define gmp_fprintf __gmp_fprintf582#ifdef _GMP_H_HAVE_FILE583__GMP_DECLSPEC int gmp_fprintf __GMP_PROTO ((FILE *, __gmp_const char *, ...));584#endif585586#define gmp_obstack_printf __gmp_obstack_printf587#if defined (_GMP_H_HAVE_OBSTACK)588__GMP_DECLSPEC int gmp_obstack_printf __GMP_PROTO ((struct obstack *, __gmp_const char *, ...));589#endif590591#define gmp_obstack_vprintf __gmp_obstack_vprintf592#if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST)593__GMP_DECLSPEC int gmp_obstack_vprintf __GMP_PROTO ((struct obstack *, __gmp_const char *, va_list));594#endif595596#define gmp_printf __gmp_printf597__GMP_DECLSPEC int gmp_printf __GMP_PROTO ((__gmp_const char *, ...));598599#define gmp_snprintf __gmp_snprintf600__GMP_DECLSPEC int gmp_snprintf __GMP_PROTO ((char *, size_t, __gmp_const char *, ...));601602#define gmp_sprintf __gmp_sprintf603__GMP_DECLSPEC int gmp_sprintf __GMP_PROTO ((char *, __gmp_const char *, ...));604605#define gmp_vasprintf __gmp_vasprintf606#if defined (_GMP_H_HAVE_VA_LIST)607__GMP_DECLSPEC int gmp_vasprintf __GMP_PROTO ((char **, __gmp_const char *, va_list));608#endif609610#define gmp_vfprintf __gmp_vfprintf611#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)612__GMP_DECLSPEC int gmp_vfprintf __GMP_PROTO ((FILE *, __gmp_const char *, va_list));613#endif614615#define gmp_vprintf __gmp_vprintf616#if defined (_GMP_H_HAVE_VA_LIST)617__GMP_DECLSPEC int gmp_vprintf __GMP_PROTO ((__gmp_const char *, va_list));618#endif619620#define gmp_vsnprintf __gmp_vsnprintf621#if defined (_GMP_H_HAVE_VA_LIST)622__GMP_DECLSPEC int gmp_vsnprintf __GMP_PROTO ((char *, size_t, __gmp_const char *, va_list));623#endif624625#define gmp_vsprintf __gmp_vsprintf626#if defined (_GMP_H_HAVE_VA_LIST)627__GMP_DECLSPEC int gmp_vsprintf __GMP_PROTO ((char *, __gmp_const char *, va_list));628#endif629630631/**************** Formatted input routines. ****************/632633#define gmp_fscanf __gmp_fscanf634#ifdef _GMP_H_HAVE_FILE635__GMP_DECLSPEC int gmp_fscanf __GMP_PROTO ((FILE *, __gmp_const char *, ...));636#endif637638#define gmp_scanf __gmp_scanf639__GMP_DECLSPEC int gmp_scanf __GMP_PROTO ((__gmp_const char *, ...));640641#define gmp_sscanf __gmp_sscanf642__GMP_DECLSPEC int gmp_sscanf __GMP_PROTO ((__gmp_const char *, __gmp_const char *, ...));643644#define gmp_vfscanf __gmp_vfscanf645#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)646__GMP_DECLSPEC int gmp_vfscanf __GMP_PROTO ((FILE *, __gmp_const char *, va_list));647#endif648649#define gmp_vscanf __gmp_vscanf650#if defined (_GMP_H_HAVE_VA_LIST)651__GMP_DECLSPEC int gmp_vscanf __GMP_PROTO ((__gmp_const char *, va_list));652#endif653654#define gmp_vsscanf __gmp_vsscanf655#if defined (_GMP_H_HAVE_VA_LIST)656__GMP_DECLSPEC int gmp_vsscanf __GMP_PROTO ((__gmp_const char *, __gmp_const char *, va_list));657#endif658659660/**************** Integer (i.e. Z) routines. ****************/661662#define _mpz_realloc __gmpz_realloc663#define mpz_realloc __gmpz_realloc664__GMP_DECLSPEC void *_mpz_realloc __GMP_PROTO ((mpz_ptr, mp_size_t));665666#define mpz_abs __gmpz_abs667#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs)668__GMP_DECLSPEC void mpz_abs __GMP_PROTO ((mpz_ptr, mpz_srcptr));669#endif670671#define mpz_add __gmpz_add672__GMP_DECLSPEC void mpz_add __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));673674#define mpz_add_ui __gmpz_add_ui675__GMP_DECLSPEC void mpz_add_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));676677#define mpz_addmul __gmpz_addmul678__GMP_DECLSPEC void mpz_addmul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));679680#define mpz_addmul_ui __gmpz_addmul_ui681__GMP_DECLSPEC void mpz_addmul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));682683#define mpz_and __gmpz_and684__GMP_DECLSPEC void mpz_and __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));685686#define mpz_array_init __gmpz_array_init687__GMP_DECLSPEC void mpz_array_init __GMP_PROTO ((mpz_ptr, mp_size_t, mp_size_t));688689#define mpz_bin_ui __gmpz_bin_ui690__GMP_DECLSPEC void mpz_bin_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));691692#define mpz_bin_uiui __gmpz_bin_uiui693__GMP_DECLSPEC void mpz_bin_uiui __GMP_PROTO ((mpz_ptr, unsigned long int, unsigned long int));694695#define mpz_cdiv_q __gmpz_cdiv_q696__GMP_DECLSPEC void mpz_cdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));697698#define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp699__GMP_DECLSPEC void mpz_cdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));700701#define mpz_cdiv_q_ui __gmpz_cdiv_q_ui702__GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));703704#define mpz_cdiv_qr __gmpz_cdiv_qr705__GMP_DECLSPEC void mpz_cdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));706707#define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui708__GMP_DECLSPEC unsigned long int mpz_cdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));709710#define mpz_cdiv_r __gmpz_cdiv_r711__GMP_DECLSPEC void mpz_cdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));712713#define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp714__GMP_DECLSPEC void mpz_cdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));715716#define mpz_cdiv_r_ui __gmpz_cdiv_r_ui717__GMP_DECLSPEC unsigned long int mpz_cdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));718719#define mpz_cdiv_ui __gmpz_cdiv_ui720__GMP_DECLSPEC unsigned long int mpz_cdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;721722#define mpz_clear __gmpz_clear723__GMP_DECLSPEC void mpz_clear __GMP_PROTO ((mpz_ptr));724725#define mpz_clrbit __gmpz_clrbit726__GMP_DECLSPEC void mpz_clrbit __GMP_PROTO ((mpz_ptr, unsigned long int));727728#define mpz_cmp __gmpz_cmp729__GMP_DECLSPEC int mpz_cmp __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;730731#define mpz_cmp_d __gmpz_cmp_d732__GMP_DECLSPEC int mpz_cmp_d __GMP_PROTO ((mpz_srcptr, double)) __GMP_ATTRIBUTE_PURE;733734#define _mpz_cmp_si __gmpz_cmp_si735__GMP_DECLSPEC int _mpz_cmp_si __GMP_PROTO ((mpz_srcptr, signed long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;736737#define _mpz_cmp_ui __gmpz_cmp_ui738__GMP_DECLSPEC int _mpz_cmp_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;739740#define mpz_cmpabs __gmpz_cmpabs741__GMP_DECLSPEC int mpz_cmpabs __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;742743#define mpz_cmpabs_d __gmpz_cmpabs_d744__GMP_DECLSPEC int mpz_cmpabs_d __GMP_PROTO ((mpz_srcptr, double)) __GMP_ATTRIBUTE_PURE;745746#define mpz_cmpabs_ui __gmpz_cmpabs_ui747__GMP_DECLSPEC int mpz_cmpabs_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;748749#define mpz_com __gmpz_com750__GMP_DECLSPEC void mpz_com __GMP_PROTO ((mpz_ptr, mpz_srcptr));751752#define mpz_combit __gmpz_combit753__GMP_DECLSPEC void mpz_combit __GMP_PROTO ((mpz_ptr, unsigned long int));754755#define mpz_congruent_p __gmpz_congruent_p756__GMP_DECLSPEC int mpz_congruent_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;757758#define mpz_congruent_2exp_p __gmpz_congruent_2exp_p759__GMP_DECLSPEC int mpz_congruent_2exp_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr, unsigned long)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;760761#define mpz_congruent_ui_p __gmpz_congruent_ui_p762__GMP_DECLSPEC int mpz_congruent_ui_p __GMP_PROTO ((mpz_srcptr, unsigned long, unsigned long)) __GMP_ATTRIBUTE_PURE;763764#define mpz_divexact __gmpz_divexact765__GMP_DECLSPEC void mpz_divexact __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));766767#define mpz_divexact_ui __gmpz_divexact_ui768__GMP_DECLSPEC void mpz_divexact_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));769770#define mpz_divisible_p __gmpz_divisible_p771__GMP_DECLSPEC int mpz_divisible_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;772773#define mpz_divisible_ui_p __gmpz_divisible_ui_p774__GMP_DECLSPEC int mpz_divisible_ui_p __GMP_PROTO ((mpz_srcptr, unsigned long)) __GMP_ATTRIBUTE_PURE;775776#define mpz_divisible_2exp_p __gmpz_divisible_2exp_p777__GMP_DECLSPEC int mpz_divisible_2exp_p __GMP_PROTO ((mpz_srcptr, unsigned long)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;778779#define mpz_dump __gmpz_dump780__GMP_DECLSPEC void mpz_dump __GMP_PROTO ((mpz_srcptr));781782#define mpz_export __gmpz_export783__GMP_DECLSPEC void *mpz_export __GMP_PROTO ((void *, size_t *, int, size_t, int, size_t, mpz_srcptr));784785#define mpz_fac_ui __gmpz_fac_ui786__GMP_DECLSPEC void mpz_fac_ui __GMP_PROTO ((mpz_ptr, unsigned long int));787788#define mpz_fdiv_q __gmpz_fdiv_q789__GMP_DECLSPEC void mpz_fdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));790791#define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp792__GMP_DECLSPEC void mpz_fdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));793794#define mpz_fdiv_q_ui __gmpz_fdiv_q_ui795__GMP_DECLSPEC unsigned long int mpz_fdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));796797#define mpz_fdiv_qr __gmpz_fdiv_qr798__GMP_DECLSPEC void mpz_fdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));799800#define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui801__GMP_DECLSPEC unsigned long int mpz_fdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));802803#define mpz_fdiv_r __gmpz_fdiv_r804__GMP_DECLSPEC void mpz_fdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));805806#define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp807__GMP_DECLSPEC void mpz_fdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));808809#define mpz_fdiv_r_ui __gmpz_fdiv_r_ui810__GMP_DECLSPEC unsigned long int mpz_fdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));811812#define mpz_fdiv_ui __gmpz_fdiv_ui813__GMP_DECLSPEC unsigned long int mpz_fdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;814815#define mpz_fib_ui __gmpz_fib_ui816__GMP_DECLSPEC void mpz_fib_ui __GMP_PROTO ((mpz_ptr, unsigned long int));817818#define mpz_fib2_ui __gmpz_fib2_ui819__GMP_DECLSPEC void mpz_fib2_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, unsigned long int));820821#define mpz_fits_sint_p __gmpz_fits_sint_p822__GMP_DECLSPEC int mpz_fits_sint_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;823824#define mpz_fits_slong_p __gmpz_fits_slong_p825__GMP_DECLSPEC int mpz_fits_slong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;826827#define mpz_fits_sshort_p __gmpz_fits_sshort_p828__GMP_DECLSPEC int mpz_fits_sshort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;829830#define mpz_fits_uint_p __gmpz_fits_uint_p831#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p)832__GMP_DECLSPEC int mpz_fits_uint_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;833#endif834835#define mpz_fits_ulong_p __gmpz_fits_ulong_p836#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p)837__GMP_DECLSPEC int mpz_fits_ulong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;838#endif839840#define mpz_fits_ushort_p __gmpz_fits_ushort_p841#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p)842__GMP_DECLSPEC int mpz_fits_ushort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;843#endif844845#define mpz_gcd __gmpz_gcd846__GMP_DECLSPEC void mpz_gcd __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));847848#define mpz_gcd_ui __gmpz_gcd_ui849__GMP_DECLSPEC unsigned long int mpz_gcd_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));850851#define mpz_gcdext __gmpz_gcdext852__GMP_DECLSPEC void mpz_gcdext __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));853854#define mpz_get_d __gmpz_get_d855__GMP_DECLSPEC double mpz_get_d __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;856857#define mpz_get_d_2exp __gmpz_get_d_2exp858__GMP_DECLSPEC double mpz_get_d_2exp __GMP_PROTO ((signed long int *, mpz_srcptr));859860#define mpz_get_si __gmpz_get_si861__GMP_DECLSPEC /* signed */ long int mpz_get_si __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;862863#define mpz_get_str __gmpz_get_str864__GMP_DECLSPEC char *mpz_get_str __GMP_PROTO ((char *, int, mpz_srcptr));865866#define mpz_get_ui __gmpz_get_ui867#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui)868__GMP_DECLSPEC unsigned long int mpz_get_ui __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;869#endif870871#define mpz_getlimbn __gmpz_getlimbn872#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn)873__GMP_DECLSPEC mp_limb_t mpz_getlimbn __GMP_PROTO ((mpz_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;874#endif875876#define mpz_hamdist __gmpz_hamdist877__GMP_DECLSPEC unsigned long int mpz_hamdist __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;878879#define mpz_import __gmpz_import880__GMP_DECLSPEC void mpz_import __GMP_PROTO ((mpz_ptr, size_t, int, size_t, int, size_t, __gmp_const void *));881882#define mpz_init __gmpz_init883__GMP_DECLSPEC void mpz_init __GMP_PROTO ((mpz_ptr));884885#define mpz_init2 __gmpz_init2886__GMP_DECLSPEC void mpz_init2 __GMP_PROTO ((mpz_ptr, unsigned long));887888#define mpz_init_set __gmpz_init_set889__GMP_DECLSPEC void mpz_init_set __GMP_PROTO ((mpz_ptr, mpz_srcptr));890891#define mpz_init_set_d __gmpz_init_set_d892__GMP_DECLSPEC void mpz_init_set_d __GMP_PROTO ((mpz_ptr, double));893894#define mpz_init_set_si __gmpz_init_set_si895__GMP_DECLSPEC void mpz_init_set_si __GMP_PROTO ((mpz_ptr, signed long int));896897#define mpz_init_set_str __gmpz_init_set_str898__GMP_DECLSPEC int mpz_init_set_str __GMP_PROTO ((mpz_ptr, __gmp_const char *, int));899900#define mpz_init_set_ui __gmpz_init_set_ui901__GMP_DECLSPEC void mpz_init_set_ui __GMP_PROTO ((mpz_ptr, unsigned long int));902903#define mpz_inp_raw __gmpz_inp_raw904#ifdef _GMP_H_HAVE_FILE905__GMP_DECLSPEC size_t mpz_inp_raw __GMP_PROTO ((mpz_ptr, FILE *));906#endif907908#define mpz_inp_str __gmpz_inp_str909#ifdef _GMP_H_HAVE_FILE910__GMP_DECLSPEC size_t mpz_inp_str __GMP_PROTO ((mpz_ptr, FILE *, int));911#endif912913#define mpz_invert __gmpz_invert914__GMP_DECLSPEC int mpz_invert __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));915916#define mpz_ior __gmpz_ior917__GMP_DECLSPEC void mpz_ior __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));918919#define mpz_jacobi __gmpz_jacobi920__GMP_DECLSPEC int mpz_jacobi __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;921922#define mpz_kronecker mpz_jacobi /* alias */923924#define mpz_kronecker_si __gmpz_kronecker_si925__GMP_DECLSPEC int mpz_kronecker_si __GMP_PROTO ((mpz_srcptr, long)) __GMP_ATTRIBUTE_PURE;926927#define mpz_kronecker_ui __gmpz_kronecker_ui928__GMP_DECLSPEC int mpz_kronecker_ui __GMP_PROTO ((mpz_srcptr, unsigned long)) __GMP_ATTRIBUTE_PURE;929930#define mpz_si_kronecker __gmpz_si_kronecker931__GMP_DECLSPEC int mpz_si_kronecker __GMP_PROTO ((long, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;932933#define mpz_ui_kronecker __gmpz_ui_kronecker934__GMP_DECLSPEC int mpz_ui_kronecker __GMP_PROTO ((unsigned long, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;935936#define mpz_lcm __gmpz_lcm937__GMP_DECLSPEC void mpz_lcm __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));938939#define mpz_lcm_ui __gmpz_lcm_ui940__GMP_DECLSPEC void mpz_lcm_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));941942#define mpz_legendre mpz_jacobi /* alias */943944#define mpz_lucnum_ui __gmpz_lucnum_ui945__GMP_DECLSPEC void mpz_lucnum_ui __GMP_PROTO ((mpz_ptr, unsigned long int));946947#define mpz_lucnum2_ui __gmpz_lucnum2_ui948__GMP_DECLSPEC void mpz_lucnum2_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, unsigned long int));949950#define mpz_millerrabin __gmpz_millerrabin951__GMP_DECLSPEC int mpz_millerrabin __GMP_PROTO ((mpz_srcptr, int)) __GMP_ATTRIBUTE_PURE;952953#define mpz_mod __gmpz_mod954__GMP_DECLSPEC void mpz_mod __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));955956#define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */957958#define mpz_mul __gmpz_mul959__GMP_DECLSPEC void mpz_mul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));960961#define mpz_mul_2exp __gmpz_mul_2exp962__GMP_DECLSPEC void mpz_mul_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));963964#define mpz_mul_si __gmpz_mul_si965__GMP_DECLSPEC void mpz_mul_si __GMP_PROTO ((mpz_ptr, mpz_srcptr, long int));966967#define mpz_mul_ui __gmpz_mul_ui968__GMP_DECLSPEC void mpz_mul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));969970#define mpz_neg __gmpz_neg971#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg)972__GMP_DECLSPEC void mpz_neg __GMP_PROTO ((mpz_ptr, mpz_srcptr));973#endif974975#define mpz_nextprime __gmpz_nextprime976__GMP_DECLSPEC void mpz_nextprime __GMP_PROTO ((mpz_ptr, mpz_srcptr));977978#define mpz_out_raw __gmpz_out_raw979#ifdef _GMP_H_HAVE_FILE980__GMP_DECLSPEC size_t mpz_out_raw __GMP_PROTO ((FILE *, mpz_srcptr));981#endif982983#define mpz_out_str __gmpz_out_str984#ifdef _GMP_H_HAVE_FILE985__GMP_DECLSPEC size_t mpz_out_str __GMP_PROTO ((FILE *, int, mpz_srcptr));986#endif987988#define mpz_perfect_power_p __gmpz_perfect_power_p989__GMP_DECLSPEC int mpz_perfect_power_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;990991#define mpz_perfect_square_p __gmpz_perfect_square_p992#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p)993__GMP_DECLSPEC int mpz_perfect_square_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;994#endif995996#define mpz_popcount __gmpz_popcount997#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount)998__GMP_DECLSPEC unsigned long int mpz_popcount __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;999#endif10001001#define mpz_pow_ui __gmpz_pow_ui1002__GMP_DECLSPEC void mpz_pow_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));10031004#define mpz_powm __gmpz_powm1005__GMP_DECLSPEC void mpz_powm __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr));10061007#define mpz_powm_ui __gmpz_powm_ui1008__GMP_DECLSPEC void mpz_powm_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr));10091010#define mpz_probab_prime_p __gmpz_probab_prime_p1011__GMP_DECLSPEC int mpz_probab_prime_p __GMP_PROTO ((mpz_srcptr, int)) __GMP_ATTRIBUTE_PURE;10121013#define mpz_random __gmpz_random1014__GMP_DECLSPEC void mpz_random __GMP_PROTO ((mpz_ptr, mp_size_t));10151016#define mpz_random2 __gmpz_random21017__GMP_DECLSPEC void mpz_random2 __GMP_PROTO ((mpz_ptr, mp_size_t));10181019#define mpz_realloc2 __gmpz_realloc21020__GMP_DECLSPEC void mpz_realloc2 __GMP_PROTO ((mpz_ptr, unsigned long));10211022#define mpz_remove __gmpz_remove1023__GMP_DECLSPEC unsigned long int mpz_remove __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));10241025#define mpz_root __gmpz_root1026__GMP_DECLSPEC int mpz_root __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));10271028#define mpz_rootrem __gmpz_rootrem1029__GMP_DECLSPEC void mpz_rootrem __GMP_PROTO ((mpz_ptr,mpz_ptr, mpz_srcptr, unsigned long int));10301031#define mpz_rrandomb __gmpz_rrandomb1032__GMP_DECLSPEC void mpz_rrandomb __GMP_PROTO ((mpz_ptr, gmp_randstate_t, unsigned long int));10331034#define mpz_scan0 __gmpz_scan01035__GMP_DECLSPEC unsigned long int mpz_scan0 __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;10361037#define mpz_scan1 __gmpz_scan11038__GMP_DECLSPEC unsigned long int mpz_scan1 __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;10391040#define mpz_set __gmpz_set1041__GMP_DECLSPEC void mpz_set __GMP_PROTO ((mpz_ptr, mpz_srcptr));10421043#define mpz_set_d __gmpz_set_d1044__GMP_DECLSPEC void mpz_set_d __GMP_PROTO ((mpz_ptr, double));10451046#define mpz_set_f __gmpz_set_f1047__GMP_DECLSPEC void mpz_set_f __GMP_PROTO ((mpz_ptr, mpf_srcptr));10481049#define mpz_set_q __gmpz_set_q1050#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q)1051__GMP_DECLSPEC void mpz_set_q __GMP_PROTO ((mpz_ptr, mpq_srcptr));1052#endif10531054#define mpz_set_si __gmpz_set_si1055__GMP_DECLSPEC void mpz_set_si __GMP_PROTO ((mpz_ptr, signed long int));10561057#define mpz_set_str __gmpz_set_str1058__GMP_DECLSPEC int mpz_set_str __GMP_PROTO ((mpz_ptr, __gmp_const char *, int));10591060#define mpz_set_ui __gmpz_set_ui1061__GMP_DECLSPEC void mpz_set_ui __GMP_PROTO ((mpz_ptr, unsigned long int));10621063#define mpz_setbit __gmpz_setbit1064__GMP_DECLSPEC void mpz_setbit __GMP_PROTO ((mpz_ptr, unsigned long int));10651066#define mpz_size __gmpz_size1067#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size)1068__GMP_DECLSPEC size_t mpz_size __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;1069#endif10701071#define mpz_sizeinbase __gmpz_sizeinbase1072__GMP_DECLSPEC size_t mpz_sizeinbase __GMP_PROTO ((mpz_srcptr, int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;10731074#define mpz_sqrt __gmpz_sqrt1075__GMP_DECLSPEC void mpz_sqrt __GMP_PROTO ((mpz_ptr, mpz_srcptr));10761077#define mpz_sqrtrem __gmpz_sqrtrem1078__GMP_DECLSPEC void mpz_sqrtrem __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr));10791080#define mpz_sub __gmpz_sub1081__GMP_DECLSPEC void mpz_sub __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));10821083#define mpz_sub_ui __gmpz_sub_ui1084__GMP_DECLSPEC void mpz_sub_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));10851086#define mpz_ui_sub __gmpz_ui_sub1087__GMP_DECLSPEC void mpz_ui_sub __GMP_PROTO ((mpz_ptr, unsigned long int, mpz_srcptr));10881089#define mpz_submul __gmpz_submul1090__GMP_DECLSPEC void mpz_submul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));10911092#define mpz_submul_ui __gmpz_submul_ui1093__GMP_DECLSPEC void mpz_submul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));10941095#define mpz_swap __gmpz_swap1096__GMP_DECLSPEC void mpz_swap __GMP_PROTO ((mpz_ptr, mpz_ptr)) __GMP_NOTHROW;10971098#define mpz_tdiv_ui __gmpz_tdiv_ui1099__GMP_DECLSPEC unsigned long int mpz_tdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;11001101#define mpz_tdiv_q __gmpz_tdiv_q1102__GMP_DECLSPEC void mpz_tdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));11031104#define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp1105__GMP_DECLSPEC void mpz_tdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));11061107#define mpz_tdiv_q_ui __gmpz_tdiv_q_ui1108__GMP_DECLSPEC unsigned long int mpz_tdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));11091110#define mpz_tdiv_qr __gmpz_tdiv_qr1111__GMP_DECLSPEC void mpz_tdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));11121113#define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui1114__GMP_DECLSPEC unsigned long int mpz_tdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));11151116#define mpz_tdiv_r __gmpz_tdiv_r1117__GMP_DECLSPEC void mpz_tdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));11181119#define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp1120__GMP_DECLSPEC void mpz_tdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));11211122#define mpz_tdiv_r_ui __gmpz_tdiv_r_ui1123__GMP_DECLSPEC unsigned long int mpz_tdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));11241125#define mpz_tstbit __gmpz_tstbit1126__GMP_DECLSPEC int mpz_tstbit __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;11271128#define mpz_ui_pow_ui __gmpz_ui_pow_ui1129__GMP_DECLSPEC void mpz_ui_pow_ui __GMP_PROTO ((mpz_ptr, unsigned long int, unsigned long int));11301131#define mpz_urandomb __gmpz_urandomb1132__GMP_DECLSPEC void mpz_urandomb __GMP_PROTO ((mpz_ptr, gmp_randstate_t, unsigned long int));11331134#define mpz_urandomm __gmpz_urandomm1135__GMP_DECLSPEC void mpz_urandomm __GMP_PROTO ((mpz_ptr, gmp_randstate_t, mpz_srcptr));11361137#define mpz_xor __gmpz_xor1138#define mpz_eor __gmpz_xor1139__GMP_DECLSPEC void mpz_xor __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));114011411142/**************** Rational (i.e. Q) routines. ****************/11431144#define mpq_abs __gmpq_abs1145#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs)1146__GMP_DECLSPEC void mpq_abs __GMP_PROTO ((mpq_ptr, mpq_srcptr));1147#endif11481149#define mpq_add __gmpq_add1150__GMP_DECLSPEC void mpq_add __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));11511152#define mpq_canonicalize __gmpq_canonicalize1153__GMP_DECLSPEC void mpq_canonicalize __GMP_PROTO ((mpq_ptr));11541155#define mpq_clear __gmpq_clear1156__GMP_DECLSPEC void mpq_clear __GMP_PROTO ((mpq_ptr));11571158#define mpq_cmp __gmpq_cmp1159__GMP_DECLSPEC int mpq_cmp __GMP_PROTO ((mpq_srcptr, mpq_srcptr)) __GMP_ATTRIBUTE_PURE;11601161#define _mpq_cmp_si __gmpq_cmp_si1162__GMP_DECLSPEC int _mpq_cmp_si __GMP_PROTO ((mpq_srcptr, long, unsigned long)) __GMP_ATTRIBUTE_PURE;11631164#define _mpq_cmp_ui __gmpq_cmp_ui1165__GMP_DECLSPEC int _mpq_cmp_ui __GMP_PROTO ((mpq_srcptr, unsigned long int, unsigned long int)) __GMP_ATTRIBUTE_PURE;11661167#define mpq_div __gmpq_div1168__GMP_DECLSPEC void mpq_div __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));11691170#define mpq_div_2exp __gmpq_div_2exp1171__GMP_DECLSPEC void mpq_div_2exp __GMP_PROTO ((mpq_ptr, mpq_srcptr, unsigned long));11721173#define mpq_equal __gmpq_equal1174__GMP_DECLSPEC int mpq_equal __GMP_PROTO ((mpq_srcptr, mpq_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;11751176#define mpq_get_num __gmpq_get_num1177__GMP_DECLSPEC void mpq_get_num __GMP_PROTO ((mpz_ptr, mpq_srcptr));11781179#define mpq_get_den __gmpq_get_den1180__GMP_DECLSPEC void mpq_get_den __GMP_PROTO ((mpz_ptr, mpq_srcptr));11811182#define mpq_get_d __gmpq_get_d1183__GMP_DECLSPEC double mpq_get_d __GMP_PROTO ((mpq_srcptr)) __GMP_ATTRIBUTE_PURE;11841185#define mpq_get_str __gmpq_get_str1186__GMP_DECLSPEC char *mpq_get_str __GMP_PROTO ((char *, int, mpq_srcptr));11871188#define mpq_init __gmpq_init1189__GMP_DECLSPEC void mpq_init __GMP_PROTO ((mpq_ptr));11901191#define mpq_inp_str __gmpq_inp_str1192#ifdef _GMP_H_HAVE_FILE1193__GMP_DECLSPEC size_t mpq_inp_str __GMP_PROTO ((mpq_ptr, FILE *, int));1194#endif11951196#define mpq_inv __gmpq_inv1197__GMP_DECLSPEC void mpq_inv __GMP_PROTO ((mpq_ptr, mpq_srcptr));11981199#define mpq_mul __gmpq_mul1200__GMP_DECLSPEC void mpq_mul __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));12011202#define mpq_mul_2exp __gmpq_mul_2exp1203__GMP_DECLSPEC void mpq_mul_2exp __GMP_PROTO ((mpq_ptr, mpq_srcptr, unsigned long));12041205#define mpq_neg __gmpq_neg1206#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg)1207__GMP_DECLSPEC void mpq_neg __GMP_PROTO ((mpq_ptr, mpq_srcptr));1208#endif12091210#define mpq_out_str __gmpq_out_str1211#ifdef _GMP_H_HAVE_FILE1212__GMP_DECLSPEC size_t mpq_out_str __GMP_PROTO ((FILE *, int, mpq_srcptr));1213#endif12141215#define mpq_set __gmpq_set1216__GMP_DECLSPEC void mpq_set __GMP_PROTO ((mpq_ptr, mpq_srcptr));12171218#define mpq_set_d __gmpq_set_d1219__GMP_DECLSPEC void mpq_set_d __GMP_PROTO ((mpq_ptr, double));12201221#define mpq_set_den __gmpq_set_den1222__GMP_DECLSPEC void mpq_set_den __GMP_PROTO ((mpq_ptr, mpz_srcptr));12231224#define mpq_set_f __gmpq_set_f1225__GMP_DECLSPEC void mpq_set_f __GMP_PROTO ((mpq_ptr, mpf_srcptr));12261227#define mpq_set_num __gmpq_set_num1228__GMP_DECLSPEC void mpq_set_num __GMP_PROTO ((mpq_ptr, mpz_srcptr));12291230#define mpq_set_si __gmpq_set_si1231__GMP_DECLSPEC void mpq_set_si __GMP_PROTO ((mpq_ptr, signed long int, unsigned long int));12321233#define mpq_set_str __gmpq_set_str1234__GMP_DECLSPEC int mpq_set_str __GMP_PROTO ((mpq_ptr, __gmp_const char *, int));12351236#define mpq_set_ui __gmpq_set_ui1237__GMP_DECLSPEC void mpq_set_ui __GMP_PROTO ((mpq_ptr, unsigned long int, unsigned long int));12381239#define mpq_set_z __gmpq_set_z1240__GMP_DECLSPEC void mpq_set_z __GMP_PROTO ((mpq_ptr, mpz_srcptr));12411242#define mpq_sub __gmpq_sub1243__GMP_DECLSPEC void mpq_sub __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));12441245#define mpq_swap __gmpq_swap1246__GMP_DECLSPEC void mpq_swap __GMP_PROTO ((mpq_ptr, mpq_ptr)) __GMP_NOTHROW;124712481249/**************** Float (i.e. F) routines. ****************/12501251#define mpf_abs __gmpf_abs1252__GMP_DECLSPEC void mpf_abs __GMP_PROTO ((mpf_ptr, mpf_srcptr));12531254#define mpf_add __gmpf_add1255__GMP_DECLSPEC void mpf_add __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));12561257#define mpf_add_ui __gmpf_add_ui1258__GMP_DECLSPEC void mpf_add_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));1259#define mpf_ceil __gmpf_ceil1260__GMP_DECLSPEC void mpf_ceil __GMP_PROTO ((mpf_ptr, mpf_srcptr));12611262#define mpf_clear __gmpf_clear1263__GMP_DECLSPEC void mpf_clear __GMP_PROTO ((mpf_ptr));12641265#define mpf_cmp __gmpf_cmp1266__GMP_DECLSPEC int mpf_cmp __GMP_PROTO ((mpf_srcptr, mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;12671268#define mpf_cmp_d __gmpf_cmp_d1269__GMP_DECLSPEC int mpf_cmp_d __GMP_PROTO ((mpf_srcptr, double)) __GMP_ATTRIBUTE_PURE;12701271#define mpf_cmp_si __gmpf_cmp_si1272__GMP_DECLSPEC int mpf_cmp_si __GMP_PROTO ((mpf_srcptr, signed long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;12731274#define mpf_cmp_ui __gmpf_cmp_ui1275__GMP_DECLSPEC int mpf_cmp_ui __GMP_PROTO ((mpf_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;12761277#define mpf_div __gmpf_div1278__GMP_DECLSPEC void mpf_div __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));12791280#define mpf_div_2exp __gmpf_div_2exp1281__GMP_DECLSPEC void mpf_div_2exp __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));12821283#define mpf_div_ui __gmpf_div_ui1284__GMP_DECLSPEC void mpf_div_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));12851286#define mpf_dump __gmpf_dump1287__GMP_DECLSPEC void mpf_dump __GMP_PROTO ((mpf_srcptr));12881289#define mpf_eq __gmpf_eq1290__GMP_DECLSPEC int mpf_eq __GMP_PROTO ((mpf_srcptr, mpf_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;12911292#define mpf_fits_sint_p __gmpf_fits_sint_p1293__GMP_DECLSPEC int mpf_fits_sint_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;12941295#define mpf_fits_slong_p __gmpf_fits_slong_p1296__GMP_DECLSPEC int mpf_fits_slong_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;12971298#define mpf_fits_sshort_p __gmpf_fits_sshort_p1299__GMP_DECLSPEC int mpf_fits_sshort_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13001301#define mpf_fits_uint_p __gmpf_fits_uint_p1302__GMP_DECLSPEC int mpf_fits_uint_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13031304#define mpf_fits_ulong_p __gmpf_fits_ulong_p1305__GMP_DECLSPEC int mpf_fits_ulong_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13061307#define mpf_fits_ushort_p __gmpf_fits_ushort_p1308__GMP_DECLSPEC int mpf_fits_ushort_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13091310#define mpf_floor __gmpf_floor1311__GMP_DECLSPEC void mpf_floor __GMP_PROTO ((mpf_ptr, mpf_srcptr));13121313#define mpf_get_d __gmpf_get_d1314__GMP_DECLSPEC double mpf_get_d __GMP_PROTO ((mpf_srcptr)) __GMP_ATTRIBUTE_PURE;13151316#define mpf_get_d_2exp __gmpf_get_d_2exp1317__GMP_DECLSPEC double mpf_get_d_2exp __GMP_PROTO ((signed long int *, mpf_srcptr));13181319#define mpf_get_default_prec __gmpf_get_default_prec1320__GMP_DECLSPEC unsigned long int mpf_get_default_prec __GMP_PROTO ((void)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13211322#define mpf_get_prec __gmpf_get_prec1323__GMP_DECLSPEC unsigned long int mpf_get_prec __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13241325#define mpf_get_si __gmpf_get_si1326__GMP_DECLSPEC long mpf_get_si __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13271328#define mpf_get_str __gmpf_get_str1329__GMP_DECLSPEC char *mpf_get_str __GMP_PROTO ((char *, mp_exp_t *, int, size_t, mpf_srcptr));13301331#define mpf_get_ui __gmpf_get_ui1332__GMP_DECLSPEC unsigned long mpf_get_ui __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13331334#define mpf_init __gmpf_init1335__GMP_DECLSPEC void mpf_init __GMP_PROTO ((mpf_ptr));13361337#define mpf_init2 __gmpf_init21338__GMP_DECLSPEC void mpf_init2 __GMP_PROTO ((mpf_ptr, unsigned long int));13391340#define mpf_init_set __gmpf_init_set1341__GMP_DECLSPEC void mpf_init_set __GMP_PROTO ((mpf_ptr, mpf_srcptr));13421343#define mpf_init_set_d __gmpf_init_set_d1344__GMP_DECLSPEC void mpf_init_set_d __GMP_PROTO ((mpf_ptr, double));13451346#define mpf_init_set_si __gmpf_init_set_si1347__GMP_DECLSPEC void mpf_init_set_si __GMP_PROTO ((mpf_ptr, signed long int));13481349#define mpf_init_set_str __gmpf_init_set_str1350__GMP_DECLSPEC int mpf_init_set_str __GMP_PROTO ((mpf_ptr, __gmp_const char *, int));13511352#define mpf_init_set_ui __gmpf_init_set_ui1353__GMP_DECLSPEC void mpf_init_set_ui __GMP_PROTO ((mpf_ptr, unsigned long int));13541355#define mpf_inp_str __gmpf_inp_str1356#ifdef _GMP_H_HAVE_FILE1357__GMP_DECLSPEC size_t mpf_inp_str __GMP_PROTO ((mpf_ptr, FILE *, int));1358#endif13591360#define mpf_integer_p __gmpf_integer_p1361__GMP_DECLSPEC int mpf_integer_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;13621363#define mpf_mul __gmpf_mul1364__GMP_DECLSPEC void mpf_mul __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));13651366#define mpf_mul_2exp __gmpf_mul_2exp1367__GMP_DECLSPEC void mpf_mul_2exp __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));13681369#define mpf_mul_ui __gmpf_mul_ui1370__GMP_DECLSPEC void mpf_mul_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));13711372#define mpf_neg __gmpf_neg1373__GMP_DECLSPEC void mpf_neg __GMP_PROTO ((mpf_ptr, mpf_srcptr));13741375#define mpf_out_str __gmpf_out_str1376#ifdef _GMP_H_HAVE_FILE1377__GMP_DECLSPEC size_t mpf_out_str __GMP_PROTO ((FILE *, int, size_t, mpf_srcptr));1378#endif13791380#define mpf_pow_ui __gmpf_pow_ui1381__GMP_DECLSPEC void mpf_pow_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));13821383#define mpf_random2 __gmpf_random21384__GMP_DECLSPEC void mpf_random2 __GMP_PROTO ((mpf_ptr, mp_size_t, mp_exp_t));13851386#define mpf_reldiff __gmpf_reldiff1387__GMP_DECLSPEC void mpf_reldiff __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));13881389#define mpf_set __gmpf_set1390__GMP_DECLSPEC void mpf_set __GMP_PROTO ((mpf_ptr, mpf_srcptr));13911392#define mpf_set_d __gmpf_set_d1393__GMP_DECLSPEC void mpf_set_d __GMP_PROTO ((mpf_ptr, double));13941395#define mpf_set_default_prec __gmpf_set_default_prec1396__GMP_DECLSPEC void mpf_set_default_prec __GMP_PROTO ((unsigned long int)) __GMP_NOTHROW;13971398#define mpf_set_prec __gmpf_set_prec1399__GMP_DECLSPEC void mpf_set_prec __GMP_PROTO ((mpf_ptr, unsigned long int));14001401#define mpf_set_prec_raw __gmpf_set_prec_raw1402__GMP_DECLSPEC void mpf_set_prec_raw __GMP_PROTO ((mpf_ptr, unsigned long int)) __GMP_NOTHROW;14031404#define mpf_set_q __gmpf_set_q1405__GMP_DECLSPEC void mpf_set_q __GMP_PROTO ((mpf_ptr, mpq_srcptr));14061407#define mpf_set_si __gmpf_set_si1408__GMP_DECLSPEC void mpf_set_si __GMP_PROTO ((mpf_ptr, signed long int));14091410#define mpf_set_str __gmpf_set_str1411__GMP_DECLSPEC int mpf_set_str __GMP_PROTO ((mpf_ptr, __gmp_const char *, int));14121413#define mpf_set_ui __gmpf_set_ui1414__GMP_DECLSPEC void mpf_set_ui __GMP_PROTO ((mpf_ptr, unsigned long int));14151416#define mpf_set_z __gmpf_set_z1417__GMP_DECLSPEC void mpf_set_z __GMP_PROTO ((mpf_ptr, mpz_srcptr));14181419#define mpf_size __gmpf_size1420__GMP_DECLSPEC size_t mpf_size __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;14211422#define mpf_sqrt __gmpf_sqrt1423__GMP_DECLSPEC void mpf_sqrt __GMP_PROTO ((mpf_ptr, mpf_srcptr));14241425#define mpf_sqrt_ui __gmpf_sqrt_ui1426__GMP_DECLSPEC void mpf_sqrt_ui __GMP_PROTO ((mpf_ptr, unsigned long int));14271428#define mpf_sub __gmpf_sub1429__GMP_DECLSPEC void mpf_sub __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));14301431#define mpf_sub_ui __gmpf_sub_ui1432__GMP_DECLSPEC void mpf_sub_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));14331434#define mpf_swap __gmpf_swap1435__GMP_DECLSPEC void mpf_swap __GMP_PROTO ((mpf_ptr, mpf_ptr)) __GMP_NOTHROW;14361437#define mpf_trunc __gmpf_trunc1438__GMP_DECLSPEC void mpf_trunc __GMP_PROTO ((mpf_ptr, mpf_srcptr));14391440#define mpf_ui_div __gmpf_ui_div1441__GMP_DECLSPEC void mpf_ui_div __GMP_PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));14421443#define mpf_ui_sub __gmpf_ui_sub1444__GMP_DECLSPEC void mpf_ui_sub __GMP_PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));14451446#define mpf_urandomb __gmpf_urandomb1447__GMP_DECLSPEC void mpf_urandomb __GMP_PROTO ((mpf_t, gmp_randstate_t, unsigned long int));144814491450/************ Low level positive-integer (i.e. N) routines. ************/14511452/* This is ugly, but we need to make user calls reach the prefixed function. */14531454#define mpn_add __MPN(add)1455#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add)1456__GMP_DECLSPEC mp_limb_t mpn_add __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));1457#endif14581459#define mpn_add_1 __MPN(add_1)1460#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1)1461__GMP_DECLSPEC mp_limb_t mpn_add_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW;1462#endif14631464#define mpn_add_n __MPN(add_n)1465__GMP_DECLSPEC mp_limb_t mpn_add_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));14661467#define mpn_addmul_1 __MPN(addmul_1)1468__GMP_DECLSPEC mp_limb_t mpn_addmul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));14691470#define mpn_bdivmod __MPN(bdivmod)1471__GMP_DECLSPEC mp_limb_t mpn_bdivmod __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, unsigned long int));14721473#define mpn_cmp __MPN(cmp)1474#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp)1475__GMP_DECLSPEC int mpn_cmp __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;1476#endif14771478#define mpn_divexact_by3(dst,src,size) \1479mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0))14801481#define mpn_divexact_by3c __MPN(divexact_by3c)1482__GMP_DECLSPEC mp_limb_t mpn_divexact_by3c __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));14831484#define mpn_divmod_1(qp,np,nsize,dlimb) \1485mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb)14861487#define mpn_divrem __MPN(divrem)1488__GMP_DECLSPEC mp_limb_t mpn_divrem __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t));14891490#define mpn_divrem_1 __MPN(divrem_1)1491__GMP_DECLSPEC mp_limb_t mpn_divrem_1 __GMP_PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t));14921493#define mpn_divrem_2 __MPN(divrem_2)1494__GMP_DECLSPEC mp_limb_t mpn_divrem_2 __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr));14951496#define mpn_gcd __MPN(gcd)1497__GMP_DECLSPEC mp_size_t mpn_gcd __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t));14981499#define mpn_gcd_1 __MPN(gcd_1)1500__GMP_DECLSPEC mp_limb_t mpn_gcd_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE;15011502#define mpn_gcdext __MPN(gcdext)1503__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));15041505#define mpn_get_str __MPN(get_str)1506__GMP_DECLSPEC size_t mpn_get_str __GMP_PROTO ((unsigned char *, int, mp_ptr, mp_size_t));15071508#define mpn_hamdist __MPN(hamdist)1509__GMP_DECLSPEC unsigned long int mpn_hamdist __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;15101511#define mpn_lshift __MPN(lshift)1512__GMP_DECLSPEC mp_limb_t mpn_lshift __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));15131514#define mpn_mod_1 __MPN(mod_1)1515__GMP_DECLSPEC mp_limb_t mpn_mod_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE;15161517#define mpn_mul __MPN(mul)1518__GMP_DECLSPEC mp_limb_t mpn_mul __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));15191520#define mpn_mul_1 __MPN(mul_1)1521__GMP_DECLSPEC mp_limb_t mpn_mul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));15221523#define mpn_mul_n __MPN(mul_n)1524__GMP_DECLSPEC void mpn_mul_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));15251526#define mpn_perfect_square_p __MPN(perfect_square_p)1527__GMP_DECLSPEC int mpn_perfect_square_p __GMP_PROTO ((mp_srcptr, mp_size_t)) __GMP_ATTRIBUTE_PURE;15281529#define mpn_popcount __MPN(popcount)1530__GMP_DECLSPEC unsigned long int mpn_popcount __GMP_PROTO ((mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;15311532#define mpn_pow_1 __MPN(pow_1)1533__GMP_DECLSPEC mp_size_t mpn_pow_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr));15341535/* undocumented now, but retained here for upward compatibility */1536#define mpn_preinv_mod_1 __MPN(preinv_mod_1)1537__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;15381539#define mpn_random __MPN(random)1540__GMP_DECLSPEC void mpn_random __GMP_PROTO ((mp_ptr, mp_size_t));15411542#define mpn_random2 __MPN(random2)1543__GMP_DECLSPEC void mpn_random2 __GMP_PROTO ((mp_ptr, mp_size_t));15441545#define mpn_rshift __MPN(rshift)1546__GMP_DECLSPEC mp_limb_t mpn_rshift __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));15471548#define mpn_scan0 __MPN(scan0)1549__GMP_DECLSPEC unsigned long int mpn_scan0 __GMP_PROTO ((mp_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;15501551#define mpn_scan1 __MPN(scan1)1552__GMP_DECLSPEC unsigned long int mpn_scan1 __GMP_PROTO ((mp_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;15531554#define mpn_set_str __MPN(set_str)1555__GMP_DECLSPEC mp_size_t mpn_set_str __GMP_PROTO ((mp_ptr, __gmp_const unsigned char *, size_t, int));15561557#define mpn_sqrtrem __MPN(sqrtrem)1558__GMP_DECLSPEC mp_size_t mpn_sqrtrem __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t));15591560#define mpn_sub __MPN(sub)1561#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub)1562__GMP_DECLSPEC mp_limb_t mpn_sub __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));1563#endif15641565#define mpn_sub_1 __MPN(sub_1)1566#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1)1567__GMP_DECLSPEC mp_limb_t mpn_sub_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW;1568#endif15691570#define mpn_sub_n __MPN(sub_n)1571__GMP_DECLSPEC mp_limb_t mpn_sub_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));15721573#define mpn_submul_1 __MPN(submul_1)1574__GMP_DECLSPEC mp_limb_t mpn_submul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));15751576#define mpn_tdiv_qr __MPN(tdiv_qr)1577__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));157815791580/**************** mpz inlines ****************/15811582/* The following are provided as inlines where possible, but always exist as1583library functions too, for binary compatibility.15841585Within gmp itself this inlining generally isn't relied on, since it1586doesn't get done for all compilers, whereas if something is worth1587inlining then it's worth arranging always.15881589There are two styles of inlining here. When the same bit of code is1590wanted for the inline as for the library version, then __GMP_FORCE_foo1591arranges for that code to be emitted and the __GMP_EXTERN_INLINE1592directive suppressed, eg. mpz_fits_uint_p. When a different bit of code1593is wanted for the inline than for the library version, then1594__GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs. */15951596#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs)1597__GMP_EXTERN_INLINE void1598mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)1599{1600if (__gmp_w != __gmp_u)1601mpz_set (__gmp_w, __gmp_u);1602__gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size);1603}1604#endif16051606#if GMP_NAIL_BITS == 01607#define __GMPZ_FITS_UTYPE_P(z,maxval) \1608mp_size_t __gmp_n = z->_mp_size; \1609mp_ptr __gmp_p = z->_mp_d; \1610return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval));1611#else1612#define __GMPZ_FITS_UTYPE_P(z,maxval) \1613mp_size_t __gmp_n = z->_mp_size; \1614mp_ptr __gmp_p = z->_mp_d; \1615return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval) \1616|| (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS)));1617#endif16181619#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p)1620#if ! defined (__GMP_FORCE_mpz_fits_uint_p)1621__GMP_EXTERN_INLINE1622#endif1623int1624mpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW1625{1626__GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_UINT_MAX);1627}1628#endif16291630#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p)1631#if ! defined (__GMP_FORCE_mpz_fits_ulong_p)1632__GMP_EXTERN_INLINE1633#endif1634int1635mpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW1636{1637__GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_ULONG_MAX);1638}1639#endif16401641#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p)1642#if ! defined (__GMP_FORCE_mpz_fits_ushort_p)1643__GMP_EXTERN_INLINE1644#endif1645int1646mpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW1647{1648__GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_USHRT_MAX);1649}1650#endif16511652#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui)1653#if ! defined (__GMP_FORCE_mpz_get_ui)1654__GMP_EXTERN_INLINE1655#endif1656unsigned long1657mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW1658{1659mp_ptr __gmp_p = __gmp_z->_mp_d;1660mp_size_t __gmp_n = __gmp_z->_mp_size;1661mp_limb_t __gmp_l = __gmp_p[0];1662/* This is a "#if" rather than a plain "if" so as to avoid gcc warnings1663about "<< GMP_NUMB_BITS" exceeding the type size, and to avoid Borland1664C++ 6.0 warnings about condition always true for something like1665"__GMP_ULONG_MAX < GMP_NUMB_MASK". */1666#if GMP_NAIL_BITS == 0 || defined (_LONG_LONG_LIMB)1667/* limb==long and no nails, or limb==longlong, one limb is enough */1668return (__gmp_n != 0 ? __gmp_l : 0);1669#else1670/* limb==long and nails, need two limbs when available */1671__gmp_n = __GMP_ABS (__gmp_n);1672if (__gmp_n <= 1)1673return (__gmp_n != 0 ? __gmp_l : 0);1674else1675return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS);1676#endif1677}1678#endif16791680#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn)1681#if ! defined (__GMP_FORCE_mpz_getlimbn)1682__GMP_EXTERN_INLINE1683#endif1684mp_limb_t1685mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW1686{1687mp_limb_t __gmp_result = 0;1688if (__GMP_LIKELY (__gmp_n >= 0 && __gmp_n < __GMP_ABS (__gmp_z->_mp_size)))1689__gmp_result = __gmp_z->_mp_d[__gmp_n];1690return __gmp_result;1691}1692#endif16931694#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg)1695__GMP_EXTERN_INLINE void1696mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)1697{1698if (__gmp_w != __gmp_u)1699mpz_set (__gmp_w, __gmp_u);1700__gmp_w->_mp_size = - __gmp_w->_mp_size;1701}1702#endif17031704#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p)1705#if ! defined (__GMP_FORCE_mpz_perfect_square_p)1706__GMP_EXTERN_INLINE1707#endif1708int1709mpz_perfect_square_p (mpz_srcptr __gmp_a)1710{1711mp_size_t __gmp_asize;1712int __gmp_result;17131714__gmp_asize = __gmp_a->_mp_size;1715__gmp_result = (__gmp_asize >= 0); /* zero is a square, negatives are not */1716if (__GMP_LIKELY (__gmp_asize > 0))1717__gmp_result = mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize);1718return __gmp_result;1719}1720#endif17211722#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount)1723#if ! defined (__GMP_FORCE_mpz_popcount)1724__GMP_EXTERN_INLINE1725#endif1726unsigned long1727mpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW1728{1729mp_size_t __gmp_usize;1730unsigned long __gmp_result;17311732__gmp_usize = __gmp_u->_mp_size;1733__gmp_result = (__gmp_usize < 0 ? __GMP_ULONG_MAX : 0);1734if (__GMP_LIKELY (__gmp_usize > 0))1735__gmp_result = mpn_popcount (__gmp_u->_mp_d, __gmp_usize);1736return __gmp_result;1737}1738#endif17391740#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q)1741#if ! defined (__GMP_FORCE_mpz_set_q)1742__GMP_EXTERN_INLINE1743#endif1744void1745mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u)1746{1747mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u));1748}1749#endif17501751#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size)1752#if ! defined (__GMP_FORCE_mpz_size)1753__GMP_EXTERN_INLINE1754#endif1755size_t1756mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW1757{1758return __GMP_ABS (__gmp_z->_mp_size);1759}1760#endif176117621763/**************** mpq inlines ****************/17641765#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs)1766__GMP_EXTERN_INLINE void1767mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)1768{1769if (__gmp_w != __gmp_u)1770mpq_set (__gmp_w, __gmp_u);1771__gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size);1772}1773#endif17741775#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg)1776__GMP_EXTERN_INLINE void1777mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)1778{1779if (__gmp_w != __gmp_u)1780mpq_set (__gmp_w, __gmp_u);1781__gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size;1782}1783#endif178417851786/**************** mpn inlines ****************/17871788/* The comments with __GMPN_ADD_1 below apply here too.17891790The test for FUNCTION returning 0 should predict well. If it's assumed1791{yp,ysize} will usually have a random number of bits then the high limb1792won't be full and a carry out will occur a good deal less than 50% of the1793time.17941795ysize==0 isn't a documented feature, but is used internally in a few1796places.17971798Producing cout last stops it using up a register during the main part of1799the calculation, though gcc (as of 3.0) on an "if (mpn_add (...))"1800doesn't seem able to move the true and false legs of the conditional up1801to the two places cout is generated. */18021803#define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST) \1804do { \1805mp_size_t __gmp_i; \1806mp_limb_t __gmp_x; \1807\1808/* ASSERT ((ysize) >= 0); */ \1809/* ASSERT ((xsize) >= (ysize)); */ \1810/* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */ \1811/* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */ \1812\1813__gmp_i = (ysize); \1814if (__gmp_i != 0) \1815{ \1816if (FUNCTION (wp, xp, yp, __gmp_i)) \1817{ \1818do \1819{ \1820if (__gmp_i >= (xsize)) \1821{ \1822(cout) = 1; \1823goto __gmp_done; \1824} \1825__gmp_x = (xp)[__gmp_i]; \1826} \1827while (TEST); \1828} \1829} \1830if ((wp) != (xp)) \1831__GMPN_COPY_REST (wp, xp, xsize, __gmp_i); \1832(cout) = 0; \1833__gmp_done: \1834; \1835} while (0)18361837#define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize) \1838__GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n, \1839(((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0))1840#define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize) \1841__GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n, \1842(((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0))184318441845/* The use of __gmp_i indexing is designed to ensure a compile time src==dst1846remains nice and clear to the compiler, so that __GMPN_COPY_REST can1847disappear, and the load/add/store gets a chance to become a1848read-modify-write on CISC CPUs.18491850Alternatives:18511852Using a pair of pointers instead of indexing would be possible, but gcc1853isn't able to recognise compile-time src==dst in that case, even when the1854pointers are incremented more or less together. Other compilers would1855very likely have similar difficulty.18561857gcc could use "if (__builtin_constant_p(src==dst) && src==dst)" or1858similar to detect a compile-time src==dst. This works nicely on gcc18592.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems1860to be always false, for a pointer p. But the current code form seems1861good enough for src==dst anyway.18621863gcc on x86 as usual doesn't give particularly good flags handling for the1864carry/borrow detection. It's tempting to want some multi instruction asm1865blocks to help it, and this was tried, but in truth there's only a few1866instructions to save and any gain is all too easily lost by register1867juggling setting up for the asm. */18681869#if GMP_NAIL_BITS == 01870#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \1871do { \1872mp_size_t __gmp_i; \1873mp_limb_t __gmp_x, __gmp_r; \1874\1875/* ASSERT ((n) >= 1); */ \1876/* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \1877\1878__gmp_x = (src)[0]; \1879__gmp_r = __gmp_x OP (v); \1880(dst)[0] = __gmp_r; \1881if (CB (__gmp_r, __gmp_x, (v))) \1882{ \1883(cout) = 1; \1884for (__gmp_i = 1; __gmp_i < (n);) \1885{ \1886__gmp_x = (src)[__gmp_i]; \1887__gmp_r = __gmp_x OP 1; \1888(dst)[__gmp_i] = __gmp_r; \1889++__gmp_i; \1890if (!CB (__gmp_r, __gmp_x, 1)) \1891{ \1892if ((src) != (dst)) \1893__GMPN_COPY_REST (dst, src, n, __gmp_i); \1894(cout) = 0; \1895break; \1896} \1897} \1898} \1899else \1900{ \1901if ((src) != (dst)) \1902__GMPN_COPY_REST (dst, src, n, 1); \1903(cout) = 0; \1904} \1905} while (0)1906#endif19071908#if GMP_NAIL_BITS >= 11909#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \1910do { \1911mp_size_t __gmp_i; \1912mp_limb_t __gmp_x, __gmp_r; \1913\1914/* ASSERT ((n) >= 1); */ \1915/* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \1916\1917__gmp_x = (src)[0]; \1918__gmp_r = __gmp_x OP (v); \1919(dst)[0] = __gmp_r & GMP_NUMB_MASK; \1920if (__gmp_r >> GMP_NUMB_BITS != 0) \1921{ \1922(cout) = 1; \1923for (__gmp_i = 1; __gmp_i < (n);) \1924{ \1925__gmp_x = (src)[__gmp_i]; \1926__gmp_r = __gmp_x OP 1; \1927(dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK; \1928++__gmp_i; \1929if (__gmp_r >> GMP_NUMB_BITS == 0) \1930{ \1931if ((src) != (dst)) \1932__GMPN_COPY_REST (dst, src, n, __gmp_i); \1933(cout) = 0; \1934break; \1935} \1936} \1937} \1938else \1939{ \1940if ((src) != (dst)) \1941__GMPN_COPY_REST (dst, src, n, 1); \1942(cout) = 0; \1943} \1944} while (0)1945#endif19461947#define __GMPN_ADDCB(r,x,y) ((r) < (y))1948#define __GMPN_SUBCB(r,x,y) ((x) < (y))19491950#define __GMPN_ADD_1(cout, dst, src, n, v) \1951__GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB)1952#define __GMPN_SUB_1(cout, dst, src, n, v) \1953__GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB)195419551956/* Compare {xp,size} and {yp,size}, setting "result" to positive, zero or1957negative. size==0 is allowed. On random data usually only one limb will1958need to be examined to get a result, so it's worth having it inline. */1959#define __GMPN_CMP(result, xp, yp, size) \1960do { \1961mp_size_t __gmp_i; \1962mp_limb_t __gmp_x, __gmp_y; \1963\1964/* ASSERT ((size) >= 0); */ \1965\1966(result) = 0; \1967__gmp_i = (size); \1968while (--__gmp_i >= 0) \1969{ \1970__gmp_x = (xp)[__gmp_i]; \1971__gmp_y = (yp)[__gmp_i]; \1972if (__gmp_x != __gmp_y) \1973{ \1974/* Cannot use __gmp_x - __gmp_y, may overflow an "int" */ \1975(result) = (__gmp_x > __gmp_y ? 1 : -1); \1976break; \1977} \1978} \1979} while (0)198019811982#if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST)1983#define __GMPN_COPY_REST(dst, src, size, start) \1984do { \1985/* ASSERT ((start) >= 0); */ \1986/* ASSERT ((start) <= (size)); */ \1987__GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \1988} while (0)1989#endif19901991/* Copy {src,size} to {dst,size}, starting at "start". This is designed to1992keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1,1993__GMPN_ADD, etc. */1994#if ! defined (__GMPN_COPY_REST)1995#define __GMPN_COPY_REST(dst, src, size, start) \1996do { \1997mp_size_t __gmp_j; \1998/* ASSERT ((size) >= 0); */ \1999/* ASSERT ((start) >= 0); */ \2000/* ASSERT ((start) <= (size)); */ \2001/* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */ \2002__GMP_CRAY_Pragma ("_CRI ivdep"); \2003for (__gmp_j = (start); __gmp_j < (size); __gmp_j++) \2004(dst)[__gmp_j] = (src)[__gmp_j]; \2005} while (0)2006#endif20072008/* Enhancement: Use some of the smarter code from gmp-impl.h. Maybe use2009mpn_copyi if there's a native version, and if we don't mind demanding2010binary compatibility for it (on targets which use it). */20112012#if ! defined (__GMPN_COPY)2013#define __GMPN_COPY(dst, src, size) __GMPN_COPY_REST (dst, src, size, 0)2014#endif201520162017#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add)2018#if ! defined (__GMP_FORCE_mpn_add)2019__GMP_EXTERN_INLINE2020#endif2021mp_limb_t2022mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)2023{2024mp_limb_t __gmp_c;2025__GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);2026return __gmp_c;2027}2028#endif20292030#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1)2031#if ! defined (__GMP_FORCE_mpn_add_1)2032__GMP_EXTERN_INLINE2033#endif2034mp_limb_t2035mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW2036{2037mp_limb_t __gmp_c;2038__GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);2039return __gmp_c;2040}2041#endif20422043#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp)2044#if ! defined (__GMP_FORCE_mpn_cmp)2045__GMP_EXTERN_INLINE2046#endif2047int2048mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW2049{2050int __gmp_result;2051__GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size);2052return __gmp_result;2053}2054#endif20552056#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub)2057#if ! defined (__GMP_FORCE_mpn_sub)2058__GMP_EXTERN_INLINE2059#endif2060mp_limb_t2061mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)2062{2063mp_limb_t __gmp_c;2064__GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);2065return __gmp_c;2066}2067#endif20682069#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1)2070#if ! defined (__GMP_FORCE_mpn_sub_1)2071__GMP_EXTERN_INLINE2072#endif2073mp_limb_t2074mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW2075{2076mp_limb_t __gmp_c;2077__GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);2078return __gmp_c;2079}2080#endif20812082#if defined (__cplusplus)2083}2084#endif208520862087/* Allow faster testing for negative, zero, and positive. */2088#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)2089#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)2090#define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0)20912092/* When using GCC, optimize certain common comparisons. */2093#if defined (__GNUC__)2094#define mpz_cmp_ui(Z,UI) \2095(__builtin_constant_p (UI) && (UI) == 0 \2096? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))2097#define mpz_cmp_si(Z,SI) \2098(__builtin_constant_p (SI) && (SI) == 0 ? mpz_sgn (Z) \2099: __builtin_constant_p (SI) && (SI) > 0 \2100? _mpz_cmp_ui (Z, __GMP_CAST (unsigned long int, SI)) \2101: _mpz_cmp_si (Z,SI))2102#define mpq_cmp_ui(Q,NUI,DUI) \2103(__builtin_constant_p (NUI) && (NUI) == 0 \2104? mpq_sgn (Q) : _mpq_cmp_ui (Q,NUI,DUI))2105#define mpq_cmp_si(q,n,d) \2106(__builtin_constant_p ((n) >= 0) && (n) >= 0 \2107? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d) \2108: _mpq_cmp_si (q, n, d))2109#else2110#define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI)2111#define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI)2112#define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI)2113#define mpq_cmp_si(q,n,d) _mpq_cmp_si(q,n,d)2114#endif211521162117/* Using "&" rather than "&&" means these can come out branch-free. Every2118mpz_t has at least one limb allocated, so fetching the low limb is always2119allowed. */2120#define mpz_odd_p(z) (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0]))2121#define mpz_even_p(z) (! mpz_odd_p (z))212221232124/**************** C++ routines ****************/21252126#ifdef __cplusplus2127__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr);2128__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr);2129__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr);2130__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr);2131__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr);2132__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr);2133#endif213421352136/* Source-level compatibility with GMP 2 and earlier. */2137#define mpn_divmod(qp,np,nsize,dp,dsize) \2138mpn_divrem (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dp, dsize)21392140/* Source-level compatibility with GMP 1. */2141#define mpz_mdiv mpz_fdiv_q2142#define mpz_mdivmod mpz_fdiv_qr2143#define mpz_mmod mpz_fdiv_r2144#define mpz_mdiv_ui mpz_fdiv_q_ui2145#define mpz_mdivmod_ui(q,r,n,d) \2146(((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d))2147#define mpz_mmod_ui(r,n,d) \2148(((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d))21492150/* Useful synonyms, but not quite compatible with GMP 1. */2151#define mpz_div mpz_fdiv_q2152#define mpz_divmod mpz_fdiv_qr2153#define mpz_div_ui mpz_fdiv_q_ui2154#define mpz_divmod_ui mpz_fdiv_qr_ui2155#define mpz_div_2exp mpz_fdiv_q_2exp2156#define mpz_mod_2exp mpz_fdiv_r_2exp21572158enum2159{2160GMP_ERROR_NONE = 0,2161GMP_ERROR_UNSUPPORTED_ARGUMENT = 1,2162GMP_ERROR_DIVISION_BY_ZERO = 2,2163GMP_ERROR_SQRT_OF_NEGATIVE = 4,2164GMP_ERROR_INVALID_ARGUMENT = 82165};21662167/* Major version number is the value of __GNU_MP__ too, above and in mp.h. */2168#define __GNU_MP_VERSION 42169#define __GNU_MP_VERSION_MINOR 22170#define __GNU_MP_VERSION_PATCHLEVEL 121712172#define __GMP_H__2173#endif /* __GMP_H__ */217421752176