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