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