16b942a58Schristos /* Definitions for GNU multiple precision functions. -*- mode: c -*-
26b942a58Schristos
36b942a58Schristos Copyright 1991, 1993-1997, 1999-2016, 2020 Free Software Foundation, Inc.
46b942a58Schristos
56b942a58Schristos This file is part of the GNU MP Library.
66b942a58Schristos
76b942a58Schristos The GNU MP Library is free software; you can redistribute it and/or modify
86b942a58Schristos it under the terms of either:
96b942a58Schristos
106b942a58Schristos * the GNU Lesser General Public License as published by the Free
116b942a58Schristos Software Foundation; either version 3 of the License, or (at your
126b942a58Schristos option) any later version.
136b942a58Schristos
146b942a58Schristos or
156b942a58Schristos
166b942a58Schristos * the GNU General Public License as published by the Free Software
176b942a58Schristos Foundation; either version 2 of the License, or (at your option) any
186b942a58Schristos later version.
196b942a58Schristos
206b942a58Schristos or both in parallel, as here.
216b942a58Schristos
226b942a58Schristos The GNU MP Library is distributed in the hope that it will be useful, but
236b942a58Schristos WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
246b942a58Schristos or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
256b942a58Schristos for more details.
266b942a58Schristos
276b942a58Schristos You should have received copies of the GNU General Public License and the
286b942a58Schristos GNU Lesser General Public License along with the GNU MP Library. If not,
296b942a58Schristos see https://www.gnu.org/licenses/. */
306b942a58Schristos
316b942a58Schristos #ifndef __GMP_H__
326b942a58Schristos
336b942a58Schristos #if defined (__cplusplus)
346b942a58Schristos #include <iosfwd> /* for std::istream, std::ostream, std::string */
356b942a58Schristos #include <cstdio>
366b942a58Schristos #endif
376b942a58Schristos
386b942a58Schristos
396b942a58Schristos /* Instantiated by configure. */
406b942a58Schristos #if ! defined (__GMP_WITHIN_CONFIGURE)
416b942a58Schristos #define __GMP_HAVE_HOST_CPU_FAMILY_power 0
426b942a58Schristos #define __GMP_HAVE_HOST_CPU_FAMILY_powerpc 0
436b942a58Schristos #define GMP_LIMB_BITS 64
446b942a58Schristos #define GMP_NAIL_BITS 0
456b942a58Schristos #endif
466b942a58Schristos #define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS)
476b942a58Schristos #define GMP_NUMB_MASK ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS)
486b942a58Schristos #define GMP_NUMB_MAX GMP_NUMB_MASK
496b942a58Schristos #define GMP_NAIL_MASK (~ GMP_NUMB_MASK)
506b942a58Schristos
516b942a58Schristos
526b942a58Schristos #ifndef __GNU_MP__
536b942a58Schristos #define __GNU_MP__ 6
546b942a58Schristos
556b942a58Schristos #include <stddef.h> /* for size_t */
566b942a58Schristos #include <limits.h>
576b942a58Schristos
586b942a58Schristos /* Instantiated by configure. */
596b942a58Schristos #if ! defined (__GMP_WITHIN_CONFIGURE)
606b942a58Schristos #define _LONG_LONG_LIMB 1
616b942a58Schristos #define __GMP_LIBGMP_DLL 0
626b942a58Schristos #endif
636b942a58Schristos
646b942a58Schristos
656b942a58Schristos /* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in
666b942a58Schristos all other circumstances.
676b942a58Schristos
686b942a58Schristos When compiling objects for libgmp, __GMP_DECLSPEC is an export directive,
696b942a58Schristos or when compiling for an application it's an import directive. The two
706b942a58Schristos cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles
716b942a58Schristos (and not defined from an application).
726b942a58Schristos
736b942a58Schristos __GMP_DECLSPEC_XX is similarly used for libgmpxx. __GMP_WITHIN_GMPXX
746b942a58Schristos indicates when building libgmpxx, and in that case libgmpxx functions are
756b942a58Schristos exports, but libgmp functions which might get called are imports.
766b942a58Schristos
776b942a58Schristos Libtool DLL_EXPORT define is not used.
786b942a58Schristos
796b942a58Schristos There's no attempt to support GMP built both static and DLL. Doing so
806b942a58Schristos would mean applications would have to tell us which of the two is going
816b942a58Schristos to be used when linking, and that seems very tedious and error prone if
826b942a58Schristos using GMP by hand, and equally tedious from a package since autoconf and
836b942a58Schristos automake don't give much help.
846b942a58Schristos
856b942a58Schristos __GMP_DECLSPEC is required on all documented global functions and
866b942a58Schristos variables, the various internals in gmp-impl.h etc can be left unadorned.
876b942a58Schristos But internals used by the test programs or speed measuring programs
886b942a58Schristos should have __GMP_DECLSPEC, and certainly constants or variables must
896b942a58Schristos have it or the wrong address will be resolved.
906b942a58Schristos
916b942a58Schristos In gcc __declspec can go at either the start or end of a prototype.
926b942a58Schristos
936b942a58Schristos In Microsoft C __declspec must go at the start, or after the type like
946b942a58Schristos void __declspec(...) *foo()". There's no __dllexport or anything to
956b942a58Schristos guard against someone foolish #defining dllexport. _export used to be
966b942a58Schristos available, but no longer.
976b942a58Schristos
986b942a58Schristos In Borland C _export still exists, but needs to go after the type, like
996b942a58Schristos "void _export foo();". Would have to change the __GMP_DECLSPEC syntax to
1006b942a58Schristos make use of that. Probably more trouble than it's worth. */
1016b942a58Schristos
1026b942a58Schristos #if defined (__GNUC__)
1036b942a58Schristos #define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__)
1046b942a58Schristos #define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__)
1056b942a58Schristos #endif
1066b942a58Schristos #if defined (_MSC_VER) || defined (__BORLANDC__)
1076b942a58Schristos #define __GMP_DECLSPEC_EXPORT __declspec(dllexport)
1086b942a58Schristos #define __GMP_DECLSPEC_IMPORT __declspec(dllimport)
1096b942a58Schristos #endif
1106b942a58Schristos #ifdef __WATCOMC__
1116b942a58Schristos #define __GMP_DECLSPEC_EXPORT __export
1126b942a58Schristos #define __GMP_DECLSPEC_IMPORT __import
1136b942a58Schristos #endif
1146b942a58Schristos #ifdef __IBMC__
1156b942a58Schristos #define __GMP_DECLSPEC_EXPORT _Export
1166b942a58Schristos #define __GMP_DECLSPEC_IMPORT _Import
1176b942a58Schristos #endif
1186b942a58Schristos
1196b942a58Schristos #if __GMP_LIBGMP_DLL
1206b942a58Schristos #ifdef __GMP_WITHIN_GMP
1216b942a58Schristos /* compiling to go into a DLL libgmp */
1226b942a58Schristos #define __GMP_DECLSPEC __GMP_DECLSPEC_EXPORT
1236b942a58Schristos #else
1246b942a58Schristos /* compiling to go into an application which will link to a DLL libgmp */
1256b942a58Schristos #define __GMP_DECLSPEC __GMP_DECLSPEC_IMPORT
1266b942a58Schristos #endif
1276b942a58Schristos #else
1286b942a58Schristos /* all other cases */
1296b942a58Schristos #define __GMP_DECLSPEC
1306b942a58Schristos #endif
1316b942a58Schristos
1326b942a58Schristos
1336b942a58Schristos #ifdef __GMP_SHORT_LIMB
1346b942a58Schristos typedef unsigned int mp_limb_t;
1356b942a58Schristos typedef int mp_limb_signed_t;
1366b942a58Schristos #else
1376b942a58Schristos #ifdef _LONG_LONG_LIMB
1386b942a58Schristos typedef unsigned long long int mp_limb_t;
1396b942a58Schristos typedef long long int mp_limb_signed_t;
1406b942a58Schristos #else
1416b942a58Schristos typedef unsigned long int mp_limb_t;
1426b942a58Schristos typedef long int mp_limb_signed_t;
1436b942a58Schristos #endif
1446b942a58Schristos #endif
1456b942a58Schristos typedef unsigned long int mp_bitcnt_t;
1466b942a58Schristos
1476b942a58Schristos /* For reference, note that the name __mpz_struct gets into C++ mangled
1486b942a58Schristos function names, which means although the "__" suggests an internal, we
1496b942a58Schristos must leave this name for binary compatibility. */
1506b942a58Schristos typedef struct
1516b942a58Schristos {
1526b942a58Schristos int _mp_alloc; /* Number of *limbs* allocated and pointed
1536b942a58Schristos to by the _mp_d field. */
1546b942a58Schristos int _mp_size; /* abs(_mp_size) is the number of limbs the
1556b942a58Schristos last field points to. If _mp_size is
1566b942a58Schristos negative this is a negative number. */
1576b942a58Schristos mp_limb_t *_mp_d; /* Pointer to the limbs. */
1586b942a58Schristos } __mpz_struct;
1596b942a58Schristos
1606b942a58Schristos #endif /* __GNU_MP__ */
1616b942a58Schristos
1626b942a58Schristos
1636b942a58Schristos typedef __mpz_struct MP_INT; /* gmp 1 source compatibility */
1646b942a58Schristos typedef __mpz_struct mpz_t[1];
1656b942a58Schristos
1666b942a58Schristos typedef mp_limb_t * mp_ptr;
1676b942a58Schristos typedef const mp_limb_t * mp_srcptr;
1686b942a58Schristos #if defined (_CRAY) && ! defined (_CRAYMPP)
1696b942a58Schristos /* plain `int' is much faster (48 bits) */
1706b942a58Schristos #define __GMP_MP_SIZE_T_INT 1
1716b942a58Schristos typedef int mp_size_t;
1726b942a58Schristos typedef int mp_exp_t;
1736b942a58Schristos #else
1746b942a58Schristos #define __GMP_MP_SIZE_T_INT 0
1756b942a58Schristos typedef long int mp_size_t;
1766b942a58Schristos typedef long int mp_exp_t;
1776b942a58Schristos #endif
1786b942a58Schristos
1796b942a58Schristos typedef struct
1806b942a58Schristos {
1816b942a58Schristos __mpz_struct _mp_num;
1826b942a58Schristos __mpz_struct _mp_den;
1836b942a58Schristos } __mpq_struct;
1846b942a58Schristos
1856b942a58Schristos typedef __mpq_struct MP_RAT; /* gmp 1 source compatibility */
1866b942a58Schristos typedef __mpq_struct mpq_t[1];
1876b942a58Schristos
1886b942a58Schristos typedef struct
1896b942a58Schristos {
1906b942a58Schristos int _mp_prec; /* Max precision, in number of `mp_limb_t's.
1916b942a58Schristos Set by mpf_init and modified by
1926b942a58Schristos mpf_set_prec. The area pointed to by the
1936b942a58Schristos _mp_d field contains `prec' + 1 limbs. */
1946b942a58Schristos int _mp_size; /* abs(_mp_size) is the number of limbs the
1956b942a58Schristos last field points to. If _mp_size is
1966b942a58Schristos negative this is a negative number. */
1976b942a58Schristos mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */
1986b942a58Schristos mp_limb_t *_mp_d; /* Pointer to the limbs. */
1996b942a58Schristos } __mpf_struct;
2006b942a58Schristos
2016b942a58Schristos /* typedef __mpf_struct MP_FLOAT; */
2026b942a58Schristos typedef __mpf_struct mpf_t[1];
2036b942a58Schristos
2046b942a58Schristos /* Available random number generation algorithms. */
2056b942a58Schristos typedef enum
2066b942a58Schristos {
2076b942a58Schristos GMP_RAND_ALG_DEFAULT = 0,
2086b942a58Schristos GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */
2096b942a58Schristos } gmp_randalg_t;
2106b942a58Schristos
2116b942a58Schristos /* Random state struct. */
2126b942a58Schristos typedef struct
2136b942a58Schristos {
2146b942a58Schristos mpz_t _mp_seed; /* _mp_d member points to state of the generator. */
2156b942a58Schristos gmp_randalg_t _mp_alg; /* Currently unused. */
2166b942a58Schristos union {
2176b942a58Schristos void *_mp_lc; /* Pointer to function pointers structure. */
2186b942a58Schristos } _mp_algdata;
2196b942a58Schristos } __gmp_randstate_struct;
2206b942a58Schristos typedef __gmp_randstate_struct gmp_randstate_t[1];
2216b942a58Schristos
2226b942a58Schristos /* Types for function declarations in gmp files. */
2236b942a58Schristos /* ??? Should not pollute user name space with these ??? */
2246b942a58Schristos typedef const __mpz_struct *mpz_srcptr;
2256b942a58Schristos typedef __mpz_struct *mpz_ptr;
2266b942a58Schristos typedef const __mpf_struct *mpf_srcptr;
2276b942a58Schristos typedef __mpf_struct *mpf_ptr;
2286b942a58Schristos typedef const __mpq_struct *mpq_srcptr;
2296b942a58Schristos typedef __mpq_struct *mpq_ptr;
2306b942a58Schristos
2316b942a58Schristos
2326b942a58Schristos #if __GMP_LIBGMP_DLL
2336b942a58Schristos #ifdef __GMP_WITHIN_GMPXX
2346b942a58Schristos /* compiling to go into a DLL libgmpxx */
2356b942a58Schristos #define __GMP_DECLSPEC_XX __GMP_DECLSPEC_EXPORT
2366b942a58Schristos #else
2376b942a58Schristos /* compiling to go into a application which will link to a DLL libgmpxx */
2386b942a58Schristos #define __GMP_DECLSPEC_XX __GMP_DECLSPEC_IMPORT
2396b942a58Schristos #endif
2406b942a58Schristos #else
2416b942a58Schristos /* all other cases */
2426b942a58Schristos #define __GMP_DECLSPEC_XX
2436b942a58Schristos #endif
2446b942a58Schristos
2456b942a58Schristos
2466b942a58Schristos #ifndef __MPN
2476b942a58Schristos #define __MPN(x) __gmpn_##x
2486b942a58Schristos #endif
2496b942a58Schristos
2506b942a58Schristos /* For reference, "defined(EOF)" cannot be used here. In g++ 2.95.4,
2516b942a58Schristos <iostream> defines EOF but not FILE. */
2526b942a58Schristos #if defined (FILE) \
2536b942a58Schristos || defined (H_STDIO) \
2546b942a58Schristos || defined (_H_STDIO) /* AIX */ \
2556b942a58Schristos || defined (_STDIO_H) /* glibc, Sun, SCO */ \
2566b942a58Schristos || defined (_STDIO_H_) /* BSD, OSF */ \
2576b942a58Schristos || defined (__STDIO_H) /* Borland */ \
2586b942a58Schristos || defined (__STDIO_H__) /* IRIX */ \
2596b942a58Schristos || defined (_STDIO_INCLUDED) /* HPUX */ \
2606b942a58Schristos || defined (__dj_include_stdio_h_) /* DJGPP */ \
2616b942a58Schristos || defined (_FILE_DEFINED) /* Microsoft */ \
2626b942a58Schristos || defined (__STDIO__) /* Apple MPW MrC */ \
2636b942a58Schristos || defined (_MSL_STDIO_H) /* Metrowerks */ \
2646b942a58Schristos || defined (_STDIO_H_INCLUDED) /* QNX4 */ \
2656b942a58Schristos || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \
2666b942a58Schristos || defined (__STDIO_LOADED) /* VMS */ \
2676b942a58Schristos || defined (__DEFINED_FILE) /* musl */
2686b942a58Schristos #define _GMP_H_HAVE_FILE 1
2696b942a58Schristos #endif
2706b942a58Schristos
2716b942a58Schristos /* In ISO C, if a prototype involving "struct obstack *" is given without
2726b942a58Schristos that structure defined, then the struct is scoped down to just the
2736b942a58Schristos prototype, causing a conflict if it's subsequently defined for real. So
2746b942a58Schristos only give prototypes if we've got obstack.h. */
2756b942a58Schristos #if defined (_OBSTACK_H) /* glibc <obstack.h> */
2766b942a58Schristos #define _GMP_H_HAVE_OBSTACK 1
2776b942a58Schristos #endif
2786b942a58Schristos
2796b942a58Schristos /* The prototypes for gmp_vprintf etc are provided only if va_list is defined,
2806b942a58Schristos via an application having included <stdarg.h>. Usually va_list is a typedef
2816b942a58Schristos so can't be tested directly, but C99 specifies that va_start is a macro.
2826b942a58Schristos
2836b942a58Schristos <stdio.h> will define some sort of va_list for vprintf and vfprintf, but
2846b942a58Schristos let's not bother trying to use that since it's not standard and since
2856b942a58Schristos application uses for gmp_vprintf etc will almost certainly require the
2866b942a58Schristos whole <stdarg.h> anyway. */
2876b942a58Schristos
2886b942a58Schristos #ifdef va_start
2896b942a58Schristos #define _GMP_H_HAVE_VA_LIST 1
2906b942a58Schristos #endif
2916b942a58Schristos
2926b942a58Schristos /* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */
2936b942a58Schristos #if defined (__GNUC__) && defined (__GNUC_MINOR__)
2946b942a58Schristos #define __GMP_GNUC_PREREQ(maj, min) \
2956b942a58Schristos ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
2966b942a58Schristos #else
2976b942a58Schristos #define __GMP_GNUC_PREREQ(maj, min) 0
2986b942a58Schristos #endif
2996b942a58Schristos
3006b942a58Schristos /* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes". Basically
3016b942a58Schristos it means a function does nothing but examine its arguments and memory
3026b942a58Schristos (global or via arguments) to generate a return value, but changes nothing
3036b942a58Schristos and has no side-effects. __GMP_NO_ATTRIBUTE_CONST_PURE lets
3046b942a58Schristos tune/common.c etc turn this off when trying to write timing loops. */
3056b942a58Schristos #if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE)
3066b942a58Schristos #define __GMP_ATTRIBUTE_PURE __attribute__ ((__pure__))
3076b942a58Schristos #else
3086b942a58Schristos #define __GMP_ATTRIBUTE_PURE
3096b942a58Schristos #endif
3106b942a58Schristos
3116b942a58Schristos
3126b942a58Schristos /* __GMP_CAST allows us to use static_cast in C++, so our macros are clean
3136b942a58Schristos to "g++ -Wold-style-cast".
3146b942a58Schristos
3156b942a58Schristos Casts in "extern inline" code within an extern "C" block don't induce
3166b942a58Schristos these warnings, so __GMP_CAST only needs to be used on documented
3176b942a58Schristos macros. */
3186b942a58Schristos
3196b942a58Schristos #ifdef __cplusplus
3206b942a58Schristos #define __GMP_CAST(type, expr) (static_cast<type> (expr))
3216b942a58Schristos #else
3226b942a58Schristos #define __GMP_CAST(type, expr) ((type) (expr))
3236b942a58Schristos #endif
3246b942a58Schristos
3256b942a58Schristos
3266b942a58Schristos /* An empty "throw ()" means the function doesn't throw any C++ exceptions,
3276b942a58Schristos this can save some stack frame info in applications.
3286b942a58Schristos
3296b942a58Schristos Currently it's given only on functions which never divide-by-zero etc,
3306b942a58Schristos don't allocate memory, and are expected to never need to allocate memory.
3316b942a58Schristos This leaves open the possibility of a C++ throw from a future GMP
3326b942a58Schristos exceptions scheme.
3336b942a58Schristos
3346b942a58Schristos mpz_set_ui etc are omitted to leave open the lazy allocation scheme
3356b942a58Schristos described in doc/tasks.html. mpz_get_d etc are omitted to leave open
3366b942a58Schristos exceptions for float overflows.
3376b942a58Schristos
3386b942a58Schristos Note that __GMP_NOTHROW must be given on any inlines the same as on their
3396b942a58Schristos prototypes (for g++ at least, where they're used together). Note also
3406b942a58Schristos that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like
3416b942a58Schristos __GMP_ATTRIBUTE_PURE. */
3426b942a58Schristos
3436b942a58Schristos #if defined (__cplusplus)
3446b942a58Schristos #if __cplusplus >= 201103L
3456b942a58Schristos #define __GMP_NOTHROW noexcept
3466b942a58Schristos #else
3476b942a58Schristos #define __GMP_NOTHROW throw ()
3486b942a58Schristos #endif
3496b942a58Schristos #else
3506b942a58Schristos #define __GMP_NOTHROW
3516b942a58Schristos #endif
3526b942a58Schristos
3536b942a58Schristos
3546b942a58Schristos /* PORTME: What other compilers have a useful "extern inline"? "static
3556b942a58Schristos inline" would be an acceptable substitute if the compiler (or linker)
3566b942a58Schristos discards unused statics. */
3576b942a58Schristos
3586b942a58Schristos /* gcc has __inline__ in all modes, including strict ansi. Give a prototype
3596b942a58Schristos for an inline too, so as to correctly specify "dllimport" on windows, in
3606b942a58Schristos case the function is called rather than inlined.
3616b942a58Schristos GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
3626b942a58Schristos inline semantics, unless -fgnu89-inline is used. */
3636b942a58Schristos #ifdef __GNUC__
364*119a1bddSmrg #if (defined __GNUC_STDC_INLINE__) || \
365*119a1bddSmrg (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) || (__GNUC__ > 4)
3666b942a58Schristos #define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__))
3676b942a58Schristos #endif
3686b942a58Schristos #define __GMP_INLINE_PROTOTYPES 1
3696b942a58Schristos #endif
3706b942a58Schristos
3716b942a58Schristos /* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1
3726b942a58Schristos strict ANSI mode. Inlining is done even when not optimizing (ie. -O0
3736b942a58Schristos mode, which is the default), but an unnecessary local copy of foo is
3746b942a58Schristos emitted unless -O is used. "extern __inline" is accepted, but the
3756b942a58Schristos "extern" appears to be ignored, ie. it becomes a plain global function
3766b942a58Schristos but which is inlined within its file. Don't know if all old versions of
3776b942a58Schristos DEC C supported __inline, but as a start let's do the right thing for
3786b942a58Schristos current versions. */
3796b942a58Schristos #ifdef __DECC
3806b942a58Schristos #define __GMP_EXTERN_INLINE static __inline
3816b942a58Schristos #endif
3826b942a58Schristos
3836b942a58Schristos /* SCO OpenUNIX 8 cc supports "static inline foo()" but not in -Xc strict
3846b942a58Schristos ANSI mode (__STDC__ is 1 in that mode). Inlining only actually takes
3856b942a58Schristos place under -O. Without -O "foo" seems to be emitted whether it's used
3866b942a58Schristos or not, which is wasteful. "extern inline foo()" isn't useful, the
3876b942a58Schristos "extern" is apparently ignored, so foo is inlined if possible but also
3886b942a58Schristos emitted as a global, which causes multiple definition errors when
3896b942a58Schristos building a shared libgmp. */
3906b942a58Schristos #ifdef __SCO_VERSION__
3916b942a58Schristos #if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \
3926b942a58Schristos && ! defined (__GMP_EXTERN_INLINE)
3936b942a58Schristos #define __GMP_EXTERN_INLINE static inline
3946b942a58Schristos #endif
3956b942a58Schristos #endif
3966b942a58Schristos
3976b942a58Schristos /* Microsoft's C compiler accepts __inline */
3986b942a58Schristos #ifdef _MSC_VER
3996b942a58Schristos #define __GMP_EXTERN_INLINE __inline
4006b942a58Schristos #endif
4016b942a58Schristos
4026b942a58Schristos /* Recent enough Sun C compilers want "inline" */
4036b942a58Schristos #if defined (__SUNPRO_C) && __SUNPRO_C >= 0x560 \
4046b942a58Schristos && ! defined (__GMP_EXTERN_INLINE)
4056b942a58Schristos #define __GMP_EXTERN_INLINE inline
4066b942a58Schristos #endif
4076b942a58Schristos
4086b942a58Schristos /* Somewhat older Sun C compilers want "static inline" */
4096b942a58Schristos #if defined (__SUNPRO_C) && __SUNPRO_C >= 0x540 \
4106b942a58Schristos && ! defined (__GMP_EXTERN_INLINE)
4116b942a58Schristos #define __GMP_EXTERN_INLINE static inline
4126b942a58Schristos #endif
4136b942a58Schristos
4146b942a58Schristos
4156b942a58Schristos /* C++ always has "inline" and since it's a normal feature the linker should
4166b942a58Schristos discard duplicate non-inlined copies, or if it doesn't then that's a
4176b942a58Schristos problem for everyone, not just GMP. */
4186b942a58Schristos #if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE)
4196b942a58Schristos #define __GMP_EXTERN_INLINE inline
4206b942a58Schristos #endif
4216b942a58Schristos
4226b942a58Schristos /* Don't do any inlining within a configure run, since if the compiler ends
4236b942a58Schristos up emitting copies of the code into the object file it can end up
4246b942a58Schristos demanding the various support routines (like mpn_popcount) for linking,
4256b942a58Schristos making the "alloca" test and perhaps others fail. And on hppa ia64 a
4266b942a58Schristos pre-release gcc 3.2 was seen not respecting the "extern" in "extern
4276b942a58Schristos __inline__", triggering this problem too. */
4286b942a58Schristos #if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE
4296b942a58Schristos #undef __GMP_EXTERN_INLINE
4306b942a58Schristos #endif
4316b942a58Schristos
4326b942a58Schristos /* By default, don't give a prototype when there's going to be an inline
4336b942a58Schristos version. Note in particular that Cray C++ objects to the combination of
4346b942a58Schristos prototype and inline. */
4356b942a58Schristos #ifdef __GMP_EXTERN_INLINE
4366b942a58Schristos #ifndef __GMP_INLINE_PROTOTYPES
4376b942a58Schristos #define __GMP_INLINE_PROTOTYPES 0
4386b942a58Schristos #endif
4396b942a58Schristos #else
4406b942a58Schristos #define __GMP_INLINE_PROTOTYPES 1
4416b942a58Schristos #endif
4426b942a58Schristos
4436b942a58Schristos
4446b942a58Schristos #define __GMP_ABS(x) ((x) >= 0 ? (x) : -(x))
4456b942a58Schristos #define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i))
4466b942a58Schristos
4476b942a58Schristos
4486b942a58Schristos /* __builtin_expect is in gcc 3.0, and not in 2.95. */
4496b942a58Schristos #if __GMP_GNUC_PREREQ (3,0)
4506b942a58Schristos #define __GMP_LIKELY(cond) __builtin_expect ((cond) != 0, 1)
4516b942a58Schristos #define __GMP_UNLIKELY(cond) __builtin_expect ((cond) != 0, 0)
4526b942a58Schristos #else
4536b942a58Schristos #define __GMP_LIKELY(cond) (cond)
4546b942a58Schristos #define __GMP_UNLIKELY(cond) (cond)
4556b942a58Schristos #endif
4566b942a58Schristos
4576b942a58Schristos #ifdef _CRAY
4586b942a58Schristos #define __GMP_CRAY_Pragma(str) _Pragma (str)
4596b942a58Schristos #else
4606b942a58Schristos #define __GMP_CRAY_Pragma(str)
4616b942a58Schristos #endif
4626b942a58Schristos
4636b942a58Schristos
4646b942a58Schristos /* Allow direct user access to numerator and denominator of an mpq_t object. */
4656b942a58Schristos #define mpq_numref(Q) (&((Q)->_mp_num))
4666b942a58Schristos #define mpq_denref(Q) (&((Q)->_mp_den))
4676b942a58Schristos
4686b942a58Schristos
4696b942a58Schristos #if defined (__cplusplus)
4706b942a58Schristos extern "C" {
4716b942a58Schristos using std::FILE;
4726b942a58Schristos #endif
4736b942a58Schristos
4746b942a58Schristos #define mp_set_memory_functions __gmp_set_memory_functions
4756b942a58Schristos __GMP_DECLSPEC void mp_set_memory_functions (void *(*) (size_t),
4766b942a58Schristos void *(*) (void *, size_t, size_t),
4776b942a58Schristos void (*) (void *, size_t)) __GMP_NOTHROW;
4786b942a58Schristos
4796b942a58Schristos #define mp_get_memory_functions __gmp_get_memory_functions
4806b942a58Schristos __GMP_DECLSPEC void mp_get_memory_functions (void *(**) (size_t),
4816b942a58Schristos void *(**) (void *, size_t, size_t),
4826b942a58Schristos void (**) (void *, size_t)) __GMP_NOTHROW;
4836b942a58Schristos
4846b942a58Schristos #define mp_bits_per_limb __gmp_bits_per_limb
4856b942a58Schristos __GMP_DECLSPEC extern const int mp_bits_per_limb;
4866b942a58Schristos
4876b942a58Schristos #define gmp_errno __gmp_errno
4886b942a58Schristos __GMP_DECLSPEC extern int gmp_errno;
4896b942a58Schristos
4906b942a58Schristos #define gmp_version __gmp_version
4916b942a58Schristos __GMP_DECLSPEC extern const char * const gmp_version;
4926b942a58Schristos
4936b942a58Schristos
4946b942a58Schristos /**************** Random number routines. ****************/
4956b942a58Schristos
4966b942a58Schristos /* obsolete */
4976b942a58Schristos #define gmp_randinit __gmp_randinit
4986b942a58Schristos __GMP_DECLSPEC void gmp_randinit (gmp_randstate_t, gmp_randalg_t, ...);
4996b942a58Schristos
5006b942a58Schristos #define gmp_randinit_default __gmp_randinit_default
5016b942a58Schristos __GMP_DECLSPEC void gmp_randinit_default (gmp_randstate_t);
5026b942a58Schristos
5036b942a58Schristos #define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp
5046b942a58Schristos __GMP_DECLSPEC void gmp_randinit_lc_2exp (gmp_randstate_t, mpz_srcptr, unsigned long int, mp_bitcnt_t);
5056b942a58Schristos
5066b942a58Schristos #define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size
5076b942a58Schristos __GMP_DECLSPEC int gmp_randinit_lc_2exp_size (gmp_randstate_t, mp_bitcnt_t);
5086b942a58Schristos
5096b942a58Schristos #define gmp_randinit_mt __gmp_randinit_mt
5106b942a58Schristos __GMP_DECLSPEC void gmp_randinit_mt (gmp_randstate_t);
5116b942a58Schristos
5126b942a58Schristos #define gmp_randinit_set __gmp_randinit_set
5136b942a58Schristos __GMP_DECLSPEC void gmp_randinit_set (gmp_randstate_t, const __gmp_randstate_struct *);
5146b942a58Schristos
5156b942a58Schristos #define gmp_randseed __gmp_randseed
5166b942a58Schristos __GMP_DECLSPEC void gmp_randseed (gmp_randstate_t, mpz_srcptr);
5176b942a58Schristos
5186b942a58Schristos #define gmp_randseed_ui __gmp_randseed_ui
5196b942a58Schristos __GMP_DECLSPEC void gmp_randseed_ui (gmp_randstate_t, unsigned long int);
5206b942a58Schristos
5216b942a58Schristos #define gmp_randclear __gmp_randclear
5226b942a58Schristos __GMP_DECLSPEC void gmp_randclear (gmp_randstate_t);
5236b942a58Schristos
5246b942a58Schristos #define gmp_urandomb_ui __gmp_urandomb_ui
5256b942a58Schristos __GMP_DECLSPEC unsigned long gmp_urandomb_ui (gmp_randstate_t, unsigned long);
5266b942a58Schristos
5276b942a58Schristos #define gmp_urandomm_ui __gmp_urandomm_ui
5286b942a58Schristos __GMP_DECLSPEC unsigned long gmp_urandomm_ui (gmp_randstate_t, unsigned long);
5296b942a58Schristos
5306b942a58Schristos
5316b942a58Schristos /**************** Formatted output routines. ****************/
5326b942a58Schristos
5336b942a58Schristos #define gmp_asprintf __gmp_asprintf
5346b942a58Schristos __GMP_DECLSPEC int gmp_asprintf (char **, const char *, ...);
5356b942a58Schristos
5366b942a58Schristos #define gmp_fprintf __gmp_fprintf
5376b942a58Schristos #ifdef _GMP_H_HAVE_FILE
5386b942a58Schristos __GMP_DECLSPEC int gmp_fprintf (FILE *, const char *, ...);
5396b942a58Schristos #endif
5406b942a58Schristos
5416b942a58Schristos #define gmp_obstack_printf __gmp_obstack_printf
5426b942a58Schristos #if defined (_GMP_H_HAVE_OBSTACK)
5436b942a58Schristos __GMP_DECLSPEC int gmp_obstack_printf (struct obstack *, const char *, ...);
5446b942a58Schristos #endif
5456b942a58Schristos
5466b942a58Schristos #define gmp_obstack_vprintf __gmp_obstack_vprintf
5476b942a58Schristos #if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST)
5486b942a58Schristos __GMP_DECLSPEC int gmp_obstack_vprintf (struct obstack *, const char *, va_list);
5496b942a58Schristos #endif
5506b942a58Schristos
5516b942a58Schristos #define gmp_printf __gmp_printf
5526b942a58Schristos __GMP_DECLSPEC int gmp_printf (const char *, ...);
5536b942a58Schristos
5546b942a58Schristos #define gmp_snprintf __gmp_snprintf
5556b942a58Schristos __GMP_DECLSPEC int gmp_snprintf (char *, size_t, const char *, ...);
5566b942a58Schristos
5576b942a58Schristos #define gmp_sprintf __gmp_sprintf
5586b942a58Schristos __GMP_DECLSPEC int gmp_sprintf (char *, const char *, ...);
5596b942a58Schristos
5606b942a58Schristos #define gmp_vasprintf __gmp_vasprintf
5616b942a58Schristos #if defined (_GMP_H_HAVE_VA_LIST)
5626b942a58Schristos __GMP_DECLSPEC int gmp_vasprintf (char **, const char *, va_list);
5636b942a58Schristos #endif
5646b942a58Schristos
5656b942a58Schristos #define gmp_vfprintf __gmp_vfprintf
5666b942a58Schristos #if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)
5676b942a58Schristos __GMP_DECLSPEC int gmp_vfprintf (FILE *, const char *, va_list);
5686b942a58Schristos #endif
5696b942a58Schristos
5706b942a58Schristos #define gmp_vprintf __gmp_vprintf
5716b942a58Schristos #if defined (_GMP_H_HAVE_VA_LIST)
5726b942a58Schristos __GMP_DECLSPEC int gmp_vprintf (const char *, va_list);
5736b942a58Schristos #endif
5746b942a58Schristos
5756b942a58Schristos #define gmp_vsnprintf __gmp_vsnprintf
5766b942a58Schristos #if defined (_GMP_H_HAVE_VA_LIST)
5776b942a58Schristos __GMP_DECLSPEC int gmp_vsnprintf (char *, size_t, const char *, va_list);
5786b942a58Schristos #endif
5796b942a58Schristos
5806b942a58Schristos #define gmp_vsprintf __gmp_vsprintf
5816b942a58Schristos #if defined (_GMP_H_HAVE_VA_LIST)
5826b942a58Schristos __GMP_DECLSPEC int gmp_vsprintf (char *, const char *, va_list);
5836b942a58Schristos #endif
5846b942a58Schristos
5856b942a58Schristos
5866b942a58Schristos /**************** Formatted input routines. ****************/
5876b942a58Schristos
5886b942a58Schristos #define gmp_fscanf __gmp_fscanf
5896b942a58Schristos #ifdef _GMP_H_HAVE_FILE
5906b942a58Schristos __GMP_DECLSPEC int gmp_fscanf (FILE *, const char *, ...);
5916b942a58Schristos #endif
5926b942a58Schristos
5936b942a58Schristos #define gmp_scanf __gmp_scanf
5946b942a58Schristos __GMP_DECLSPEC int gmp_scanf (const char *, ...);
5956b942a58Schristos
5966b942a58Schristos #define gmp_sscanf __gmp_sscanf
5976b942a58Schristos __GMP_DECLSPEC int gmp_sscanf (const char *, const char *, ...);
5986b942a58Schristos
5996b942a58Schristos #define gmp_vfscanf __gmp_vfscanf
6006b942a58Schristos #if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)
6016b942a58Schristos __GMP_DECLSPEC int gmp_vfscanf (FILE *, const char *, va_list);
6026b942a58Schristos #endif
6036b942a58Schristos
6046b942a58Schristos #define gmp_vscanf __gmp_vscanf
6056b942a58Schristos #if defined (_GMP_H_HAVE_VA_LIST)
6066b942a58Schristos __GMP_DECLSPEC int gmp_vscanf (const char *, va_list);
6076b942a58Schristos #endif
6086b942a58Schristos
6096b942a58Schristos #define gmp_vsscanf __gmp_vsscanf
6106b942a58Schristos #if defined (_GMP_H_HAVE_VA_LIST)
6116b942a58Schristos __GMP_DECLSPEC int gmp_vsscanf (const char *, const char *, va_list);
6126b942a58Schristos #endif
6136b942a58Schristos
6146b942a58Schristos
6156b942a58Schristos /**************** Integer (i.e. Z) routines. ****************/
6166b942a58Schristos
6176b942a58Schristos #define _mpz_realloc __gmpz_realloc
6186b942a58Schristos #define mpz_realloc __gmpz_realloc
6196b942a58Schristos __GMP_DECLSPEC void *_mpz_realloc (mpz_ptr, mp_size_t);
6206b942a58Schristos
6216b942a58Schristos #define mpz_abs __gmpz_abs
6226b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs)
6236b942a58Schristos __GMP_DECLSPEC void mpz_abs (mpz_ptr, mpz_srcptr);
6246b942a58Schristos #endif
6256b942a58Schristos
6266b942a58Schristos #define mpz_add __gmpz_add
6276b942a58Schristos __GMP_DECLSPEC void mpz_add (mpz_ptr, mpz_srcptr, mpz_srcptr);
6286b942a58Schristos
6296b942a58Schristos #define mpz_add_ui __gmpz_add_ui
6306b942a58Schristos __GMP_DECLSPEC void mpz_add_ui (mpz_ptr, mpz_srcptr, unsigned long int);
6316b942a58Schristos
6326b942a58Schristos #define mpz_addmul __gmpz_addmul
6336b942a58Schristos __GMP_DECLSPEC void mpz_addmul (mpz_ptr, mpz_srcptr, mpz_srcptr);
6346b942a58Schristos
6356b942a58Schristos #define mpz_addmul_ui __gmpz_addmul_ui
6366b942a58Schristos __GMP_DECLSPEC void mpz_addmul_ui (mpz_ptr, mpz_srcptr, unsigned long int);
6376b942a58Schristos
6386b942a58Schristos #define mpz_and __gmpz_and
6396b942a58Schristos __GMP_DECLSPEC void mpz_and (mpz_ptr, mpz_srcptr, mpz_srcptr);
6406b942a58Schristos
6416b942a58Schristos #define mpz_array_init __gmpz_array_init
6426b942a58Schristos __GMP_DECLSPEC void mpz_array_init (mpz_ptr, mp_size_t, mp_size_t);
6436b942a58Schristos
6446b942a58Schristos #define mpz_bin_ui __gmpz_bin_ui
6456b942a58Schristos __GMP_DECLSPEC void mpz_bin_ui (mpz_ptr, mpz_srcptr, unsigned long int);
6466b942a58Schristos
6476b942a58Schristos #define mpz_bin_uiui __gmpz_bin_uiui
6486b942a58Schristos __GMP_DECLSPEC void mpz_bin_uiui (mpz_ptr, unsigned long int, unsigned long int);
6496b942a58Schristos
6506b942a58Schristos #define mpz_cdiv_q __gmpz_cdiv_q
6516b942a58Schristos __GMP_DECLSPEC void mpz_cdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);
6526b942a58Schristos
6536b942a58Schristos #define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp
6546b942a58Schristos __GMP_DECLSPEC void mpz_cdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);
6556b942a58Schristos
6566b942a58Schristos #define mpz_cdiv_q_ui __gmpz_cdiv_q_ui
6576b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);
6586b942a58Schristos
6596b942a58Schristos #define mpz_cdiv_qr __gmpz_cdiv_qr
6606b942a58Schristos __GMP_DECLSPEC void mpz_cdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);
6616b942a58Schristos
6626b942a58Schristos #define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui
6636b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_cdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);
6646b942a58Schristos
6656b942a58Schristos #define mpz_cdiv_r __gmpz_cdiv_r
6666b942a58Schristos __GMP_DECLSPEC void mpz_cdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);
6676b942a58Schristos
6686b942a58Schristos #define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp
6696b942a58Schristos __GMP_DECLSPEC void mpz_cdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);
6706b942a58Schristos
6716b942a58Schristos #define mpz_cdiv_r_ui __gmpz_cdiv_r_ui
6726b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_cdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);
6736b942a58Schristos
6746b942a58Schristos #define mpz_cdiv_ui __gmpz_cdiv_ui
6756b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_cdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;
6766b942a58Schristos
6776b942a58Schristos #define mpz_clear __gmpz_clear
6786b942a58Schristos __GMP_DECLSPEC void mpz_clear (mpz_ptr);
6796b942a58Schristos
6806b942a58Schristos #define mpz_clears __gmpz_clears
6816b942a58Schristos __GMP_DECLSPEC void mpz_clears (mpz_ptr, ...);
6826b942a58Schristos
6836b942a58Schristos #define mpz_clrbit __gmpz_clrbit
6846b942a58Schristos __GMP_DECLSPEC void mpz_clrbit (mpz_ptr, mp_bitcnt_t);
6856b942a58Schristos
6866b942a58Schristos #define mpz_cmp __gmpz_cmp
6876b942a58Schristos __GMP_DECLSPEC int mpz_cmp (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
6886b942a58Schristos
6896b942a58Schristos #define mpz_cmp_d __gmpz_cmp_d
6906b942a58Schristos __GMP_DECLSPEC int mpz_cmp_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE;
6916b942a58Schristos
6926b942a58Schristos #define _mpz_cmp_si __gmpz_cmp_si
6936b942a58Schristos __GMP_DECLSPEC int _mpz_cmp_si (mpz_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
6946b942a58Schristos
6956b942a58Schristos #define _mpz_cmp_ui __gmpz_cmp_ui
6966b942a58Schristos __GMP_DECLSPEC int _mpz_cmp_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
6976b942a58Schristos
6986b942a58Schristos #define mpz_cmpabs __gmpz_cmpabs
6996b942a58Schristos __GMP_DECLSPEC int mpz_cmpabs (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
7006b942a58Schristos
7016b942a58Schristos #define mpz_cmpabs_d __gmpz_cmpabs_d
7026b942a58Schristos __GMP_DECLSPEC int mpz_cmpabs_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE;
7036b942a58Schristos
7046b942a58Schristos #define mpz_cmpabs_ui __gmpz_cmpabs_ui
7056b942a58Schristos __GMP_DECLSPEC int mpz_cmpabs_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
7066b942a58Schristos
7076b942a58Schristos #define mpz_com __gmpz_com
7086b942a58Schristos __GMP_DECLSPEC void mpz_com (mpz_ptr, mpz_srcptr);
7096b942a58Schristos
7106b942a58Schristos #define mpz_combit __gmpz_combit
7116b942a58Schristos __GMP_DECLSPEC void mpz_combit (mpz_ptr, mp_bitcnt_t);
7126b942a58Schristos
7136b942a58Schristos #define mpz_congruent_p __gmpz_congruent_p
7146b942a58Schristos __GMP_DECLSPEC int mpz_congruent_p (mpz_srcptr, mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;
7156b942a58Schristos
7166b942a58Schristos #define mpz_congruent_2exp_p __gmpz_congruent_2exp_p
7176b942a58Schristos __GMP_DECLSPEC int mpz_congruent_2exp_p (mpz_srcptr, mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
7186b942a58Schristos
7196b942a58Schristos #define mpz_congruent_ui_p __gmpz_congruent_ui_p
7206b942a58Schristos __GMP_DECLSPEC int mpz_congruent_ui_p (mpz_srcptr, unsigned long, unsigned long) __GMP_ATTRIBUTE_PURE;
7216b942a58Schristos
7226b942a58Schristos #define mpz_divexact __gmpz_divexact
7236b942a58Schristos __GMP_DECLSPEC void mpz_divexact (mpz_ptr, mpz_srcptr, mpz_srcptr);
7246b942a58Schristos
7256b942a58Schristos #define mpz_divexact_ui __gmpz_divexact_ui
7266b942a58Schristos __GMP_DECLSPEC void mpz_divexact_ui (mpz_ptr, mpz_srcptr, unsigned long);
7276b942a58Schristos
7286b942a58Schristos #define mpz_divisible_p __gmpz_divisible_p
7296b942a58Schristos __GMP_DECLSPEC int mpz_divisible_p (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;
7306b942a58Schristos
7316b942a58Schristos #define mpz_divisible_ui_p __gmpz_divisible_ui_p
7326b942a58Schristos __GMP_DECLSPEC int mpz_divisible_ui_p (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE;
7336b942a58Schristos
7346b942a58Schristos #define mpz_divisible_2exp_p __gmpz_divisible_2exp_p
7356b942a58Schristos __GMP_DECLSPEC int mpz_divisible_2exp_p (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
7366b942a58Schristos
7376b942a58Schristos #define mpz_dump __gmpz_dump
7386b942a58Schristos __GMP_DECLSPEC void mpz_dump (mpz_srcptr);
7396b942a58Schristos
7406b942a58Schristos #define mpz_export __gmpz_export
7416b942a58Schristos __GMP_DECLSPEC void *mpz_export (void *, size_t *, int, size_t, int, size_t, mpz_srcptr);
7426b942a58Schristos
7436b942a58Schristos #define mpz_fac_ui __gmpz_fac_ui
7446b942a58Schristos __GMP_DECLSPEC void mpz_fac_ui (mpz_ptr, unsigned long int);
7456b942a58Schristos
7466b942a58Schristos #define mpz_2fac_ui __gmpz_2fac_ui
7476b942a58Schristos __GMP_DECLSPEC void mpz_2fac_ui (mpz_ptr, unsigned long int);
7486b942a58Schristos
7496b942a58Schristos #define mpz_mfac_uiui __gmpz_mfac_uiui
7506b942a58Schristos __GMP_DECLSPEC void mpz_mfac_uiui (mpz_ptr, unsigned long int, unsigned long int);
7516b942a58Schristos
7526b942a58Schristos #define mpz_primorial_ui __gmpz_primorial_ui
7536b942a58Schristos __GMP_DECLSPEC void mpz_primorial_ui (mpz_ptr, unsigned long int);
7546b942a58Schristos
7556b942a58Schristos #define mpz_fdiv_q __gmpz_fdiv_q
7566b942a58Schristos __GMP_DECLSPEC void mpz_fdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);
7576b942a58Schristos
7586b942a58Schristos #define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp
7596b942a58Schristos __GMP_DECLSPEC void mpz_fdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);
7606b942a58Schristos
7616b942a58Schristos #define mpz_fdiv_q_ui __gmpz_fdiv_q_ui
7626b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_fdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);
7636b942a58Schristos
7646b942a58Schristos #define mpz_fdiv_qr __gmpz_fdiv_qr
7656b942a58Schristos __GMP_DECLSPEC void mpz_fdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);
7666b942a58Schristos
7676b942a58Schristos #define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui
7686b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_fdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);
7696b942a58Schristos
7706b942a58Schristos #define mpz_fdiv_r __gmpz_fdiv_r
7716b942a58Schristos __GMP_DECLSPEC void mpz_fdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);
7726b942a58Schristos
7736b942a58Schristos #define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp
7746b942a58Schristos __GMP_DECLSPEC void mpz_fdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);
7756b942a58Schristos
7766b942a58Schristos #define mpz_fdiv_r_ui __gmpz_fdiv_r_ui
7776b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_fdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);
7786b942a58Schristos
7796b942a58Schristos #define mpz_fdiv_ui __gmpz_fdiv_ui
7806b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_fdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;
7816b942a58Schristos
7826b942a58Schristos #define mpz_fib_ui __gmpz_fib_ui
7836b942a58Schristos __GMP_DECLSPEC void mpz_fib_ui (mpz_ptr, unsigned long int);
7846b942a58Schristos
7856b942a58Schristos #define mpz_fib2_ui __gmpz_fib2_ui
7866b942a58Schristos __GMP_DECLSPEC void mpz_fib2_ui (mpz_ptr, mpz_ptr, unsigned long int);
7876b942a58Schristos
7886b942a58Schristos #define mpz_fits_sint_p __gmpz_fits_sint_p
7896b942a58Schristos __GMP_DECLSPEC int mpz_fits_sint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
7906b942a58Schristos
7916b942a58Schristos #define mpz_fits_slong_p __gmpz_fits_slong_p
7926b942a58Schristos __GMP_DECLSPEC int mpz_fits_slong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
7936b942a58Schristos
7946b942a58Schristos #define mpz_fits_sshort_p __gmpz_fits_sshort_p
7956b942a58Schristos __GMP_DECLSPEC int mpz_fits_sshort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
7966b942a58Schristos
7976b942a58Schristos #define mpz_fits_uint_p __gmpz_fits_uint_p
7986b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p)
7996b942a58Schristos __GMP_DECLSPEC int mpz_fits_uint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
8006b942a58Schristos #endif
8016b942a58Schristos
8026b942a58Schristos #define mpz_fits_ulong_p __gmpz_fits_ulong_p
8036b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p)
8046b942a58Schristos __GMP_DECLSPEC int mpz_fits_ulong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
8056b942a58Schristos #endif
8066b942a58Schristos
8076b942a58Schristos #define mpz_fits_ushort_p __gmpz_fits_ushort_p
8086b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p)
8096b942a58Schristos __GMP_DECLSPEC int mpz_fits_ushort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
8106b942a58Schristos #endif
8116b942a58Schristos
8126b942a58Schristos #define mpz_gcd __gmpz_gcd
8136b942a58Schristos __GMP_DECLSPEC void mpz_gcd (mpz_ptr, mpz_srcptr, mpz_srcptr);
8146b942a58Schristos
8156b942a58Schristos #define mpz_gcd_ui __gmpz_gcd_ui
8166b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_gcd_ui (mpz_ptr, mpz_srcptr, unsigned long int);
8176b942a58Schristos
8186b942a58Schristos #define mpz_gcdext __gmpz_gcdext
8196b942a58Schristos __GMP_DECLSPEC void mpz_gcdext (mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);
8206b942a58Schristos
8216b942a58Schristos #define mpz_get_d __gmpz_get_d
8226b942a58Schristos __GMP_DECLSPEC double mpz_get_d (mpz_srcptr) __GMP_ATTRIBUTE_PURE;
8236b942a58Schristos
8246b942a58Schristos #define mpz_get_d_2exp __gmpz_get_d_2exp
8256b942a58Schristos __GMP_DECLSPEC double mpz_get_d_2exp (signed long int *, mpz_srcptr);
8266b942a58Schristos
8276b942a58Schristos #define mpz_get_si __gmpz_get_si
8286b942a58Schristos __GMP_DECLSPEC /* signed */ long int mpz_get_si (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
8296b942a58Schristos
8306b942a58Schristos #define mpz_get_str __gmpz_get_str
8316b942a58Schristos __GMP_DECLSPEC char *mpz_get_str (char *, int, mpz_srcptr);
8326b942a58Schristos
8336b942a58Schristos #define mpz_get_ui __gmpz_get_ui
8346b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui)
8356b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_get_ui (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
8366b942a58Schristos #endif
8376b942a58Schristos
8386b942a58Schristos #define mpz_getlimbn __gmpz_getlimbn
8396b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn)
8406b942a58Schristos __GMP_DECLSPEC mp_limb_t mpz_getlimbn (mpz_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
8416b942a58Schristos #endif
8426b942a58Schristos
8436b942a58Schristos #define mpz_hamdist __gmpz_hamdist
8446b942a58Schristos __GMP_DECLSPEC mp_bitcnt_t mpz_hamdist (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
8456b942a58Schristos
8466b942a58Schristos #define mpz_import __gmpz_import
8476b942a58Schristos __GMP_DECLSPEC void mpz_import (mpz_ptr, size_t, int, size_t, int, size_t, const void *);
8486b942a58Schristos
8496b942a58Schristos #define mpz_init __gmpz_init
8506b942a58Schristos __GMP_DECLSPEC void mpz_init (mpz_ptr) __GMP_NOTHROW;
8516b942a58Schristos
8526b942a58Schristos #define mpz_init2 __gmpz_init2
8536b942a58Schristos __GMP_DECLSPEC void mpz_init2 (mpz_ptr, mp_bitcnt_t);
8546b942a58Schristos
8556b942a58Schristos #define mpz_inits __gmpz_inits
8566b942a58Schristos __GMP_DECLSPEC void mpz_inits (mpz_ptr, ...) __GMP_NOTHROW;
8576b942a58Schristos
8586b942a58Schristos #define mpz_init_set __gmpz_init_set
8596b942a58Schristos __GMP_DECLSPEC void mpz_init_set (mpz_ptr, mpz_srcptr);
8606b942a58Schristos
8616b942a58Schristos #define mpz_init_set_d __gmpz_init_set_d
8626b942a58Schristos __GMP_DECLSPEC void mpz_init_set_d (mpz_ptr, double);
8636b942a58Schristos
8646b942a58Schristos #define mpz_init_set_si __gmpz_init_set_si
8656b942a58Schristos __GMP_DECLSPEC void mpz_init_set_si (mpz_ptr, signed long int);
8666b942a58Schristos
8676b942a58Schristos #define mpz_init_set_str __gmpz_init_set_str
8686b942a58Schristos __GMP_DECLSPEC int mpz_init_set_str (mpz_ptr, const char *, int);
8696b942a58Schristos
8706b942a58Schristos #define mpz_init_set_ui __gmpz_init_set_ui
8716b942a58Schristos __GMP_DECLSPEC void mpz_init_set_ui (mpz_ptr, unsigned long int);
8726b942a58Schristos
8736b942a58Schristos #define mpz_inp_raw __gmpz_inp_raw
8746b942a58Schristos #ifdef _GMP_H_HAVE_FILE
8756b942a58Schristos __GMP_DECLSPEC size_t mpz_inp_raw (mpz_ptr, FILE *);
8766b942a58Schristos #endif
8776b942a58Schristos
8786b942a58Schristos #define mpz_inp_str __gmpz_inp_str
8796b942a58Schristos #ifdef _GMP_H_HAVE_FILE
8806b942a58Schristos __GMP_DECLSPEC size_t mpz_inp_str (mpz_ptr, FILE *, int);
8816b942a58Schristos #endif
8826b942a58Schristos
8836b942a58Schristos #define mpz_invert __gmpz_invert
8846b942a58Schristos __GMP_DECLSPEC int mpz_invert (mpz_ptr, mpz_srcptr, mpz_srcptr);
8856b942a58Schristos
8866b942a58Schristos #define mpz_ior __gmpz_ior
8876b942a58Schristos __GMP_DECLSPEC void mpz_ior (mpz_ptr, mpz_srcptr, mpz_srcptr);
8886b942a58Schristos
8896b942a58Schristos #define mpz_jacobi __gmpz_jacobi
8906b942a58Schristos __GMP_DECLSPEC int mpz_jacobi (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;
8916b942a58Schristos
8926b942a58Schristos #define mpz_kronecker mpz_jacobi /* alias */
8936b942a58Schristos
8946b942a58Schristos #define mpz_kronecker_si __gmpz_kronecker_si
8956b942a58Schristos __GMP_DECLSPEC int mpz_kronecker_si (mpz_srcptr, long) __GMP_ATTRIBUTE_PURE;
8966b942a58Schristos
8976b942a58Schristos #define mpz_kronecker_ui __gmpz_kronecker_ui
8986b942a58Schristos __GMP_DECLSPEC int mpz_kronecker_ui (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE;
8996b942a58Schristos
9006b942a58Schristos #define mpz_si_kronecker __gmpz_si_kronecker
9016b942a58Schristos __GMP_DECLSPEC int mpz_si_kronecker (long, mpz_srcptr) __GMP_ATTRIBUTE_PURE;
9026b942a58Schristos
9036b942a58Schristos #define mpz_ui_kronecker __gmpz_ui_kronecker
9046b942a58Schristos __GMP_DECLSPEC int mpz_ui_kronecker (unsigned long, mpz_srcptr) __GMP_ATTRIBUTE_PURE;
9056b942a58Schristos
9066b942a58Schristos #define mpz_lcm __gmpz_lcm
9076b942a58Schristos __GMP_DECLSPEC void mpz_lcm (mpz_ptr, mpz_srcptr, mpz_srcptr);
9086b942a58Schristos
9096b942a58Schristos #define mpz_lcm_ui __gmpz_lcm_ui
9106b942a58Schristos __GMP_DECLSPEC void mpz_lcm_ui (mpz_ptr, mpz_srcptr, unsigned long);
9116b942a58Schristos
9126b942a58Schristos #define mpz_legendre mpz_jacobi /* alias */
9136b942a58Schristos
9146b942a58Schristos #define mpz_lucnum_ui __gmpz_lucnum_ui
9156b942a58Schristos __GMP_DECLSPEC void mpz_lucnum_ui (mpz_ptr, unsigned long int);
9166b942a58Schristos
9176b942a58Schristos #define mpz_lucnum2_ui __gmpz_lucnum2_ui
9186b942a58Schristos __GMP_DECLSPEC void mpz_lucnum2_ui (mpz_ptr, mpz_ptr, unsigned long int);
9196b942a58Schristos
9206b942a58Schristos #define mpz_millerrabin __gmpz_millerrabin
9216b942a58Schristos __GMP_DECLSPEC int mpz_millerrabin (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE;
9226b942a58Schristos
9236b942a58Schristos #define mpz_mod __gmpz_mod
9246b942a58Schristos __GMP_DECLSPEC void mpz_mod (mpz_ptr, mpz_srcptr, mpz_srcptr);
9256b942a58Schristos
9266b942a58Schristos #define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */
9276b942a58Schristos
9286b942a58Schristos #define mpz_mul __gmpz_mul
9296b942a58Schristos __GMP_DECLSPEC void mpz_mul (mpz_ptr, mpz_srcptr, mpz_srcptr);
9306b942a58Schristos
9316b942a58Schristos #define mpz_mul_2exp __gmpz_mul_2exp
9326b942a58Schristos __GMP_DECLSPEC void mpz_mul_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);
9336b942a58Schristos
9346b942a58Schristos #define mpz_mul_si __gmpz_mul_si
9356b942a58Schristos __GMP_DECLSPEC void mpz_mul_si (mpz_ptr, mpz_srcptr, long int);
9366b942a58Schristos
9376b942a58Schristos #define mpz_mul_ui __gmpz_mul_ui
9386b942a58Schristos __GMP_DECLSPEC void mpz_mul_ui (mpz_ptr, mpz_srcptr, unsigned long int);
9396b942a58Schristos
9406b942a58Schristos #define mpz_neg __gmpz_neg
9416b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg)
9426b942a58Schristos __GMP_DECLSPEC void mpz_neg (mpz_ptr, mpz_srcptr);
9436b942a58Schristos #endif
9446b942a58Schristos
9456b942a58Schristos #define mpz_nextprime __gmpz_nextprime
9466b942a58Schristos __GMP_DECLSPEC void mpz_nextprime (mpz_ptr, mpz_srcptr);
9476b942a58Schristos
9486b942a58Schristos #define mpz_out_raw __gmpz_out_raw
9496b942a58Schristos #ifdef _GMP_H_HAVE_FILE
9506b942a58Schristos __GMP_DECLSPEC size_t mpz_out_raw (FILE *, mpz_srcptr);
9516b942a58Schristos #endif
9526b942a58Schristos
9536b942a58Schristos #define mpz_out_str __gmpz_out_str
9546b942a58Schristos #ifdef _GMP_H_HAVE_FILE
9556b942a58Schristos __GMP_DECLSPEC size_t mpz_out_str (FILE *, int, mpz_srcptr);
9566b942a58Schristos #endif
9576b942a58Schristos
9586b942a58Schristos #define mpz_perfect_power_p __gmpz_perfect_power_p
9596b942a58Schristos __GMP_DECLSPEC int mpz_perfect_power_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE;
9606b942a58Schristos
9616b942a58Schristos #define mpz_perfect_square_p __gmpz_perfect_square_p
9626b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p)
9636b942a58Schristos __GMP_DECLSPEC int mpz_perfect_square_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE;
9646b942a58Schristos #endif
9656b942a58Schristos
9666b942a58Schristos #define mpz_popcount __gmpz_popcount
9676b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount)
9686b942a58Schristos __GMP_DECLSPEC mp_bitcnt_t mpz_popcount (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
9696b942a58Schristos #endif
9706b942a58Schristos
9716b942a58Schristos #define mpz_pow_ui __gmpz_pow_ui
9726b942a58Schristos __GMP_DECLSPEC void mpz_pow_ui (mpz_ptr, mpz_srcptr, unsigned long int);
9736b942a58Schristos
9746b942a58Schristos #define mpz_powm __gmpz_powm
9756b942a58Schristos __GMP_DECLSPEC void mpz_powm (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr);
9766b942a58Schristos
9776b942a58Schristos #define mpz_powm_sec __gmpz_powm_sec
9786b942a58Schristos __GMP_DECLSPEC void mpz_powm_sec (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr);
9796b942a58Schristos
9806b942a58Schristos #define mpz_powm_ui __gmpz_powm_ui
9816b942a58Schristos __GMP_DECLSPEC void mpz_powm_ui (mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr);
9826b942a58Schristos
9836b942a58Schristos #define mpz_probab_prime_p __gmpz_probab_prime_p
9846b942a58Schristos __GMP_DECLSPEC int mpz_probab_prime_p (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE;
9856b942a58Schristos
9866b942a58Schristos #define mpz_random __gmpz_random
9876b942a58Schristos __GMP_DECLSPEC void mpz_random (mpz_ptr, mp_size_t);
9886b942a58Schristos
9896b942a58Schristos #define mpz_random2 __gmpz_random2
9906b942a58Schristos __GMP_DECLSPEC void mpz_random2 (mpz_ptr, mp_size_t);
9916b942a58Schristos
9926b942a58Schristos #define mpz_realloc2 __gmpz_realloc2
9936b942a58Schristos __GMP_DECLSPEC void mpz_realloc2 (mpz_ptr, mp_bitcnt_t);
9946b942a58Schristos
9956b942a58Schristos #define mpz_remove __gmpz_remove
9966b942a58Schristos __GMP_DECLSPEC mp_bitcnt_t mpz_remove (mpz_ptr, mpz_srcptr, mpz_srcptr);
9976b942a58Schristos
9986b942a58Schristos #define mpz_root __gmpz_root
9996b942a58Schristos __GMP_DECLSPEC int mpz_root (mpz_ptr, mpz_srcptr, unsigned long int);
10006b942a58Schristos
10016b942a58Schristos #define mpz_rootrem __gmpz_rootrem
10026b942a58Schristos __GMP_DECLSPEC void mpz_rootrem (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);
10036b942a58Schristos
10046b942a58Schristos #define mpz_rrandomb __gmpz_rrandomb
10056b942a58Schristos __GMP_DECLSPEC void mpz_rrandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t);
10066b942a58Schristos
10076b942a58Schristos #define mpz_scan0 __gmpz_scan0
10086b942a58Schristos __GMP_DECLSPEC mp_bitcnt_t mpz_scan0 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
10096b942a58Schristos
10106b942a58Schristos #define mpz_scan1 __gmpz_scan1
10116b942a58Schristos __GMP_DECLSPEC mp_bitcnt_t mpz_scan1 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
10126b942a58Schristos
10136b942a58Schristos #define mpz_set __gmpz_set
10146b942a58Schristos __GMP_DECLSPEC void mpz_set (mpz_ptr, mpz_srcptr);
10156b942a58Schristos
10166b942a58Schristos #define mpz_set_d __gmpz_set_d
10176b942a58Schristos __GMP_DECLSPEC void mpz_set_d (mpz_ptr, double);
10186b942a58Schristos
10196b942a58Schristos #define mpz_set_f __gmpz_set_f
10206b942a58Schristos __GMP_DECLSPEC void mpz_set_f (mpz_ptr, mpf_srcptr);
10216b942a58Schristos
10226b942a58Schristos #define mpz_set_q __gmpz_set_q
10236b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q)
10246b942a58Schristos __GMP_DECLSPEC void mpz_set_q (mpz_ptr, mpq_srcptr);
10256b942a58Schristos #endif
10266b942a58Schristos
10276b942a58Schristos #define mpz_set_si __gmpz_set_si
10286b942a58Schristos __GMP_DECLSPEC void mpz_set_si (mpz_ptr, signed long int);
10296b942a58Schristos
10306b942a58Schristos #define mpz_set_str __gmpz_set_str
10316b942a58Schristos __GMP_DECLSPEC int mpz_set_str (mpz_ptr, const char *, int);
10326b942a58Schristos
10336b942a58Schristos #define mpz_set_ui __gmpz_set_ui
10346b942a58Schristos __GMP_DECLSPEC void mpz_set_ui (mpz_ptr, unsigned long int);
10356b942a58Schristos
10366b942a58Schristos #define mpz_setbit __gmpz_setbit
10376b942a58Schristos __GMP_DECLSPEC void mpz_setbit (mpz_ptr, mp_bitcnt_t);
10386b942a58Schristos
10396b942a58Schristos #define mpz_size __gmpz_size
10406b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size)
10416b942a58Schristos __GMP_DECLSPEC size_t mpz_size (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
10426b942a58Schristos #endif
10436b942a58Schristos
10446b942a58Schristos #define mpz_sizeinbase __gmpz_sizeinbase
10456b942a58Schristos __GMP_DECLSPEC size_t mpz_sizeinbase (mpz_srcptr, int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
10466b942a58Schristos
10476b942a58Schristos #define mpz_sqrt __gmpz_sqrt
10486b942a58Schristos __GMP_DECLSPEC void mpz_sqrt (mpz_ptr, mpz_srcptr);
10496b942a58Schristos
10506b942a58Schristos #define mpz_sqrtrem __gmpz_sqrtrem
10516b942a58Schristos __GMP_DECLSPEC void mpz_sqrtrem (mpz_ptr, mpz_ptr, mpz_srcptr);
10526b942a58Schristos
10536b942a58Schristos #define mpz_sub __gmpz_sub
10546b942a58Schristos __GMP_DECLSPEC void mpz_sub (mpz_ptr, mpz_srcptr, mpz_srcptr);
10556b942a58Schristos
10566b942a58Schristos #define mpz_sub_ui __gmpz_sub_ui
10576b942a58Schristos __GMP_DECLSPEC void mpz_sub_ui (mpz_ptr, mpz_srcptr, unsigned long int);
10586b942a58Schristos
10596b942a58Schristos #define mpz_ui_sub __gmpz_ui_sub
10606b942a58Schristos __GMP_DECLSPEC void mpz_ui_sub (mpz_ptr, unsigned long int, mpz_srcptr);
10616b942a58Schristos
10626b942a58Schristos #define mpz_submul __gmpz_submul
10636b942a58Schristos __GMP_DECLSPEC void mpz_submul (mpz_ptr, mpz_srcptr, mpz_srcptr);
10646b942a58Schristos
10656b942a58Schristos #define mpz_submul_ui __gmpz_submul_ui
10666b942a58Schristos __GMP_DECLSPEC void mpz_submul_ui (mpz_ptr, mpz_srcptr, unsigned long int);
10676b942a58Schristos
10686b942a58Schristos #define mpz_swap __gmpz_swap
10696b942a58Schristos __GMP_DECLSPEC void mpz_swap (mpz_ptr, mpz_ptr) __GMP_NOTHROW;
10706b942a58Schristos
10716b942a58Schristos #define mpz_tdiv_ui __gmpz_tdiv_ui
10726b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_tdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;
10736b942a58Schristos
10746b942a58Schristos #define mpz_tdiv_q __gmpz_tdiv_q
10756b942a58Schristos __GMP_DECLSPEC void mpz_tdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);
10766b942a58Schristos
10776b942a58Schristos #define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp
10786b942a58Schristos __GMP_DECLSPEC void mpz_tdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);
10796b942a58Schristos
10806b942a58Schristos #define mpz_tdiv_q_ui __gmpz_tdiv_q_ui
10816b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_tdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);
10826b942a58Schristos
10836b942a58Schristos #define mpz_tdiv_qr __gmpz_tdiv_qr
10846b942a58Schristos __GMP_DECLSPEC void mpz_tdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);
10856b942a58Schristos
10866b942a58Schristos #define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui
10876b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_tdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);
10886b942a58Schristos
10896b942a58Schristos #define mpz_tdiv_r __gmpz_tdiv_r
10906b942a58Schristos __GMP_DECLSPEC void mpz_tdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);
10916b942a58Schristos
10926b942a58Schristos #define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp
10936b942a58Schristos __GMP_DECLSPEC void mpz_tdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);
10946b942a58Schristos
10956b942a58Schristos #define mpz_tdiv_r_ui __gmpz_tdiv_r_ui
10966b942a58Schristos __GMP_DECLSPEC unsigned long int mpz_tdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);
10976b942a58Schristos
10986b942a58Schristos #define mpz_tstbit __gmpz_tstbit
10996b942a58Schristos __GMP_DECLSPEC int mpz_tstbit (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
11006b942a58Schristos
11016b942a58Schristos #define mpz_ui_pow_ui __gmpz_ui_pow_ui
11026b942a58Schristos __GMP_DECLSPEC void mpz_ui_pow_ui (mpz_ptr, unsigned long int, unsigned long int);
11036b942a58Schristos
11046b942a58Schristos #define mpz_urandomb __gmpz_urandomb
11056b942a58Schristos __GMP_DECLSPEC void mpz_urandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t);
11066b942a58Schristos
11076b942a58Schristos #define mpz_urandomm __gmpz_urandomm
11086b942a58Schristos __GMP_DECLSPEC void mpz_urandomm (mpz_ptr, gmp_randstate_t, mpz_srcptr);
11096b942a58Schristos
11106b942a58Schristos #define mpz_xor __gmpz_xor
11116b942a58Schristos #define mpz_eor __gmpz_xor
11126b942a58Schristos __GMP_DECLSPEC void mpz_xor (mpz_ptr, mpz_srcptr, mpz_srcptr);
11136b942a58Schristos
11146b942a58Schristos #define mpz_limbs_read __gmpz_limbs_read
11156b942a58Schristos __GMP_DECLSPEC mp_srcptr mpz_limbs_read (mpz_srcptr);
11166b942a58Schristos
11176b942a58Schristos #define mpz_limbs_write __gmpz_limbs_write
11186b942a58Schristos __GMP_DECLSPEC mp_ptr mpz_limbs_write (mpz_ptr, mp_size_t);
11196b942a58Schristos
11206b942a58Schristos #define mpz_limbs_modify __gmpz_limbs_modify
11216b942a58Schristos __GMP_DECLSPEC mp_ptr mpz_limbs_modify (mpz_ptr, mp_size_t);
11226b942a58Schristos
11236b942a58Schristos #define mpz_limbs_finish __gmpz_limbs_finish
11246b942a58Schristos __GMP_DECLSPEC void mpz_limbs_finish (mpz_ptr, mp_size_t);
11256b942a58Schristos
11266b942a58Schristos #define mpz_roinit_n __gmpz_roinit_n
11276b942a58Schristos __GMP_DECLSPEC mpz_srcptr mpz_roinit_n (mpz_ptr, mp_srcptr, mp_size_t);
11286b942a58Schristos
11296b942a58Schristos #define MPZ_ROINIT_N(xp, xs) {{0, (xs),(xp) }}
11306b942a58Schristos
11316b942a58Schristos /**************** Rational (i.e. Q) routines. ****************/
11326b942a58Schristos
11336b942a58Schristos #define mpq_abs __gmpq_abs
11346b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs)
11356b942a58Schristos __GMP_DECLSPEC void mpq_abs (mpq_ptr, mpq_srcptr);
11366b942a58Schristos #endif
11376b942a58Schristos
11386b942a58Schristos #define mpq_add __gmpq_add
11396b942a58Schristos __GMP_DECLSPEC void mpq_add (mpq_ptr, mpq_srcptr, mpq_srcptr);
11406b942a58Schristos
11416b942a58Schristos #define mpq_canonicalize __gmpq_canonicalize
11426b942a58Schristos __GMP_DECLSPEC void mpq_canonicalize (mpq_ptr);
11436b942a58Schristos
11446b942a58Schristos #define mpq_clear __gmpq_clear
11456b942a58Schristos __GMP_DECLSPEC void mpq_clear (mpq_ptr);
11466b942a58Schristos
11476b942a58Schristos #define mpq_clears __gmpq_clears
11486b942a58Schristos __GMP_DECLSPEC void mpq_clears (mpq_ptr, ...);
11496b942a58Schristos
11506b942a58Schristos #define mpq_cmp __gmpq_cmp
11516b942a58Schristos __GMP_DECLSPEC int mpq_cmp (mpq_srcptr, mpq_srcptr) __GMP_ATTRIBUTE_PURE;
11526b942a58Schristos
11536b942a58Schristos #define _mpq_cmp_si __gmpq_cmp_si
11546b942a58Schristos __GMP_DECLSPEC int _mpq_cmp_si (mpq_srcptr, long, unsigned long) __GMP_ATTRIBUTE_PURE;
11556b942a58Schristos
11566b942a58Schristos #define _mpq_cmp_ui __gmpq_cmp_ui
11576b942a58Schristos __GMP_DECLSPEC int _mpq_cmp_ui (mpq_srcptr, unsigned long int, unsigned long int) __GMP_ATTRIBUTE_PURE;
11586b942a58Schristos
11596b942a58Schristos #define mpq_cmp_z __gmpq_cmp_z
11606b942a58Schristos __GMP_DECLSPEC int mpq_cmp_z (mpq_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;
11616b942a58Schristos
11626b942a58Schristos #define mpq_div __gmpq_div
11636b942a58Schristos __GMP_DECLSPEC void mpq_div (mpq_ptr, mpq_srcptr, mpq_srcptr);
11646b942a58Schristos
11656b942a58Schristos #define mpq_div_2exp __gmpq_div_2exp
11666b942a58Schristos __GMP_DECLSPEC void mpq_div_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t);
11676b942a58Schristos
11686b942a58Schristos #define mpq_equal __gmpq_equal
11696b942a58Schristos __GMP_DECLSPEC int mpq_equal (mpq_srcptr, mpq_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
11706b942a58Schristos
11716b942a58Schristos #define mpq_get_num __gmpq_get_num
11726b942a58Schristos __GMP_DECLSPEC void mpq_get_num (mpz_ptr, mpq_srcptr);
11736b942a58Schristos
11746b942a58Schristos #define mpq_get_den __gmpq_get_den
11756b942a58Schristos __GMP_DECLSPEC void mpq_get_den (mpz_ptr, mpq_srcptr);
11766b942a58Schristos
11776b942a58Schristos #define mpq_get_d __gmpq_get_d
11786b942a58Schristos __GMP_DECLSPEC double mpq_get_d (mpq_srcptr) __GMP_ATTRIBUTE_PURE;
11796b942a58Schristos
11806b942a58Schristos #define mpq_get_str __gmpq_get_str
11816b942a58Schristos __GMP_DECLSPEC char *mpq_get_str (char *, int, mpq_srcptr);
11826b942a58Schristos
11836b942a58Schristos #define mpq_init __gmpq_init
11846b942a58Schristos __GMP_DECLSPEC void mpq_init (mpq_ptr);
11856b942a58Schristos
11866b942a58Schristos #define mpq_inits __gmpq_inits
11876b942a58Schristos __GMP_DECLSPEC void mpq_inits (mpq_ptr, ...);
11886b942a58Schristos
11896b942a58Schristos #define mpq_inp_str __gmpq_inp_str
11906b942a58Schristos #ifdef _GMP_H_HAVE_FILE
11916b942a58Schristos __GMP_DECLSPEC size_t mpq_inp_str (mpq_ptr, FILE *, int);
11926b942a58Schristos #endif
11936b942a58Schristos
11946b942a58Schristos #define mpq_inv __gmpq_inv
11956b942a58Schristos __GMP_DECLSPEC void mpq_inv (mpq_ptr, mpq_srcptr);
11966b942a58Schristos
11976b942a58Schristos #define mpq_mul __gmpq_mul
11986b942a58Schristos __GMP_DECLSPEC void mpq_mul (mpq_ptr, mpq_srcptr, mpq_srcptr);
11996b942a58Schristos
12006b942a58Schristos #define mpq_mul_2exp __gmpq_mul_2exp
12016b942a58Schristos __GMP_DECLSPEC void mpq_mul_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t);
12026b942a58Schristos
12036b942a58Schristos #define mpq_neg __gmpq_neg
12046b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg)
12056b942a58Schristos __GMP_DECLSPEC void mpq_neg (mpq_ptr, mpq_srcptr);
12066b942a58Schristos #endif
12076b942a58Schristos
12086b942a58Schristos #define mpq_out_str __gmpq_out_str
12096b942a58Schristos #ifdef _GMP_H_HAVE_FILE
12106b942a58Schristos __GMP_DECLSPEC size_t mpq_out_str (FILE *, int, mpq_srcptr);
12116b942a58Schristos #endif
12126b942a58Schristos
12136b942a58Schristos #define mpq_set __gmpq_set
12146b942a58Schristos __GMP_DECLSPEC void mpq_set (mpq_ptr, mpq_srcptr);
12156b942a58Schristos
12166b942a58Schristos #define mpq_set_d __gmpq_set_d
12176b942a58Schristos __GMP_DECLSPEC void mpq_set_d (mpq_ptr, double);
12186b942a58Schristos
12196b942a58Schristos #define mpq_set_den __gmpq_set_den
12206b942a58Schristos __GMP_DECLSPEC void mpq_set_den (mpq_ptr, mpz_srcptr);
12216b942a58Schristos
12226b942a58Schristos #define mpq_set_f __gmpq_set_f
12236b942a58Schristos __GMP_DECLSPEC void mpq_set_f (mpq_ptr, mpf_srcptr);
12246b942a58Schristos
12256b942a58Schristos #define mpq_set_num __gmpq_set_num
12266b942a58Schristos __GMP_DECLSPEC void mpq_set_num (mpq_ptr, mpz_srcptr);
12276b942a58Schristos
12286b942a58Schristos #define mpq_set_si __gmpq_set_si
12296b942a58Schristos __GMP_DECLSPEC void mpq_set_si (mpq_ptr, signed long int, unsigned long int);
12306b942a58Schristos
12316b942a58Schristos #define mpq_set_str __gmpq_set_str
12326b942a58Schristos __GMP_DECLSPEC int mpq_set_str (mpq_ptr, const char *, int);
12336b942a58Schristos
12346b942a58Schristos #define mpq_set_ui __gmpq_set_ui
12356b942a58Schristos __GMP_DECLSPEC void mpq_set_ui (mpq_ptr, unsigned long int, unsigned long int);
12366b942a58Schristos
12376b942a58Schristos #define mpq_set_z __gmpq_set_z
12386b942a58Schristos __GMP_DECLSPEC void mpq_set_z (mpq_ptr, mpz_srcptr);
12396b942a58Schristos
12406b942a58Schristos #define mpq_sub __gmpq_sub
12416b942a58Schristos __GMP_DECLSPEC void mpq_sub (mpq_ptr, mpq_srcptr, mpq_srcptr);
12426b942a58Schristos
12436b942a58Schristos #define mpq_swap __gmpq_swap
12446b942a58Schristos __GMP_DECLSPEC void mpq_swap (mpq_ptr, mpq_ptr) __GMP_NOTHROW;
12456b942a58Schristos
12466b942a58Schristos
12476b942a58Schristos /**************** Float (i.e. F) routines. ****************/
12486b942a58Schristos
12496b942a58Schristos #define mpf_abs __gmpf_abs
12506b942a58Schristos __GMP_DECLSPEC void mpf_abs (mpf_ptr, mpf_srcptr);
12516b942a58Schristos
12526b942a58Schristos #define mpf_add __gmpf_add
12536b942a58Schristos __GMP_DECLSPEC void mpf_add (mpf_ptr, mpf_srcptr, mpf_srcptr);
12546b942a58Schristos
12556b942a58Schristos #define mpf_add_ui __gmpf_add_ui
12566b942a58Schristos __GMP_DECLSPEC void mpf_add_ui (mpf_ptr, mpf_srcptr, unsigned long int);
12576b942a58Schristos #define mpf_ceil __gmpf_ceil
12586b942a58Schristos __GMP_DECLSPEC void mpf_ceil (mpf_ptr, mpf_srcptr);
12596b942a58Schristos
12606b942a58Schristos #define mpf_clear __gmpf_clear
12616b942a58Schristos __GMP_DECLSPEC void mpf_clear (mpf_ptr);
12626b942a58Schristos
12636b942a58Schristos #define mpf_clears __gmpf_clears
12646b942a58Schristos __GMP_DECLSPEC void mpf_clears (mpf_ptr, ...);
12656b942a58Schristos
12666b942a58Schristos #define mpf_cmp __gmpf_cmp
12676b942a58Schristos __GMP_DECLSPEC int mpf_cmp (mpf_srcptr, mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
12686b942a58Schristos
12696b942a58Schristos #define mpf_cmp_z __gmpf_cmp_z
12706b942a58Schristos __GMP_DECLSPEC int mpf_cmp_z (mpf_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
12716b942a58Schristos
12726b942a58Schristos #define mpf_cmp_d __gmpf_cmp_d
12736b942a58Schristos __GMP_DECLSPEC int mpf_cmp_d (mpf_srcptr, double) __GMP_ATTRIBUTE_PURE;
12746b942a58Schristos
12756b942a58Schristos #define mpf_cmp_si __gmpf_cmp_si
12766b942a58Schristos __GMP_DECLSPEC int mpf_cmp_si (mpf_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
12776b942a58Schristos
12786b942a58Schristos #define mpf_cmp_ui __gmpf_cmp_ui
12796b942a58Schristos __GMP_DECLSPEC int mpf_cmp_ui (mpf_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
12806b942a58Schristos
12816b942a58Schristos #define mpf_div __gmpf_div
12826b942a58Schristos __GMP_DECLSPEC void mpf_div (mpf_ptr, mpf_srcptr, mpf_srcptr);
12836b942a58Schristos
12846b942a58Schristos #define mpf_div_2exp __gmpf_div_2exp
12856b942a58Schristos __GMP_DECLSPEC void mpf_div_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t);
12866b942a58Schristos
12876b942a58Schristos #define mpf_div_ui __gmpf_div_ui
12886b942a58Schristos __GMP_DECLSPEC void mpf_div_ui (mpf_ptr, mpf_srcptr, unsigned long int);
12896b942a58Schristos
12906b942a58Schristos #define mpf_dump __gmpf_dump
12916b942a58Schristos __GMP_DECLSPEC void mpf_dump (mpf_srcptr);
12926b942a58Schristos
12936b942a58Schristos #define mpf_eq __gmpf_eq
12946b942a58Schristos __GMP_DECLSPEC int mpf_eq (mpf_srcptr, mpf_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;
12956b942a58Schristos
12966b942a58Schristos #define mpf_fits_sint_p __gmpf_fits_sint_p
12976b942a58Schristos __GMP_DECLSPEC int mpf_fits_sint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
12986b942a58Schristos
12996b942a58Schristos #define mpf_fits_slong_p __gmpf_fits_slong_p
13006b942a58Schristos __GMP_DECLSPEC int mpf_fits_slong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
13016b942a58Schristos
13026b942a58Schristos #define mpf_fits_sshort_p __gmpf_fits_sshort_p
13036b942a58Schristos __GMP_DECLSPEC int mpf_fits_sshort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
13046b942a58Schristos
13056b942a58Schristos #define mpf_fits_uint_p __gmpf_fits_uint_p
13066b942a58Schristos __GMP_DECLSPEC int mpf_fits_uint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
13076b942a58Schristos
13086b942a58Schristos #define mpf_fits_ulong_p __gmpf_fits_ulong_p
13096b942a58Schristos __GMP_DECLSPEC int mpf_fits_ulong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
13106b942a58Schristos
13116b942a58Schristos #define mpf_fits_ushort_p __gmpf_fits_ushort_p
13126b942a58Schristos __GMP_DECLSPEC int mpf_fits_ushort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
13136b942a58Schristos
13146b942a58Schristos #define mpf_floor __gmpf_floor
13156b942a58Schristos __GMP_DECLSPEC void mpf_floor (mpf_ptr, mpf_srcptr);
13166b942a58Schristos
13176b942a58Schristos #define mpf_get_d __gmpf_get_d
13186b942a58Schristos __GMP_DECLSPEC double mpf_get_d (mpf_srcptr) __GMP_ATTRIBUTE_PURE;
13196b942a58Schristos
13206b942a58Schristos #define mpf_get_d_2exp __gmpf_get_d_2exp
13216b942a58Schristos __GMP_DECLSPEC double mpf_get_d_2exp (signed long int *, mpf_srcptr);
13226b942a58Schristos
13236b942a58Schristos #define mpf_get_default_prec __gmpf_get_default_prec
13246b942a58Schristos __GMP_DECLSPEC mp_bitcnt_t mpf_get_default_prec (void) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
13256b942a58Schristos
13266b942a58Schristos #define mpf_get_prec __gmpf_get_prec
13276b942a58Schristos __GMP_DECLSPEC mp_bitcnt_t mpf_get_prec (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
13286b942a58Schristos
13296b942a58Schristos #define mpf_get_si __gmpf_get_si
13306b942a58Schristos __GMP_DECLSPEC long mpf_get_si (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
13316b942a58Schristos
13326b942a58Schristos #define mpf_get_str __gmpf_get_str
13336b942a58Schristos __GMP_DECLSPEC char *mpf_get_str (char *, mp_exp_t *, int, size_t, mpf_srcptr);
13346b942a58Schristos
13356b942a58Schristos #define mpf_get_ui __gmpf_get_ui
13366b942a58Schristos __GMP_DECLSPEC unsigned long mpf_get_ui (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
13376b942a58Schristos
13386b942a58Schristos #define mpf_init __gmpf_init
13396b942a58Schristos __GMP_DECLSPEC void mpf_init (mpf_ptr);
13406b942a58Schristos
13416b942a58Schristos #define mpf_init2 __gmpf_init2
13426b942a58Schristos __GMP_DECLSPEC void mpf_init2 (mpf_ptr, mp_bitcnt_t);
13436b942a58Schristos
13446b942a58Schristos #define mpf_inits __gmpf_inits
13456b942a58Schristos __GMP_DECLSPEC void mpf_inits (mpf_ptr, ...);
13466b942a58Schristos
13476b942a58Schristos #define mpf_init_set __gmpf_init_set
13486b942a58Schristos __GMP_DECLSPEC void mpf_init_set (mpf_ptr, mpf_srcptr);
13496b942a58Schristos
13506b942a58Schristos #define mpf_init_set_d __gmpf_init_set_d
13516b942a58Schristos __GMP_DECLSPEC void mpf_init_set_d (mpf_ptr, double);
13526b942a58Schristos
13536b942a58Schristos #define mpf_init_set_si __gmpf_init_set_si
13546b942a58Schristos __GMP_DECLSPEC void mpf_init_set_si (mpf_ptr, signed long int);
13556b942a58Schristos
13566b942a58Schristos #define mpf_init_set_str __gmpf_init_set_str
13576b942a58Schristos __GMP_DECLSPEC int mpf_init_set_str (mpf_ptr, const char *, int);
13586b942a58Schristos
13596b942a58Schristos #define mpf_init_set_ui __gmpf_init_set_ui
13606b942a58Schristos __GMP_DECLSPEC void mpf_init_set_ui (mpf_ptr, unsigned long int);
13616b942a58Schristos
13626b942a58Schristos #define mpf_inp_str __gmpf_inp_str
13636b942a58Schristos #ifdef _GMP_H_HAVE_FILE
13646b942a58Schristos __GMP_DECLSPEC size_t mpf_inp_str (mpf_ptr, FILE *, int);
13656b942a58Schristos #endif
13666b942a58Schristos
13676b942a58Schristos #define mpf_integer_p __gmpf_integer_p
13686b942a58Schristos __GMP_DECLSPEC int mpf_integer_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
13696b942a58Schristos
13706b942a58Schristos #define mpf_mul __gmpf_mul
13716b942a58Schristos __GMP_DECLSPEC void mpf_mul (mpf_ptr, mpf_srcptr, mpf_srcptr);
13726b942a58Schristos
13736b942a58Schristos #define mpf_mul_2exp __gmpf_mul_2exp
13746b942a58Schristos __GMP_DECLSPEC void mpf_mul_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t);
13756b942a58Schristos
13766b942a58Schristos #define mpf_mul_ui __gmpf_mul_ui
13776b942a58Schristos __GMP_DECLSPEC void mpf_mul_ui (mpf_ptr, mpf_srcptr, unsigned long int);
13786b942a58Schristos
13796b942a58Schristos #define mpf_neg __gmpf_neg
13806b942a58Schristos __GMP_DECLSPEC void mpf_neg (mpf_ptr, mpf_srcptr);
13816b942a58Schristos
13826b942a58Schristos #define mpf_out_str __gmpf_out_str
13836b942a58Schristos #ifdef _GMP_H_HAVE_FILE
13846b942a58Schristos __GMP_DECLSPEC size_t mpf_out_str (FILE *, int, size_t, mpf_srcptr);
13856b942a58Schristos #endif
13866b942a58Schristos
13876b942a58Schristos #define mpf_pow_ui __gmpf_pow_ui
13886b942a58Schristos __GMP_DECLSPEC void mpf_pow_ui (mpf_ptr, mpf_srcptr, unsigned long int);
13896b942a58Schristos
13906b942a58Schristos #define mpf_random2 __gmpf_random2
13916b942a58Schristos __GMP_DECLSPEC void mpf_random2 (mpf_ptr, mp_size_t, mp_exp_t);
13926b942a58Schristos
13936b942a58Schristos #define mpf_reldiff __gmpf_reldiff
13946b942a58Schristos __GMP_DECLSPEC void mpf_reldiff (mpf_ptr, mpf_srcptr, mpf_srcptr);
13956b942a58Schristos
13966b942a58Schristos #define mpf_set __gmpf_set
13976b942a58Schristos __GMP_DECLSPEC void mpf_set (mpf_ptr, mpf_srcptr);
13986b942a58Schristos
13996b942a58Schristos #define mpf_set_d __gmpf_set_d
14006b942a58Schristos __GMP_DECLSPEC void mpf_set_d (mpf_ptr, double);
14016b942a58Schristos
14026b942a58Schristos #define mpf_set_default_prec __gmpf_set_default_prec
14036b942a58Schristos __GMP_DECLSPEC void mpf_set_default_prec (mp_bitcnt_t) __GMP_NOTHROW;
14046b942a58Schristos
14056b942a58Schristos #define mpf_set_prec __gmpf_set_prec
14066b942a58Schristos __GMP_DECLSPEC void mpf_set_prec (mpf_ptr, mp_bitcnt_t);
14076b942a58Schristos
14086b942a58Schristos #define mpf_set_prec_raw __gmpf_set_prec_raw
14096b942a58Schristos __GMP_DECLSPEC void mpf_set_prec_raw (mpf_ptr, mp_bitcnt_t) __GMP_NOTHROW;
14106b942a58Schristos
14116b942a58Schristos #define mpf_set_q __gmpf_set_q
14126b942a58Schristos __GMP_DECLSPEC void mpf_set_q (mpf_ptr, mpq_srcptr);
14136b942a58Schristos
14146b942a58Schristos #define mpf_set_si __gmpf_set_si
14156b942a58Schristos __GMP_DECLSPEC void mpf_set_si (mpf_ptr, signed long int);
14166b942a58Schristos
14176b942a58Schristos #define mpf_set_str __gmpf_set_str
14186b942a58Schristos __GMP_DECLSPEC int mpf_set_str (mpf_ptr, const char *, int);
14196b942a58Schristos
14206b942a58Schristos #define mpf_set_ui __gmpf_set_ui
14216b942a58Schristos __GMP_DECLSPEC void mpf_set_ui (mpf_ptr, unsigned long int);
14226b942a58Schristos
14236b942a58Schristos #define mpf_set_z __gmpf_set_z
14246b942a58Schristos __GMP_DECLSPEC void mpf_set_z (mpf_ptr, mpz_srcptr);
14256b942a58Schristos
14266b942a58Schristos #define mpf_size __gmpf_size
14276b942a58Schristos __GMP_DECLSPEC size_t mpf_size (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
14286b942a58Schristos
14296b942a58Schristos #define mpf_sqrt __gmpf_sqrt
14306b942a58Schristos __GMP_DECLSPEC void mpf_sqrt (mpf_ptr, mpf_srcptr);
14316b942a58Schristos
14326b942a58Schristos #define mpf_sqrt_ui __gmpf_sqrt_ui
14336b942a58Schristos __GMP_DECLSPEC void mpf_sqrt_ui (mpf_ptr, unsigned long int);
14346b942a58Schristos
14356b942a58Schristos #define mpf_sub __gmpf_sub
14366b942a58Schristos __GMP_DECLSPEC void mpf_sub (mpf_ptr, mpf_srcptr, mpf_srcptr);
14376b942a58Schristos
14386b942a58Schristos #define mpf_sub_ui __gmpf_sub_ui
14396b942a58Schristos __GMP_DECLSPEC void mpf_sub_ui (mpf_ptr, mpf_srcptr, unsigned long int);
14406b942a58Schristos
14416b942a58Schristos #define mpf_swap __gmpf_swap
14426b942a58Schristos __GMP_DECLSPEC void mpf_swap (mpf_ptr, mpf_ptr) __GMP_NOTHROW;
14436b942a58Schristos
14446b942a58Schristos #define mpf_trunc __gmpf_trunc
14456b942a58Schristos __GMP_DECLSPEC void mpf_trunc (mpf_ptr, mpf_srcptr);
14466b942a58Schristos
14476b942a58Schristos #define mpf_ui_div __gmpf_ui_div
14486b942a58Schristos __GMP_DECLSPEC void mpf_ui_div (mpf_ptr, unsigned long int, mpf_srcptr);
14496b942a58Schristos
14506b942a58Schristos #define mpf_ui_sub __gmpf_ui_sub
14516b942a58Schristos __GMP_DECLSPEC void mpf_ui_sub (mpf_ptr, unsigned long int, mpf_srcptr);
14526b942a58Schristos
14536b942a58Schristos #define mpf_urandomb __gmpf_urandomb
14546b942a58Schristos __GMP_DECLSPEC void mpf_urandomb (mpf_t, gmp_randstate_t, mp_bitcnt_t);
14556b942a58Schristos
14566b942a58Schristos
14576b942a58Schristos /************ Low level positive-integer (i.e. N) routines. ************/
14586b942a58Schristos
14596b942a58Schristos /* This is ugly, but we need to make user calls reach the prefixed function. */
14606b942a58Schristos
14616b942a58Schristos #define mpn_add __MPN(add)
14626b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add)
14636b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_add (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);
14646b942a58Schristos #endif
14656b942a58Schristos
14666b942a58Schristos #define mpn_add_1 __MPN(add_1)
14676b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1)
14686b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW;
14696b942a58Schristos #endif
14706b942a58Schristos
14716b942a58Schristos #define mpn_add_n __MPN(add_n)
14726b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
14736b942a58Schristos
14746b942a58Schristos #define mpn_addmul_1 __MPN(addmul_1)
14756b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_addmul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
14766b942a58Schristos
14776b942a58Schristos #define mpn_cmp __MPN(cmp)
14786b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp)
14796b942a58Schristos __GMP_DECLSPEC int mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
14806b942a58Schristos #endif
14816b942a58Schristos
14826b942a58Schristos #define mpn_zero_p __MPN(zero_p)
14836b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_zero_p)
14846b942a58Schristos __GMP_DECLSPEC int mpn_zero_p (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
14856b942a58Schristos #endif
14866b942a58Schristos
14876b942a58Schristos #define mpn_divexact_1 __MPN(divexact_1)
14886b942a58Schristos __GMP_DECLSPEC void mpn_divexact_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
14896b942a58Schristos
14906b942a58Schristos #define mpn_divexact_by3(dst,src,size) \
14916b942a58Schristos mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0))
14926b942a58Schristos
14936b942a58Schristos #define mpn_divexact_by3c __MPN(divexact_by3c)
14946b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_divexact_by3c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
14956b942a58Schristos
14966b942a58Schristos #define mpn_divmod_1(qp,np,nsize,dlimb) \
14976b942a58Schristos mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb)
14986b942a58Schristos
14996b942a58Schristos #define mpn_divrem __MPN(divrem)
15006b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_divrem (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t);
15016b942a58Schristos
15026b942a58Schristos #define mpn_divrem_1 __MPN(divrem_1)
15036b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_divrem_1 (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t);
15046b942a58Schristos
15056b942a58Schristos #define mpn_divrem_2 __MPN(divrem_2)
15066b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_divrem_2 (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr);
15076b942a58Schristos
15086b942a58Schristos #define mpn_div_qr_1 __MPN(div_qr_1)
15096b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_div_qr_1 (mp_ptr, mp_limb_t *, mp_srcptr, mp_size_t, mp_limb_t);
15106b942a58Schristos
15116b942a58Schristos #define mpn_div_qr_2 __MPN(div_qr_2)
15126b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_div_qr_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr);
15136b942a58Schristos
15146b942a58Schristos #define mpn_gcd __MPN(gcd)
15156b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_gcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t);
15166b942a58Schristos
15176b942a58Schristos #define mpn_gcd_11 __MPN(gcd_11)
15186b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_gcd_11 (mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;
15196b942a58Schristos
15206b942a58Schristos #define mpn_gcd_1 __MPN(gcd_1)
15216b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_gcd_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;
15226b942a58Schristos
15236b942a58Schristos #define mpn_gcdext_1 __MPN(gcdext_1)
15246b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_gcdext_1 (mp_limb_signed_t *, mp_limb_signed_t *, mp_limb_t, mp_limb_t);
15256b942a58Schristos
15266b942a58Schristos #define mpn_gcdext __MPN(gcdext)
15276b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_gcdext (mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_size_t, mp_ptr, mp_size_t);
15286b942a58Schristos
15296b942a58Schristos #define mpn_get_str __MPN(get_str)
15306b942a58Schristos __GMP_DECLSPEC size_t mpn_get_str (unsigned char *, int, mp_ptr, mp_size_t);
15316b942a58Schristos
15326b942a58Schristos #define mpn_hamdist __MPN(hamdist)
15336b942a58Schristos __GMP_DECLSPEC mp_bitcnt_t mpn_hamdist (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
15346b942a58Schristos
15356b942a58Schristos #define mpn_lshift __MPN(lshift)
15366b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);
15376b942a58Schristos
15386b942a58Schristos #define mpn_mod_1 __MPN(mod_1)
15396b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_mod_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;
15406b942a58Schristos
15416b942a58Schristos #define mpn_mul __MPN(mul)
15426b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);
15436b942a58Schristos
15446b942a58Schristos #define mpn_mul_1 __MPN(mul_1)
15456b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_mul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
15466b942a58Schristos
15476b942a58Schristos #define mpn_mul_n __MPN(mul_n)
15486b942a58Schristos __GMP_DECLSPEC void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
15496b942a58Schristos
15506b942a58Schristos #define mpn_sqr __MPN(sqr)
15516b942a58Schristos __GMP_DECLSPEC void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t);
15526b942a58Schristos
15536b942a58Schristos #define mpn_neg __MPN(neg)
15546b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_neg)
15556b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_neg (mp_ptr, mp_srcptr, mp_size_t);
15566b942a58Schristos #endif
15576b942a58Schristos
15586b942a58Schristos #define mpn_com __MPN(com)
15596b942a58Schristos __GMP_DECLSPEC void mpn_com (mp_ptr, mp_srcptr, mp_size_t);
15606b942a58Schristos
15616b942a58Schristos #define mpn_perfect_square_p __MPN(perfect_square_p)
15626b942a58Schristos __GMP_DECLSPEC int mpn_perfect_square_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE;
15636b942a58Schristos
15646b942a58Schristos #define mpn_perfect_power_p __MPN(perfect_power_p)
15656b942a58Schristos __GMP_DECLSPEC int mpn_perfect_power_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE;
15666b942a58Schristos
15676b942a58Schristos #define mpn_popcount __MPN(popcount)
15686b942a58Schristos __GMP_DECLSPEC mp_bitcnt_t mpn_popcount (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
15696b942a58Schristos
15706b942a58Schristos #define mpn_pow_1 __MPN(pow_1)
15716b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_pow_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);
15726b942a58Schristos
15736b942a58Schristos /* undocumented now, but retained here for upward compatibility */
15746b942a58Schristos #define mpn_preinv_mod_1 __MPN(preinv_mod_1)
15756b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_preinv_mod_1 (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;
15766b942a58Schristos
15776b942a58Schristos #define mpn_random __MPN(random)
15786b942a58Schristos __GMP_DECLSPEC void mpn_random (mp_ptr, mp_size_t);
15796b942a58Schristos
15806b942a58Schristos #define mpn_random2 __MPN(random2)
15816b942a58Schristos __GMP_DECLSPEC void mpn_random2 (mp_ptr, mp_size_t);
15826b942a58Schristos
15836b942a58Schristos #define mpn_rshift __MPN(rshift)
15846b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);
15856b942a58Schristos
15866b942a58Schristos #define mpn_scan0 __MPN(scan0)
15876b942a58Schristos __GMP_DECLSPEC mp_bitcnt_t mpn_scan0 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;
15886b942a58Schristos
15896b942a58Schristos #define mpn_scan1 __MPN(scan1)
15906b942a58Schristos __GMP_DECLSPEC mp_bitcnt_t mpn_scan1 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;
15916b942a58Schristos
15926b942a58Schristos #define mpn_set_str __MPN(set_str)
15936b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_set_str (mp_ptr, const unsigned char *, size_t, int);
15946b942a58Schristos
15956b942a58Schristos #define mpn_sizeinbase __MPN(sizeinbase)
15966b942a58Schristos __GMP_DECLSPEC size_t mpn_sizeinbase (mp_srcptr, mp_size_t, int);
15976b942a58Schristos
15986b942a58Schristos #define mpn_sqrtrem __MPN(sqrtrem)
15996b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t);
16006b942a58Schristos
16016b942a58Schristos #define mpn_sub __MPN(sub)
16026b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub)
16036b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_sub (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);
16046b942a58Schristos #endif
16056b942a58Schristos
16066b942a58Schristos #define mpn_sub_1 __MPN(sub_1)
16076b942a58Schristos #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1)
16086b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW;
16096b942a58Schristos #endif
16106b942a58Schristos
16116b942a58Schristos #define mpn_sub_n __MPN(sub_n)
16126b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
16136b942a58Schristos
16146b942a58Schristos #define mpn_submul_1 __MPN(submul_1)
16156b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_submul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
16166b942a58Schristos
16176b942a58Schristos #define mpn_tdiv_qr __MPN(tdiv_qr)
16186b942a58Schristos __GMP_DECLSPEC void mpn_tdiv_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);
16196b942a58Schristos
16206b942a58Schristos #define mpn_and_n __MPN(and_n)
16216b942a58Schristos __GMP_DECLSPEC void mpn_and_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
16226b942a58Schristos #define mpn_andn_n __MPN(andn_n)
16236b942a58Schristos __GMP_DECLSPEC void mpn_andn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
16246b942a58Schristos #define mpn_nand_n __MPN(nand_n)
16256b942a58Schristos __GMP_DECLSPEC void mpn_nand_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
16266b942a58Schristos #define mpn_ior_n __MPN(ior_n)
16276b942a58Schristos __GMP_DECLSPEC void mpn_ior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
16286b942a58Schristos #define mpn_iorn_n __MPN(iorn_n)
16296b942a58Schristos __GMP_DECLSPEC void mpn_iorn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
16306b942a58Schristos #define mpn_nior_n __MPN(nior_n)
16316b942a58Schristos __GMP_DECLSPEC void mpn_nior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
16326b942a58Schristos #define mpn_xor_n __MPN(xor_n)
16336b942a58Schristos __GMP_DECLSPEC void mpn_xor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
16346b942a58Schristos #define mpn_xnor_n __MPN(xnor_n)
16356b942a58Schristos __GMP_DECLSPEC void mpn_xnor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
16366b942a58Schristos
16376b942a58Schristos #define mpn_copyi __MPN(copyi)
16386b942a58Schristos __GMP_DECLSPEC void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t);
16396b942a58Schristos #define mpn_copyd __MPN(copyd)
16406b942a58Schristos __GMP_DECLSPEC void mpn_copyd (mp_ptr, mp_srcptr, mp_size_t);
16416b942a58Schristos #define mpn_zero __MPN(zero)
16426b942a58Schristos __GMP_DECLSPEC void mpn_zero (mp_ptr, mp_size_t);
16436b942a58Schristos
16446b942a58Schristos #define mpn_cnd_add_n __MPN(cnd_add_n)
16456b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_cnd_add_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
16466b942a58Schristos #define mpn_cnd_sub_n __MPN(cnd_sub_n)
16476b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_cnd_sub_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
16486b942a58Schristos
16496b942a58Schristos #define mpn_sec_add_1 __MPN(sec_add_1)
16506b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_sec_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);
16516b942a58Schristos #define mpn_sec_add_1_itch __MPN(sec_add_1_itch)
16526b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_sec_add_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;
16536b942a58Schristos
16546b942a58Schristos #define mpn_sec_sub_1 __MPN(sec_sub_1)
16556b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_sec_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);
16566b942a58Schristos #define mpn_sec_sub_1_itch __MPN(sec_sub_1_itch)
16576b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_sec_sub_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;
16586b942a58Schristos
16596b942a58Schristos #define mpn_cnd_swap __MPN(cnd_swap)
16606b942a58Schristos __GMP_DECLSPEC void mpn_cnd_swap (mp_limb_t, volatile mp_limb_t *, volatile mp_limb_t *, mp_size_t);
16616b942a58Schristos
16626b942a58Schristos #define mpn_sec_mul __MPN(sec_mul)
16636b942a58Schristos __GMP_DECLSPEC void mpn_sec_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
16646b942a58Schristos #define mpn_sec_mul_itch __MPN(sec_mul_itch)
16656b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_sec_mul_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
16666b942a58Schristos
16676b942a58Schristos #define mpn_sec_sqr __MPN(sec_sqr)
16686b942a58Schristos __GMP_DECLSPEC void mpn_sec_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr);
16696b942a58Schristos #define mpn_sec_sqr_itch __MPN(sec_sqr_itch)
16706b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_sec_sqr_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;
16716b942a58Schristos
16726b942a58Schristos #define mpn_sec_powm __MPN(sec_powm)
16736b942a58Schristos __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);
16746b942a58Schristos #define mpn_sec_powm_itch __MPN(sec_powm_itch)
16756b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_sec_powm_itch (mp_size_t, mp_bitcnt_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
16766b942a58Schristos
16776b942a58Schristos #define mpn_sec_tabselect __MPN(sec_tabselect)
16786b942a58Schristos __GMP_DECLSPEC void mpn_sec_tabselect (volatile mp_limb_t *, volatile const mp_limb_t *, mp_size_t, mp_size_t, mp_size_t);
16796b942a58Schristos
16806b942a58Schristos #define mpn_sec_div_qr __MPN(sec_div_qr)
16816b942a58Schristos __GMP_DECLSPEC mp_limb_t mpn_sec_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
16826b942a58Schristos #define mpn_sec_div_qr_itch __MPN(sec_div_qr_itch)
16836b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_sec_div_qr_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
16846b942a58Schristos #define mpn_sec_div_r __MPN(sec_div_r)
16856b942a58Schristos __GMP_DECLSPEC void mpn_sec_div_r (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
16866b942a58Schristos #define mpn_sec_div_r_itch __MPN(sec_div_r_itch)
16876b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_sec_div_r_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;
16886b942a58Schristos
16896b942a58Schristos #define mpn_sec_invert __MPN(sec_invert)
16906b942a58Schristos __GMP_DECLSPEC int mpn_sec_invert (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_bitcnt_t, mp_ptr);
16916b942a58Schristos #define mpn_sec_invert_itch __MPN(sec_invert_itch)
16926b942a58Schristos __GMP_DECLSPEC mp_size_t mpn_sec_invert_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;
16936b942a58Schristos
1694*119a1bddSmrg #define mpn_udiv_w_sdiv __MPN(udiv_w_sdiv)
1695*119a1bddSmrg __GMP_DECLSPEC mp_limb_t mpn_udiv_w_sdiv (mp_limb_t *, mp_limb_t, mp_limb_t, mp_limb_t);
1696*119a1bddSmrg
16976b942a58Schristos
16986b942a58Schristos /**************** mpz inlines ****************/
16996b942a58Schristos
17006b942a58Schristos /* The following are provided as inlines where possible, but always exist as
17016b942a58Schristos library functions too, for binary compatibility.
17026b942a58Schristos
17036b942a58Schristos Within gmp itself this inlining generally isn't relied on, since it
17046b942a58Schristos doesn't get done for all compilers, whereas if something is worth
17056b942a58Schristos inlining then it's worth arranging always.
17066b942a58Schristos
17076b942a58Schristos There are two styles of inlining here. When the same bit of code is
17086b942a58Schristos wanted for the inline as for the library version, then __GMP_FORCE_foo
17096b942a58Schristos arranges for that code to be emitted and the __GMP_EXTERN_INLINE
17106b942a58Schristos directive suppressed, eg. mpz_fits_uint_p. When a different bit of code
17116b942a58Schristos is wanted for the inline than for the library version, then
17126b942a58Schristos __GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs. */
17136b942a58Schristos
17146b942a58Schristos #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs)
17156b942a58Schristos __GMP_EXTERN_INLINE void
mpz_abs(mpz_ptr __gmp_w,mpz_srcptr __gmp_u)17166b942a58Schristos mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)
17176b942a58Schristos {
17186b942a58Schristos if (__gmp_w != __gmp_u)
17196b942a58Schristos mpz_set (__gmp_w, __gmp_u);
17206b942a58Schristos __gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size);
17216b942a58Schristos }
17226b942a58Schristos #endif
17236b942a58Schristos
17246b942a58Schristos #if GMP_NAIL_BITS == 0
17256b942a58Schristos #define __GMPZ_FITS_UTYPE_P(z,maxval) \
17266b942a58Schristos mp_size_t __gmp_n = z->_mp_size; \
17276b942a58Schristos mp_ptr __gmp_p = z->_mp_d; \
17286b942a58Schristos return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval));
17296b942a58Schristos #else
17306b942a58Schristos #define __GMPZ_FITS_UTYPE_P(z,maxval) \
17316b942a58Schristos mp_size_t __gmp_n = z->_mp_size; \
17326b942a58Schristos mp_ptr __gmp_p = z->_mp_d; \
17336b942a58Schristos return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval) \
17346b942a58Schristos || (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS)));
17356b942a58Schristos #endif
17366b942a58Schristos
17376b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p)
17386b942a58Schristos #if ! defined (__GMP_FORCE_mpz_fits_uint_p)
17396b942a58Schristos __GMP_EXTERN_INLINE
17406b942a58Schristos #endif
17416b942a58Schristos int
mpz_fits_uint_p(mpz_srcptr __gmp_z)17426b942a58Schristos mpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
17436b942a58Schristos {
17446b942a58Schristos __GMPZ_FITS_UTYPE_P (__gmp_z, UINT_MAX);
17456b942a58Schristos }
17466b942a58Schristos #endif
17476b942a58Schristos
17486b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p)
17496b942a58Schristos #if ! defined (__GMP_FORCE_mpz_fits_ulong_p)
17506b942a58Schristos __GMP_EXTERN_INLINE
17516b942a58Schristos #endif
17526b942a58Schristos int
mpz_fits_ulong_p(mpz_srcptr __gmp_z)17536b942a58Schristos mpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
17546b942a58Schristos {
17556b942a58Schristos __GMPZ_FITS_UTYPE_P (__gmp_z, ULONG_MAX);
17566b942a58Schristos }
17576b942a58Schristos #endif
17586b942a58Schristos
17596b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p)
17606b942a58Schristos #if ! defined (__GMP_FORCE_mpz_fits_ushort_p)
17616b942a58Schristos __GMP_EXTERN_INLINE
17626b942a58Schristos #endif
17636b942a58Schristos int
mpz_fits_ushort_p(mpz_srcptr __gmp_z)17646b942a58Schristos mpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
17656b942a58Schristos {
17666b942a58Schristos __GMPZ_FITS_UTYPE_P (__gmp_z, USHRT_MAX);
17676b942a58Schristos }
17686b942a58Schristos #endif
17696b942a58Schristos
17706b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui)
17716b942a58Schristos #if ! defined (__GMP_FORCE_mpz_get_ui)
17726b942a58Schristos __GMP_EXTERN_INLINE
17736b942a58Schristos #endif
17746b942a58Schristos unsigned long
mpz_get_ui(mpz_srcptr __gmp_z)17756b942a58Schristos mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW
17766b942a58Schristos {
17776b942a58Schristos mp_ptr __gmp_p = __gmp_z->_mp_d;
17786b942a58Schristos mp_size_t __gmp_n = __gmp_z->_mp_size;
17796b942a58Schristos mp_limb_t __gmp_l = __gmp_p[0];
17806b942a58Schristos /* This is a "#if" rather than a plain "if" so as to avoid gcc warnings
17816b942a58Schristos about "<< GMP_NUMB_BITS" exceeding the type size, and to avoid Borland
17826b942a58Schristos C++ 6.0 warnings about condition always true for something like
17836b942a58Schristos "ULONG_MAX < GMP_NUMB_MASK". */
17846b942a58Schristos #if GMP_NAIL_BITS == 0 || defined (_LONG_LONG_LIMB)
17856b942a58Schristos /* limb==long and no nails, or limb==longlong, one limb is enough */
17866b942a58Schristos return (__gmp_n != 0 ? __gmp_l : 0);
17876b942a58Schristos #else
17886b942a58Schristos /* limb==long and nails, need two limbs when available */
17896b942a58Schristos __gmp_n = __GMP_ABS (__gmp_n);
17906b942a58Schristos if (__gmp_n <= 1)
17916b942a58Schristos return (__gmp_n != 0 ? __gmp_l : 0);
17926b942a58Schristos else
17936b942a58Schristos return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS);
17946b942a58Schristos #endif
17956b942a58Schristos }
17966b942a58Schristos #endif
17976b942a58Schristos
17986b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn)
17996b942a58Schristos #if ! defined (__GMP_FORCE_mpz_getlimbn)
18006b942a58Schristos __GMP_EXTERN_INLINE
18016b942a58Schristos #endif
18026b942a58Schristos mp_limb_t
mpz_getlimbn(mpz_srcptr __gmp_z,mp_size_t __gmp_n)18036b942a58Schristos mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW
18046b942a58Schristos {
18056b942a58Schristos mp_limb_t __gmp_result = 0;
18066b942a58Schristos if (__GMP_LIKELY (__gmp_n >= 0 && __gmp_n < __GMP_ABS (__gmp_z->_mp_size)))
18076b942a58Schristos __gmp_result = __gmp_z->_mp_d[__gmp_n];
18086b942a58Schristos return __gmp_result;
18096b942a58Schristos }
18106b942a58Schristos #endif
18116b942a58Schristos
18126b942a58Schristos #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg)
18136b942a58Schristos __GMP_EXTERN_INLINE void
mpz_neg(mpz_ptr __gmp_w,mpz_srcptr __gmp_u)18146b942a58Schristos mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)
18156b942a58Schristos {
18166b942a58Schristos if (__gmp_w != __gmp_u)
18176b942a58Schristos mpz_set (__gmp_w, __gmp_u);
18186b942a58Schristos __gmp_w->_mp_size = - __gmp_w->_mp_size;
18196b942a58Schristos }
18206b942a58Schristos #endif
18216b942a58Schristos
18226b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p)
18236b942a58Schristos #if ! defined (__GMP_FORCE_mpz_perfect_square_p)
18246b942a58Schristos __GMP_EXTERN_INLINE
18256b942a58Schristos #endif
18266b942a58Schristos int
mpz_perfect_square_p(mpz_srcptr __gmp_a)18276b942a58Schristos mpz_perfect_square_p (mpz_srcptr __gmp_a)
18286b942a58Schristos {
18296b942a58Schristos mp_size_t __gmp_asize;
18306b942a58Schristos int __gmp_result;
18316b942a58Schristos
18326b942a58Schristos __gmp_asize = __gmp_a->_mp_size;
18336b942a58Schristos __gmp_result = (__gmp_asize >= 0); /* zero is a square, negatives are not */
18346b942a58Schristos if (__GMP_LIKELY (__gmp_asize > 0))
18356b942a58Schristos __gmp_result = mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize);
18366b942a58Schristos return __gmp_result;
18376b942a58Schristos }
18386b942a58Schristos #endif
18396b942a58Schristos
18406b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount)
18416b942a58Schristos #if ! defined (__GMP_FORCE_mpz_popcount)
18426b942a58Schristos __GMP_EXTERN_INLINE
18436b942a58Schristos #endif
18446b942a58Schristos mp_bitcnt_t
mpz_popcount(mpz_srcptr __gmp_u)18456b942a58Schristos mpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW
18466b942a58Schristos {
18476b942a58Schristos mp_size_t __gmp_usize;
18486b942a58Schristos mp_bitcnt_t __gmp_result;
18496b942a58Schristos
18506b942a58Schristos __gmp_usize = __gmp_u->_mp_size;
18516b942a58Schristos __gmp_result = (__gmp_usize < 0 ? ~ __GMP_CAST (mp_bitcnt_t, 0) : __GMP_CAST (mp_bitcnt_t, 0));
18526b942a58Schristos if (__GMP_LIKELY (__gmp_usize > 0))
18536b942a58Schristos __gmp_result = mpn_popcount (__gmp_u->_mp_d, __gmp_usize);
18546b942a58Schristos return __gmp_result;
18556b942a58Schristos }
18566b942a58Schristos #endif
18576b942a58Schristos
18586b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q)
18596b942a58Schristos #if ! defined (__GMP_FORCE_mpz_set_q)
18606b942a58Schristos __GMP_EXTERN_INLINE
18616b942a58Schristos #endif
18626b942a58Schristos void
mpz_set_q(mpz_ptr __gmp_w,mpq_srcptr __gmp_u)18636b942a58Schristos mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u)
18646b942a58Schristos {
18656b942a58Schristos mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u));
18666b942a58Schristos }
18676b942a58Schristos #endif
18686b942a58Schristos
18696b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size)
18706b942a58Schristos #if ! defined (__GMP_FORCE_mpz_size)
18716b942a58Schristos __GMP_EXTERN_INLINE
18726b942a58Schristos #endif
18736b942a58Schristos size_t
mpz_size(mpz_srcptr __gmp_z)18746b942a58Schristos mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW
18756b942a58Schristos {
18766b942a58Schristos return __GMP_ABS (__gmp_z->_mp_size);
18776b942a58Schristos }
18786b942a58Schristos #endif
18796b942a58Schristos
18806b942a58Schristos
18816b942a58Schristos /**************** mpq inlines ****************/
18826b942a58Schristos
18836b942a58Schristos #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs)
18846b942a58Schristos __GMP_EXTERN_INLINE void
mpq_abs(mpq_ptr __gmp_w,mpq_srcptr __gmp_u)18856b942a58Schristos mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)
18866b942a58Schristos {
18876b942a58Schristos if (__gmp_w != __gmp_u)
18886b942a58Schristos mpq_set (__gmp_w, __gmp_u);
18896b942a58Schristos __gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size);
18906b942a58Schristos }
18916b942a58Schristos #endif
18926b942a58Schristos
18936b942a58Schristos #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg)
18946b942a58Schristos __GMP_EXTERN_INLINE void
mpq_neg(mpq_ptr __gmp_w,mpq_srcptr __gmp_u)18956b942a58Schristos mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)
18966b942a58Schristos {
18976b942a58Schristos if (__gmp_w != __gmp_u)
18986b942a58Schristos mpq_set (__gmp_w, __gmp_u);
18996b942a58Schristos __gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size;
19006b942a58Schristos }
19016b942a58Schristos #endif
19026b942a58Schristos
19036b942a58Schristos
19046b942a58Schristos /**************** mpn inlines ****************/
19056b942a58Schristos
19066b942a58Schristos /* The comments with __GMPN_ADD_1 below apply here too.
19076b942a58Schristos
19086b942a58Schristos The test for FUNCTION returning 0 should predict well. If it's assumed
19096b942a58Schristos {yp,ysize} will usually have a random number of bits then the high limb
19106b942a58Schristos won't be full and a carry out will occur a good deal less than 50% of the
19116b942a58Schristos time.
19126b942a58Schristos
19136b942a58Schristos ysize==0 isn't a documented feature, but is used internally in a few
19146b942a58Schristos places.
19156b942a58Schristos
19166b942a58Schristos Producing cout last stops it using up a register during the main part of
19176b942a58Schristos the calculation, though gcc (as of 3.0) on an "if (mpn_add (...))"
19186b942a58Schristos doesn't seem able to move the true and false legs of the conditional up
19196b942a58Schristos to the two places cout is generated. */
19206b942a58Schristos
19216b942a58Schristos #define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST) \
19226b942a58Schristos do { \
19236b942a58Schristos mp_size_t __gmp_i; \
19246b942a58Schristos mp_limb_t __gmp_x; \
19256b942a58Schristos \
19266b942a58Schristos /* ASSERT ((ysize) >= 0); */ \
19276b942a58Schristos /* ASSERT ((xsize) >= (ysize)); */ \
19286b942a58Schristos /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */ \
19296b942a58Schristos /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */ \
19306b942a58Schristos \
19316b942a58Schristos __gmp_i = (ysize); \
19326b942a58Schristos if (__gmp_i != 0) \
19336b942a58Schristos { \
19346b942a58Schristos if (FUNCTION (wp, xp, yp, __gmp_i)) \
19356b942a58Schristos { \
19366b942a58Schristos do \
19376b942a58Schristos { \
19386b942a58Schristos if (__gmp_i >= (xsize)) \
19396b942a58Schristos { \
19406b942a58Schristos (cout) = 1; \
19416b942a58Schristos goto __gmp_done; \
19426b942a58Schristos } \
19436b942a58Schristos __gmp_x = (xp)[__gmp_i]; \
19446b942a58Schristos } \
19456b942a58Schristos while (TEST); \
19466b942a58Schristos } \
19476b942a58Schristos } \
19486b942a58Schristos if ((wp) != (xp)) \
19496b942a58Schristos __GMPN_COPY_REST (wp, xp, xsize, __gmp_i); \
19506b942a58Schristos (cout) = 0; \
19516b942a58Schristos __gmp_done: \
19526b942a58Schristos ; \
19536b942a58Schristos } while (0)
19546b942a58Schristos
19556b942a58Schristos #define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize) \
19566b942a58Schristos __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n, \
19576b942a58Schristos (((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0))
19586b942a58Schristos #define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize) \
19596b942a58Schristos __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n, \
19606b942a58Schristos (((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0))
19616b942a58Schristos
19626b942a58Schristos
19636b942a58Schristos /* The use of __gmp_i indexing is designed to ensure a compile time src==dst
19646b942a58Schristos remains nice and clear to the compiler, so that __GMPN_COPY_REST can
19656b942a58Schristos disappear, and the load/add/store gets a chance to become a
19666b942a58Schristos read-modify-write on CISC CPUs.
19676b942a58Schristos
19686b942a58Schristos Alternatives:
19696b942a58Schristos
19706b942a58Schristos Using a pair of pointers instead of indexing would be possible, but gcc
19716b942a58Schristos isn't able to recognise compile-time src==dst in that case, even when the
19726b942a58Schristos pointers are incremented more or less together. Other compilers would
19736b942a58Schristos very likely have similar difficulty.
19746b942a58Schristos
19756b942a58Schristos gcc could use "if (__builtin_constant_p(src==dst) && src==dst)" or
19766b942a58Schristos similar to detect a compile-time src==dst. This works nicely on gcc
19776b942a58Schristos 2.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems
19786b942a58Schristos to be always false, for a pointer p. But the current code form seems
19796b942a58Schristos good enough for src==dst anyway.
19806b942a58Schristos
19816b942a58Schristos gcc on x86 as usual doesn't give particularly good flags handling for the
19826b942a58Schristos carry/borrow detection. It's tempting to want some multi instruction asm
19836b942a58Schristos blocks to help it, and this was tried, but in truth there's only a few
19846b942a58Schristos instructions to save and any gain is all too easily lost by register
19856b942a58Schristos juggling setting up for the asm. */
19866b942a58Schristos
19876b942a58Schristos #if GMP_NAIL_BITS == 0
19886b942a58Schristos #define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \
19896b942a58Schristos do { \
19906b942a58Schristos mp_size_t __gmp_i; \
19916b942a58Schristos mp_limb_t __gmp_x, __gmp_r; \
19926b942a58Schristos \
19936b942a58Schristos /* ASSERT ((n) >= 1); */ \
19946b942a58Schristos /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \
19956b942a58Schristos \
19966b942a58Schristos __gmp_x = (src)[0]; \
19976b942a58Schristos __gmp_r = __gmp_x OP (v); \
19986b942a58Schristos (dst)[0] = __gmp_r; \
19996b942a58Schristos if (CB (__gmp_r, __gmp_x, (v))) \
20006b942a58Schristos { \
20016b942a58Schristos (cout) = 1; \
20026b942a58Schristos for (__gmp_i = 1; __gmp_i < (n);) \
20036b942a58Schristos { \
20046b942a58Schristos __gmp_x = (src)[__gmp_i]; \
20056b942a58Schristos __gmp_r = __gmp_x OP 1; \
20066b942a58Schristos (dst)[__gmp_i] = __gmp_r; \
20076b942a58Schristos ++__gmp_i; \
20086b942a58Schristos if (!CB (__gmp_r, __gmp_x, 1)) \
20096b942a58Schristos { \
20106b942a58Schristos if ((src) != (dst)) \
20116b942a58Schristos __GMPN_COPY_REST (dst, src, n, __gmp_i); \
20126b942a58Schristos (cout) = 0; \
20136b942a58Schristos break; \
20146b942a58Schristos } \
20156b942a58Schristos } \
20166b942a58Schristos } \
20176b942a58Schristos else \
20186b942a58Schristos { \
20196b942a58Schristos if ((src) != (dst)) \
20206b942a58Schristos __GMPN_COPY_REST (dst, src, n, 1); \
20216b942a58Schristos (cout) = 0; \
20226b942a58Schristos } \
20236b942a58Schristos } while (0)
20246b942a58Schristos #endif
20256b942a58Schristos
20266b942a58Schristos #if GMP_NAIL_BITS >= 1
20276b942a58Schristos #define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \
20286b942a58Schristos do { \
20296b942a58Schristos mp_size_t __gmp_i; \
20306b942a58Schristos mp_limb_t __gmp_x, __gmp_r; \
20316b942a58Schristos \
20326b942a58Schristos /* ASSERT ((n) >= 1); */ \
20336b942a58Schristos /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \
20346b942a58Schristos \
20356b942a58Schristos __gmp_x = (src)[0]; \
20366b942a58Schristos __gmp_r = __gmp_x OP (v); \
20376b942a58Schristos (dst)[0] = __gmp_r & GMP_NUMB_MASK; \
20386b942a58Schristos if (__gmp_r >> GMP_NUMB_BITS != 0) \
20396b942a58Schristos { \
20406b942a58Schristos (cout) = 1; \
20416b942a58Schristos for (__gmp_i = 1; __gmp_i < (n);) \
20426b942a58Schristos { \
20436b942a58Schristos __gmp_x = (src)[__gmp_i]; \
20446b942a58Schristos __gmp_r = __gmp_x OP 1; \
20456b942a58Schristos (dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK; \
20466b942a58Schristos ++__gmp_i; \
20476b942a58Schristos if (__gmp_r >> GMP_NUMB_BITS == 0) \
20486b942a58Schristos { \
20496b942a58Schristos if ((src) != (dst)) \
20506b942a58Schristos __GMPN_COPY_REST (dst, src, n, __gmp_i); \
20516b942a58Schristos (cout) = 0; \
20526b942a58Schristos break; \
20536b942a58Schristos } \
20546b942a58Schristos } \
20556b942a58Schristos } \
20566b942a58Schristos else \
20576b942a58Schristos { \
20586b942a58Schristos if ((src) != (dst)) \
20596b942a58Schristos __GMPN_COPY_REST (dst, src, n, 1); \
20606b942a58Schristos (cout) = 0; \
20616b942a58Schristos } \
20626b942a58Schristos } while (0)
20636b942a58Schristos #endif
20646b942a58Schristos
20656b942a58Schristos #define __GMPN_ADDCB(r,x,y) ((r) < (y))
20666b942a58Schristos #define __GMPN_SUBCB(r,x,y) ((x) < (y))
20676b942a58Schristos
20686b942a58Schristos #define __GMPN_ADD_1(cout, dst, src, n, v) \
20696b942a58Schristos __GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB)
20706b942a58Schristos #define __GMPN_SUB_1(cout, dst, src, n, v) \
20716b942a58Schristos __GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB)
20726b942a58Schristos
20736b942a58Schristos
20746b942a58Schristos /* Compare {xp,size} and {yp,size}, setting "result" to positive, zero or
20756b942a58Schristos negative. size==0 is allowed. On random data usually only one limb will
20766b942a58Schristos need to be examined to get a result, so it's worth having it inline. */
20776b942a58Schristos #define __GMPN_CMP(result, xp, yp, size) \
20786b942a58Schristos do { \
20796b942a58Schristos mp_size_t __gmp_i; \
20806b942a58Schristos mp_limb_t __gmp_x, __gmp_y; \
20816b942a58Schristos \
20826b942a58Schristos /* ASSERT ((size) >= 0); */ \
20836b942a58Schristos \
20846b942a58Schristos (result) = 0; \
20856b942a58Schristos __gmp_i = (size); \
20866b942a58Schristos while (--__gmp_i >= 0) \
20876b942a58Schristos { \
20886b942a58Schristos __gmp_x = (xp)[__gmp_i]; \
20896b942a58Schristos __gmp_y = (yp)[__gmp_i]; \
20906b942a58Schristos if (__gmp_x != __gmp_y) \
20916b942a58Schristos { \
20926b942a58Schristos /* Cannot use __gmp_x - __gmp_y, may overflow an "int" */ \
20936b942a58Schristos (result) = (__gmp_x > __gmp_y ? 1 : -1); \
20946b942a58Schristos break; \
20956b942a58Schristos } \
20966b942a58Schristos } \
20976b942a58Schristos } while (0)
20986b942a58Schristos
20996b942a58Schristos
21006b942a58Schristos #if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST)
21016b942a58Schristos #define __GMPN_COPY_REST(dst, src, size, start) \
21026b942a58Schristos do { \
21036b942a58Schristos /* ASSERT ((start) >= 0); */ \
21046b942a58Schristos /* ASSERT ((start) <= (size)); */ \
21056b942a58Schristos __GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \
21066b942a58Schristos } while (0)
21076b942a58Schristos #endif
21086b942a58Schristos
21096b942a58Schristos /* Copy {src,size} to {dst,size}, starting at "start". This is designed to
21106b942a58Schristos keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1,
21116b942a58Schristos __GMPN_ADD, etc. */
21126b942a58Schristos #if ! defined (__GMPN_COPY_REST)
21136b942a58Schristos #define __GMPN_COPY_REST(dst, src, size, start) \
21146b942a58Schristos do { \
21156b942a58Schristos mp_size_t __gmp_j; \
21166b942a58Schristos /* ASSERT ((size) >= 0); */ \
21176b942a58Schristos /* ASSERT ((start) >= 0); */ \
21186b942a58Schristos /* ASSERT ((start) <= (size)); */ \
21196b942a58Schristos /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */ \
21206b942a58Schristos __GMP_CRAY_Pragma ("_CRI ivdep"); \
21216b942a58Schristos for (__gmp_j = (start); __gmp_j < (size); __gmp_j++) \
21226b942a58Schristos (dst)[__gmp_j] = (src)[__gmp_j]; \
21236b942a58Schristos } while (0)
21246b942a58Schristos #endif
21256b942a58Schristos
21266b942a58Schristos /* Enhancement: Use some of the smarter code from gmp-impl.h. Maybe use
21276b942a58Schristos mpn_copyi if there's a native version, and if we don't mind demanding
21286b942a58Schristos binary compatibility for it (on targets which use it). */
21296b942a58Schristos
21306b942a58Schristos #if ! defined (__GMPN_COPY)
21316b942a58Schristos #define __GMPN_COPY(dst, src, size) __GMPN_COPY_REST (dst, src, size, 0)
21326b942a58Schristos #endif
21336b942a58Schristos
21346b942a58Schristos
21356b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add)
21366b942a58Schristos #if ! defined (__GMP_FORCE_mpn_add)
21376b942a58Schristos __GMP_EXTERN_INLINE
21386b942a58Schristos #endif
21396b942a58Schristos mp_limb_t
mpn_add(mp_ptr __gmp_wp,mp_srcptr __gmp_xp,mp_size_t __gmp_xsize,mp_srcptr __gmp_yp,mp_size_t __gmp_ysize)21406b942a58Schristos mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)
21416b942a58Schristos {
21426b942a58Schristos mp_limb_t __gmp_c;
21436b942a58Schristos __GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);
21446b942a58Schristos return __gmp_c;
21456b942a58Schristos }
21466b942a58Schristos #endif
21476b942a58Schristos
21486b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1)
21496b942a58Schristos #if ! defined (__GMP_FORCE_mpn_add_1)
21506b942a58Schristos __GMP_EXTERN_INLINE
21516b942a58Schristos #endif
21526b942a58Schristos mp_limb_t
mpn_add_1(mp_ptr __gmp_dst,mp_srcptr __gmp_src,mp_size_t __gmp_size,mp_limb_t __gmp_n)21536b942a58Schristos mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW
21546b942a58Schristos {
21556b942a58Schristos mp_limb_t __gmp_c;
21566b942a58Schristos __GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);
21576b942a58Schristos return __gmp_c;
21586b942a58Schristos }
21596b942a58Schristos #endif
21606b942a58Schristos
21616b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp)
21626b942a58Schristos #if ! defined (__GMP_FORCE_mpn_cmp)
21636b942a58Schristos __GMP_EXTERN_INLINE
21646b942a58Schristos #endif
21656b942a58Schristos int
mpn_cmp(mp_srcptr __gmp_xp,mp_srcptr __gmp_yp,mp_size_t __gmp_size)21666b942a58Schristos mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW
21676b942a58Schristos {
21686b942a58Schristos int __gmp_result;
21696b942a58Schristos __GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size);
21706b942a58Schristos return __gmp_result;
21716b942a58Schristos }
21726b942a58Schristos #endif
21736b942a58Schristos
21746b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_zero_p)
21756b942a58Schristos #if ! defined (__GMP_FORCE_mpn_zero_p)
21766b942a58Schristos __GMP_EXTERN_INLINE
21776b942a58Schristos #endif
21786b942a58Schristos int
mpn_zero_p(mp_srcptr __gmp_p,mp_size_t __gmp_n)21796b942a58Schristos mpn_zero_p (mp_srcptr __gmp_p, mp_size_t __gmp_n) __GMP_NOTHROW
21806b942a58Schristos {
21816b942a58Schristos /* if (__GMP_LIKELY (__gmp_n > 0)) */
21826b942a58Schristos do {
21836b942a58Schristos if (__gmp_p[--__gmp_n] != 0)
21846b942a58Schristos return 0;
21856b942a58Schristos } while (__gmp_n != 0);
21866b942a58Schristos return 1;
21876b942a58Schristos }
21886b942a58Schristos #endif
21896b942a58Schristos
21906b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub)
21916b942a58Schristos #if ! defined (__GMP_FORCE_mpn_sub)
21926b942a58Schristos __GMP_EXTERN_INLINE
21936b942a58Schristos #endif
21946b942a58Schristos mp_limb_t
mpn_sub(mp_ptr __gmp_wp,mp_srcptr __gmp_xp,mp_size_t __gmp_xsize,mp_srcptr __gmp_yp,mp_size_t __gmp_ysize)21956b942a58Schristos mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)
21966b942a58Schristos {
21976b942a58Schristos mp_limb_t __gmp_c;
21986b942a58Schristos __GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);
21996b942a58Schristos return __gmp_c;
22006b942a58Schristos }
22016b942a58Schristos #endif
22026b942a58Schristos
22036b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1)
22046b942a58Schristos #if ! defined (__GMP_FORCE_mpn_sub_1)
22056b942a58Schristos __GMP_EXTERN_INLINE
22066b942a58Schristos #endif
22076b942a58Schristos mp_limb_t
mpn_sub_1(mp_ptr __gmp_dst,mp_srcptr __gmp_src,mp_size_t __gmp_size,mp_limb_t __gmp_n)22086b942a58Schristos mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW
22096b942a58Schristos {
22106b942a58Schristos mp_limb_t __gmp_c;
22116b942a58Schristos __GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);
22126b942a58Schristos return __gmp_c;
22136b942a58Schristos }
22146b942a58Schristos #endif
22156b942a58Schristos
22166b942a58Schristos #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_neg)
22176b942a58Schristos #if ! defined (__GMP_FORCE_mpn_neg)
22186b942a58Schristos __GMP_EXTERN_INLINE
22196b942a58Schristos #endif
22206b942a58Schristos mp_limb_t
mpn_neg(mp_ptr __gmp_rp,mp_srcptr __gmp_up,mp_size_t __gmp_n)22216b942a58Schristos mpn_neg (mp_ptr __gmp_rp, mp_srcptr __gmp_up, mp_size_t __gmp_n)
22226b942a58Schristos {
22236b942a58Schristos while (*__gmp_up == 0) /* Low zero limbs are unchanged by negation. */
22246b942a58Schristos {
22256b942a58Schristos *__gmp_rp = 0;
22266b942a58Schristos if (!--__gmp_n) /* All zero */
22276b942a58Schristos return 0;
22286b942a58Schristos ++__gmp_up; ++__gmp_rp;
22296b942a58Schristos }
22306b942a58Schristos
22316b942a58Schristos *__gmp_rp = (- *__gmp_up) & GMP_NUMB_MASK;
22326b942a58Schristos
22336b942a58Schristos if (--__gmp_n) /* Higher limbs get complemented. */
22346b942a58Schristos mpn_com (++__gmp_rp, ++__gmp_up, __gmp_n);
22356b942a58Schristos
22366b942a58Schristos return 1;
22376b942a58Schristos }
22386b942a58Schristos #endif
22396b942a58Schristos
22406b942a58Schristos #if defined (__cplusplus)
22416b942a58Schristos }
22426b942a58Schristos #endif
22436b942a58Schristos
22446b942a58Schristos
22456b942a58Schristos /* Allow faster testing for negative, zero, and positive. */
22466b942a58Schristos #define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
22476b942a58Schristos #define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)
22486b942a58Schristos #define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0)
22496b942a58Schristos
22506b942a58Schristos /* When using GCC, optimize certain common comparisons. */
22516b942a58Schristos #if defined (__GNUC__) && __GNUC__ >= 2
22526b942a58Schristos #define mpz_cmp_ui(Z,UI) \
22536b942a58Schristos (__builtin_constant_p (UI) && (UI) == 0 \
22546b942a58Schristos ? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))
22556b942a58Schristos #define mpz_cmp_si(Z,SI) \
22566b942a58Schristos (__builtin_constant_p ((SI) >= 0) && (SI) >= 0 \
22576b942a58Schristos ? mpz_cmp_ui (Z, __GMP_CAST (unsigned long, SI)) \
22586b942a58Schristos : _mpz_cmp_si (Z,SI))
22596b942a58Schristos #define mpq_cmp_ui(Q,NUI,DUI) \
22606b942a58Schristos (__builtin_constant_p (NUI) && (NUI) == 0 ? mpq_sgn (Q) \
22616b942a58Schristos : __builtin_constant_p ((NUI) == (DUI)) && (NUI) == (DUI) \
22626b942a58Schristos ? mpz_cmp (mpq_numref (Q), mpq_denref (Q)) \
22636b942a58Schristos : _mpq_cmp_ui (Q,NUI,DUI))
22646b942a58Schristos #define mpq_cmp_si(q,n,d) \
22656b942a58Schristos (__builtin_constant_p ((n) >= 0) && (n) >= 0 \
22666b942a58Schristos ? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d) \
22676b942a58Schristos : _mpq_cmp_si (q, n, d))
22686b942a58Schristos #else
22696b942a58Schristos #define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI)
22706b942a58Schristos #define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI)
22716b942a58Schristos #define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI)
22726b942a58Schristos #define mpq_cmp_si(q,n,d) _mpq_cmp_si(q,n,d)
22736b942a58Schristos #endif
22746b942a58Schristos
22756b942a58Schristos
22766b942a58Schristos /* Using "&" rather than "&&" means these can come out branch-free. Every
22776b942a58Schristos mpz_t has at least one limb allocated, so fetching the low limb is always
22786b942a58Schristos allowed. */
22796b942a58Schristos #define mpz_odd_p(z) (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0]))
22806b942a58Schristos #define mpz_even_p(z) (! mpz_odd_p (z))
22816b942a58Schristos
22826b942a58Schristos
22836b942a58Schristos /**************** C++ routines ****************/
22846b942a58Schristos
22856b942a58Schristos #ifdef __cplusplus
22866b942a58Schristos __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr);
22876b942a58Schristos __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr);
22886b942a58Schristos __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr);
22896b942a58Schristos __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr);
22906b942a58Schristos __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr);
22916b942a58Schristos __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr);
22926b942a58Schristos #endif
22936b942a58Schristos
22946b942a58Schristos
22956b942a58Schristos /* Source-level compatibility with GMP 2 and earlier. */
22966b942a58Schristos #define mpn_divmod(qp,np,nsize,dp,dsize) \
22976b942a58Schristos mpn_divrem (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dp, dsize)
22986b942a58Schristos
22996b942a58Schristos /* Source-level compatibility with GMP 1. */
23006b942a58Schristos #define mpz_mdiv mpz_fdiv_q
23016b942a58Schristos #define mpz_mdivmod mpz_fdiv_qr
23026b942a58Schristos #define mpz_mmod mpz_fdiv_r
23036b942a58Schristos #define mpz_mdiv_ui mpz_fdiv_q_ui
23046b942a58Schristos #define mpz_mdivmod_ui(q,r,n,d) \
23056b942a58Schristos (((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d))
23066b942a58Schristos #define mpz_mmod_ui(r,n,d) \
23076b942a58Schristos (((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d))
23086b942a58Schristos
23096b942a58Schristos /* Useful synonyms, but not quite compatible with GMP 1. */
23106b942a58Schristos #define mpz_div mpz_fdiv_q
23116b942a58Schristos #define mpz_divmod mpz_fdiv_qr
23126b942a58Schristos #define mpz_div_ui mpz_fdiv_q_ui
23136b942a58Schristos #define mpz_divmod_ui mpz_fdiv_qr_ui
23146b942a58Schristos #define mpz_div_2exp mpz_fdiv_q_2exp
23156b942a58Schristos #define mpz_mod_2exp mpz_fdiv_r_2exp
23166b942a58Schristos
23176b942a58Schristos enum
23186b942a58Schristos {
23196b942a58Schristos GMP_ERROR_NONE = 0,
23206b942a58Schristos GMP_ERROR_UNSUPPORTED_ARGUMENT = 1,
23216b942a58Schristos GMP_ERROR_DIVISION_BY_ZERO = 2,
23226b942a58Schristos GMP_ERROR_SQRT_OF_NEGATIVE = 4,
23236b942a58Schristos GMP_ERROR_INVALID_ARGUMENT = 8
23246b942a58Schristos };
23256b942a58Schristos
23266b942a58Schristos /* Define CC and CFLAGS which were used to build this version of GMP */
23276b942a58Schristos #define __GMP_CC "gcc"
2328*119a1bddSmrg #define __GMP_CFLAGS "-O2 -pedantic"
23296b942a58Schristos
23306b942a58Schristos /* Major version number is the value of __GNU_MP__ too, above. */
23316b942a58Schristos #define __GNU_MP_VERSION 6
23326b942a58Schristos #define __GNU_MP_VERSION_MINOR 2
2333*119a1bddSmrg #define __GNU_MP_VERSION_PATCHLEVEL 1
23346b942a58Schristos #define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL)
23356b942a58Schristos
23366b942a58Schristos #define __GMP_H__
23376b942a58Schristos #endif /* __GMP_H__ */
2338