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