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