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