1
/* Definitions for GNU multiple precision functions. -*- mode: c -*-
3
Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
4
2004 Free Software Foundation, Inc.
6
This file is part of the GNU MP Library.
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.
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.
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. */
25
#if defined (__cplusplus)
26
#include <iosfwd> /* for istream, ostream */
29
/* Instantiated by configure. */
30
#if ! defined (__GMP_WITHIN_CONFIGURE)
31
#define __GMP_BITS_PER_MP_LIMB 32
32
#define __GMP_HAVE_HOST_CPU_FAMILY_power 0
33
#define __GMP_HAVE_HOST_CPU_FAMILY_powerpc 0
34
#define GMP_LIMB_BITS 32
35
#define GMP_NAIL_BITS 0
37
#define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS)
38
#define GMP_NUMB_MASK ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS)
39
#define GMP_NUMB_MAX GMP_NUMB_MASK
40
#define GMP_NAIL_MASK (~ GMP_NUMB_MASK)
42
/* The following (everything under ifndef __GNU_MP__) must be identical in
43
gmp.h and mp.h to allow both to be included in an application or during
48
#define __need_size_t /* tell gcc stddef.h we only want size_t */
49
#if defined (__cplusplus)
50
#include <cstddef> /* for size_t */
52
#include <stddef.h> /* for size_t */
56
/* Instantiated by configure. */
57
#if ! defined (__GMP_WITHIN_CONFIGURE)
58
#undef _LONG_LONG_LIMB
61
/* __STDC__ - some ANSI compilers define this only to 0, hence the use of
62
"defined" and not "__STDC__-0". In particular Sun workshop C 5.0
63
sets __STDC__ to 0, but requires "##" for token pasting.
65
_AIX - gnu ansidecl.h asserts that all known AIX compilers are ANSI but
66
don't always define __STDC__.
68
_mips - gnu ansidecl.h says the RISC/OS MIPS compiler is ANSI in SVR4
69
mode, but doesn't define __STDC__.
71
_MSC_VER - Microsoft C is ANSI, but __STDC__ is undefined unless the /Za
72
option is given (in which case it's 1).
74
_WIN32 - tested for by gnu ansidecl.h, no doubt on the assumption that
75
all w32 compilers are ansi. */
77
#if defined (__STDC__) \
78
|| defined (__cplusplus) \
81
|| (defined (__mips) && defined (_SYSTYPE_SVR4)) \
82
|| defined (_MSC_VER) \
84
#define __GMP_HAVE_CONST 1
85
#define __GMP_HAVE_PROTOTYPES 1
86
#define __GMP_HAVE_TOKEN_PASTE 1
88
#define __GMP_HAVE_CONST 0
89
#define __GMP_HAVE_PROTOTYPES 0
90
#define __GMP_HAVE_TOKEN_PASTE 0
95
#define __gmp_const const
96
#define __gmp_signed signed
103
/* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in
104
all other circumstances.
106
When compiling objects for libgmp, __GMP_DECLSPEC is an export directive,
107
or when compiling for an application it's an import directive. The two
108
cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles
109
(and not defined from an application).
111
__GMP_DECLSPEC_XX is similarly used for libgmpxx. __GMP_WITHIN_GMPXX
112
indicates when building libgmpxx, and in that case libgmpxx functions are
113
exports, but libgmp functions which might get called are imports.
115
libmp.la uses __GMP_DECLSPEC, just as if it were libgmp.la. libgmp and
116
libmp don't call each other, so there's no conflict or confusion.
118
Libtool DLL_EXPORT define is not used.
120
There's no attempt to support GMP built both static and DLL. Doing so
121
would mean applications would have to tell us which of the two is going
122
to be used when linking, and that seems very tedious and error prone if
123
using GMP by hand, and equally tedious from a package since autoconf and
124
automake don't give much help.
126
__GMP_DECLSPEC is required on all documented global functions and
127
variables, the various internals in gmp-impl.h etc can be left unadorned.
128
But internals used by the test programs or speed measuring programs
129
should have __GMP_DECLSPEC, and certainly constants or variables must
130
have it or the wrong address will be resolved. */
132
#if defined (__GNUC__)
133
#define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__)
134
#define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__)
136
#if defined (_MSC_VER) || defined (__BORLANDC__)
137
#define __GMP_DECLSPEC_EXPORT __declspec(dllexport)
138
#define __GMP_DECLSPEC_IMPORT __declspec(dllimport)
141
#define __GMP_DECLSPEC_EXPORT __export
142
#define __GMP_DECLSPEC_IMPORT __import
145
#define __GMP_DECLSPEC_EXPORT _Export
146
#define __GMP_DECLSPEC_IMPORT _Import
151
/* compiling to go into a DLL libgmp */
152
#define __GMP_DECLSPEC __GMP_DECLSPEC_EXPORT
154
/* compiling to go into an application which will link to a DLL libgmp */
155
#define __GMP_DECLSPEC __GMP_DECLSPEC_IMPORT
158
/* all other cases */
159
#define __GMP_DECLSPEC
163
#ifdef __GMP_SHORT_LIMB
164
typedef unsigned int mp_limb_t;
165
typedef int mp_limb_signed_t;
167
#ifdef _LONG_LONG_LIMB
168
typedef unsigned long long int mp_limb_t;
169
typedef long long int mp_limb_signed_t;
171
typedef unsigned long int mp_limb_t;
172
typedef long int mp_limb_signed_t;
176
typedef mp_limb_t * mp_ptr;
177
typedef __gmp_const mp_limb_t * mp_srcptr;
178
#if defined (_CRAY) && ! defined (_CRAYMPP)
179
/* plain `int' is much faster (48 bits) */
180
#define __GMP_MP_SIZE_T_INT 1
181
typedef int mp_size_t;
182
typedef int mp_exp_t;
184
#define __GMP_MP_SIZE_T_INT 0
185
typedef long int mp_size_t;
186
typedef long int mp_exp_t;
191
int _mp_alloc; /* Number of *limbs* allocated and pointed
192
to by the _mp_d field. */
193
int _mp_size; /* abs(_mp_size) is the number of limbs the
194
last field points to. If _mp_size is
195
negative this is a negative number. */
196
mp_limb_t *_mp_d; /* Pointer to the limbs. */
198
#endif /* __GNU_MP__ */
200
typedef __mpz_struct MP_INT;
201
typedef __mpz_struct mpz_t[1];
205
__mpz_struct _mp_num;
206
__mpz_struct _mp_den;
209
typedef __mpq_struct MP_RAT;
210
typedef __mpq_struct mpq_t[1];
214
int _mp_prec; /* Max precision, in number of `mp_limb_t's.
215
Set by mpf_init and modified by
216
mpf_set_prec. The area pointed to by the
217
_mp_d field contains `prec' + 1 limbs. */
218
int _mp_size; /* abs(_mp_size) is the number of limbs the
219
last field points to. If _mp_size is
220
negative this is a negative number. */
221
mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */
222
mp_limb_t *_mp_d; /* Pointer to the limbs. */
225
/* typedef __mpf_struct MP_FLOAT; */
226
typedef __mpf_struct mpf_t[1];
228
/* Available random number generation algorithms. */
231
GMP_RAND_ALG_DEFAULT = 0,
232
GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */
235
/* Linear congruential data struct. */
237
mpz_t _mp_a; /* Multiplier. */
238
unsigned long int _mp_c; /* Adder. */
239
mpz_t _mp_m; /* Modulus (valid only if m2exp == 0). */
240
unsigned long int _mp_m2exp; /* If != 0, modulus is 2 ^ m2exp. */
243
/* Random state struct. */
246
mpz_t _mp_seed; /* Current seed. */
247
gmp_randalg_t _mp_alg; /* Algorithm used. */
248
union { /* Algorithm specific data. */
249
__gmp_randata_lc *_mp_lc; /* Linear congruential. */
251
} __gmp_randstate_struct;
252
typedef __gmp_randstate_struct gmp_randstate_t[1];
254
/* Types for function declarations in gmp files. */
255
/* ??? Should not pollute user name space with these ??? */
256
typedef __gmp_const __mpz_struct *mpz_srcptr;
257
typedef __mpz_struct *mpz_ptr;
258
typedef __gmp_const __mpf_struct *mpf_srcptr;
259
typedef __mpf_struct *mpf_ptr;
260
typedef __gmp_const __mpq_struct *mpq_srcptr;
261
typedef __mpq_struct *mpq_ptr;
264
/* This is not wanted in mp.h, so put it outside the __GNU_MP__ common
267
#if __GMP_WITHIN_GMPXX
268
/* compiling to go into a DLL libgmpxx */
269
#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_EXPORT
271
/* compiling to go into a application which will link to a DLL libgmpxx */
272
#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_IMPORT
275
/* all other cases */
276
#define __GMP_DECLSPEC_XX
279
#if __GMP_HAVE_PROTOTYPES
280
#define __GMP_PROTO(x) x
282
#define __GMP_PROTO(x) ()
286
#if __GMP_HAVE_TOKEN_PASTE
287
#define __MPN(x) __gmpn_##x
289
#define __MPN(x) __gmpn_/**/x
294
|| defined (H_STDIO) \
295
|| defined (_H_STDIO) /* AIX */ \
296
|| defined (_STDIO_H) /* glibc, Sun, SCO */ \
297
|| defined (_STDIO_H_) /* BSD, OSF */ \
298
|| defined (__STDIO_H) /* Borland */ \
299
|| defined (__STDIO_H__) /* IRIX */ \
300
|| defined (_STDIO_INCLUDED) /* HPUX */ \
301
|| defined (__dj_include_stdio_h_) /* DJGPP */ \
302
|| defined (_FILE_DEFINED) /* Microsoft */ \
303
|| defined (__STDIO__) /* Apple MPW MrC */ \
304
|| defined (_MSL_STDIO_H) /* Metrowerks */
305
#define _GMP_H_HAVE_FILE 1
308
/* In ISO C, if a prototype involving "struct obstack *" is given without
309
that structure defined, then the struct is scoped down to just the
310
prototype, causing a conflict if it's subsequently defined for real. So
311
only give prototypes if we've got obstack.h. */
312
#if defined (_OBSTACK_H) /* glibc <obstack.h> */
313
#define _GMP_H_HAVE_OBSTACK 1
316
/* The prototypes for gmp_vprintf etc are provided only if va_list is
317
available, via an application having included <stdarg.h> or <varargs.h>.
318
Usually va_list is a typedef so can't be tested directly, but va_start is
319
almost certainly a macro, so look for that.
321
<stdio.h> will define some sort of va_list for vprintf and vfprintf, but
322
let's not bother trying to use that since it's not standard and since
323
application uses for gmp_vprintf etc will almost certainly require the
324
whole <stdarg.h> or <varargs.h> anyway. */
327
#define _GMP_H_HAVE_VA_LIST 1
330
/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */
331
#if defined (__GNUC__) && defined (__GNUC_MINOR__)
332
#define __GMP_GNUC_PREREQ(maj, min) \
333
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
335
#define __GMP_GNUC_PREREQ(maj, min) 0
338
/* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes". Basically
339
it means a function does nothing but examine its arguments and memory
340
(global or via arguments) to generate a return value, but changes nothing
341
and has no side-effects. */
342
#if __GMP_GNUC_PREREQ (2,96)
343
#define __GMP_ATTRIBUTE_PURE __attribute__ ((__pure__))
345
#define __GMP_ATTRIBUTE_PURE
349
/* __GMP_CAST allows us to use static_cast in C++, so our macros are clean
350
to "g++ -Wold-style-cast".
352
Casts in "extern inline" code within an extern "C" block don't induce
353
these warnings, so __GMP_CAST only needs to be used on documented
357
#define __GMP_CAST(type, expr) (static_cast<type> (expr))
359
#define __GMP_CAST(type, expr) ((type) (expr))
363
/* An empty "throw ()" means the function doesn't throw any C++ exceptions,
364
this can save some stack frame info in applications.
366
Currently it's given only on functions which never divide-by-zero etc,
367
don't allocate memory, and are expected to never need to allocate memory.
368
This leaves open the possibility of a C++ throw from a future GMP
371
mpz_set_ui etc are omitted to leave open the lazy allocation scheme
372
described in doc/tasks.html. mpz_get_d etc are omitted to leave open
373
exceptions for float overflows.
375
Note that __GMP_NOTHROW must be given on any inlines the same as on their
376
prototypes (for g++ at least, where they're used together). Note also
377
that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like
378
__GMP_ATTRIBUTE_PURE. */
380
#if defined (__cplusplus)
381
#define __GMP_NOTHROW throw ()
383
#define __GMP_NOTHROW
387
/* PORTME: What other compilers have a useful "extern inline"? "static
388
inline" would be an acceptable substitute if the compiler (or linker)
389
discards unused statics. */
391
/* gcc has __inline__ in all modes, including strict ansi. Give a prototype
392
for an inline too, so as to correctly specify "dllimport" on windows, in
393
case the function is called rather than inlined. */
395
#define __GMP_EXTERN_INLINE extern __inline__
396
#define __GMP_INLINE_PROTOTYPES 1
399
/* SCO OpenUNIX 8 cc supports "static inline foo()" but not in -Xc strict
400
ANSI mode (__STDC__ is 1 in that mode). Inlining only actually takes
401
place under -O. Without -O "foo" seems to be emitted whether it's used
402
or not, which is wasteful. "extern inline foo()" isn't useful, the
403
"extern" is apparently ignored, so foo is inlined if possible but also
404
emitted as a global, which causes multiple definition errors when
405
building a shared libgmp. */
406
#ifdef __SCO_VERSION__
407
#if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \
408
&& ! defined (__GMP_EXTERN_INLINE)
409
#define __GMP_EXTERN_INLINE static inline
413
/* C++ always has "inline" and since it's a normal feature the linker should
414
discard duplicate non-inlined copies, or if it doesn't then that's a
415
problem for everyone, not just GMP. */
416
#if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE)
417
#define __GMP_EXTERN_INLINE inline
420
/* Don't do any inlining within a configure run, since if the compiler ends
421
up emitting copies of the code into the object file it can end up
422
demanding the various support routines (like mpn_popcount) for linking,
423
making the "alloca" test and perhaps others fail. And on hppa ia64 a
424
pre-release gcc 3.2 was seen not respecting the "extern" in "extern
425
__inline__", triggering this problem too. */
426
#if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE
427
#undef __GMP_EXTERN_INLINE
430
/* By default, don't give a prototype when there's going to be an inline
431
version. Note in particular that Cray C++ objects to the combination of
432
prototype and inline. */
433
#ifdef __GMP_EXTERN_INLINE
434
#ifndef __GMP_INLINE_PROTOTYPES
435
#define __GMP_INLINE_PROTOTYPES 0
438
#define __GMP_INLINE_PROTOTYPES 1
442
#define __GMP_ABS(x) ((x) >= 0 ? (x) : -(x))
443
#define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i))
445
#define __GMP_UINT_MAX (~ (unsigned) 0)
446
#define __GMP_ULONG_MAX (~ (unsigned long) 0)
447
#define __GMP_USHRT_MAX ((unsigned short) ~0)
450
/* Allow direct user access to numerator and denominator of a mpq_t object. */
451
#define mpq_numref(Q) (&((Q)->_mp_num))
452
#define mpq_denref(Q) (&((Q)->_mp_den))
455
#if defined (__cplusplus)
459
#define mp_set_memory_functions __gmp_set_memory_functions
460
__GMP_DECLSPEC void mp_set_memory_functions __GMP_PROTO ((void *(*) (size_t),
461
void *(*) (void *, size_t, size_t),
462
void (*) (void *, size_t))) __GMP_NOTHROW;
464
#define mp_bits_per_limb __gmp_bits_per_limb
465
__GMP_DECLSPEC extern __gmp_const int mp_bits_per_limb;
467
#define gmp_errno __gmp_errno
468
__GMP_DECLSPEC extern int gmp_errno;
470
#define gmp_version __gmp_version
471
__GMP_DECLSPEC extern __gmp_const char * __gmp_const gmp_version;
473
/* The following for internal use only.
474
Enhancement: __gmp_allocate_func could have "__attribute__ ((malloc))",
475
but current gcc (3.0) doesn't seem to support that. */
476
__GMP_DECLSPEC extern void * (*__gmp_allocate_func) __GMP_PROTO ((size_t));
477
__GMP_DECLSPEC extern void * (*__gmp_reallocate_func) __GMP_PROTO ((void *, size_t, size_t));
478
__GMP_DECLSPEC extern void (*__gmp_free_func) __GMP_PROTO ((void *, size_t));
481
/**************** Random number routines. ****************/
484
#define gmp_randinit __gmp_randinit
485
__GMP_DECLSPEC void gmp_randinit __GMP_PROTO ((gmp_randstate_t, gmp_randalg_t, ...));
487
#define gmp_randinit_default __gmp_randinit_default
488
__GMP_DECLSPEC void gmp_randinit_default __GMP_PROTO ((gmp_randstate_t));
490
#define gmp_randinit_lc __gmp_randinit_lc
491
__GMP_DECLSPEC void gmp_randinit_lc __GMP_PROTO ((gmp_randstate_t,
492
mpz_srcptr, unsigned long int, mpz_srcptr));
494
#define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp
495
__GMP_DECLSPEC void gmp_randinit_lc_2exp __GMP_PROTO ((gmp_randstate_t,
496
mpz_srcptr, unsigned long int,
499
#define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size
500
__GMP_DECLSPEC int gmp_randinit_lc_2exp_size __GMP_PROTO ((gmp_randstate_t, unsigned long));
502
#define gmp_randseed __gmp_randseed
503
__GMP_DECLSPEC void gmp_randseed __GMP_PROTO ((gmp_randstate_t, mpz_srcptr));
505
#define gmp_randseed_ui __gmp_randseed_ui
506
__GMP_DECLSPEC void gmp_randseed_ui __GMP_PROTO ((gmp_randstate_t, unsigned long int));
508
#define gmp_randclear __gmp_randclear
509
__GMP_DECLSPEC void gmp_randclear __GMP_PROTO ((gmp_randstate_t));
512
/**************** Formatted output routines. ****************/
514
#define gmp_asprintf __gmp_asprintf
515
__GMP_DECLSPEC int gmp_asprintf __GMP_PROTO ((char **, const char *, ...));
517
#define gmp_fprintf __gmp_fprintf
518
#ifdef _GMP_H_HAVE_FILE
519
__GMP_DECLSPEC int gmp_fprintf __GMP_PROTO ((FILE *, const char *, ...));
522
#define gmp_obstack_printf __gmp_obstack_printf
523
#if defined (_GMP_H_HAVE_OBSTACK)
524
__GMP_DECLSPEC int gmp_obstack_printf __GMP_PROTO ((struct obstack *, const char *, ...));
527
#define gmp_obstack_vprintf __gmp_obstack_vprintf
528
#if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST)
529
__GMP_DECLSPEC int gmp_obstack_vprintf __GMP_PROTO ((struct obstack *, const char *, va_list));
532
#define gmp_printf __gmp_printf
533
__GMP_DECLSPEC int gmp_printf __GMP_PROTO ((const char *, ...));
535
#define gmp_snprintf __gmp_snprintf
536
__GMP_DECLSPEC int gmp_snprintf __GMP_PROTO ((char *, size_t, const char *, ...));
538
#define gmp_sprintf __gmp_sprintf
539
__GMP_DECLSPEC int gmp_sprintf __GMP_PROTO ((char *, const char *, ...));
541
#define gmp_vasprintf __gmp_vasprintf
542
#if defined (_GMP_H_HAVE_VA_LIST)
543
__GMP_DECLSPEC int gmp_vasprintf __GMP_PROTO ((char **, const char *, va_list));
546
#define gmp_vfprintf __gmp_vfprintf
547
#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)
548
__GMP_DECLSPEC int gmp_vfprintf __GMP_PROTO ((FILE *, const char *, va_list));
551
#define gmp_vprintf __gmp_vprintf
552
#if defined (_GMP_H_HAVE_VA_LIST)
553
__GMP_DECLSPEC int gmp_vprintf __GMP_PROTO ((const char *, va_list));
556
#define gmp_vsnprintf __gmp_vsnprintf
557
#if defined (_GMP_H_HAVE_VA_LIST)
558
__GMP_DECLSPEC int gmp_vsnprintf __GMP_PROTO ((char *, size_t, const char *, va_list));
561
#define gmp_vsprintf __gmp_vsprintf
562
#if defined (_GMP_H_HAVE_VA_LIST)
563
__GMP_DECLSPEC int gmp_vsprintf __GMP_PROTO ((char *, const char *, va_list));
567
/**************** Formatted input routines. ****************/
569
#define gmp_fscanf __gmp_fscanf
570
#ifdef _GMP_H_HAVE_FILE
571
__GMP_DECLSPEC int gmp_fscanf __GMP_PROTO ((FILE *, const char *, ...));
574
#define gmp_scanf __gmp_scanf
575
__GMP_DECLSPEC int gmp_scanf __GMP_PROTO ((const char *, ...));
577
#define gmp_sscanf __gmp_sscanf
578
__GMP_DECLSPEC int gmp_sscanf __GMP_PROTO ((const char *, const char *, ...));
580
#define gmp_vfscanf __gmp_vfscanf
581
#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)
582
__GMP_DECLSPEC int gmp_vfscanf __GMP_PROTO ((FILE *, const char *, va_list));
585
#define gmp_vscanf __gmp_vscanf
586
#if defined (_GMP_H_HAVE_VA_LIST)
587
__GMP_DECLSPEC int gmp_vscanf __GMP_PROTO ((const char *, va_list));
590
#define gmp_vsscanf __gmp_vsscanf
591
#if defined (_GMP_H_HAVE_VA_LIST)
592
__GMP_DECLSPEC int gmp_vsscanf __GMP_PROTO ((const char *, const char *, va_list));
596
/**************** Integer (i.e. Z) routines. ****************/
598
#define _mpz_realloc __gmpz_realloc
599
#define mpz_realloc __gmpz_realloc
600
__GMP_DECLSPEC void *_mpz_realloc __GMP_PROTO ((mpz_ptr, mp_size_t));
602
#define mpz_abs __gmpz_abs
603
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs)
604
__GMP_DECLSPEC void mpz_abs __GMP_PROTO ((mpz_ptr, mpz_srcptr));
607
#define mpz_add __gmpz_add
608
__GMP_DECLSPEC void mpz_add __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
610
#define mpz_add_ui __gmpz_add_ui
611
__GMP_DECLSPEC void mpz_add_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
613
#define mpz_addmul __gmpz_addmul
614
__GMP_DECLSPEC void mpz_addmul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
616
#define mpz_addmul_ui __gmpz_addmul_ui
617
__GMP_DECLSPEC void mpz_addmul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
619
#define mpz_and __gmpz_and
620
__GMP_DECLSPEC void mpz_and __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
622
#define mpz_array_init __gmpz_array_init
623
__GMP_DECLSPEC void mpz_array_init __GMP_PROTO ((mpz_ptr, mp_size_t, mp_size_t));
625
#define mpz_bin_ui __gmpz_bin_ui
626
__GMP_DECLSPEC void mpz_bin_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
628
#define mpz_bin_uiui __gmpz_bin_uiui
629
__GMP_DECLSPEC void mpz_bin_uiui __GMP_PROTO ((mpz_ptr, unsigned long int, unsigned long int));
631
#define mpz_cdiv_q __gmpz_cdiv_q
632
__GMP_DECLSPEC void mpz_cdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
634
#define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp
635
__GMP_DECLSPEC void mpz_cdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));
637
#define mpz_cdiv_q_ui __gmpz_cdiv_q_ui
638
__GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
640
#define mpz_cdiv_qr __gmpz_cdiv_qr
641
__GMP_DECLSPEC void mpz_cdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
643
#define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui
644
__GMP_DECLSPEC unsigned long int mpz_cdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
646
#define mpz_cdiv_r __gmpz_cdiv_r
647
__GMP_DECLSPEC void mpz_cdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
649
#define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp
650
__GMP_DECLSPEC void mpz_cdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));
652
#define mpz_cdiv_r_ui __gmpz_cdiv_r_ui
653
__GMP_DECLSPEC unsigned long int mpz_cdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
655
#define mpz_cdiv_ui __gmpz_cdiv_ui
656
__GMP_DECLSPEC unsigned long int mpz_cdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
658
#define mpz_clear __gmpz_clear
659
__GMP_DECLSPEC void mpz_clear __GMP_PROTO ((mpz_ptr));
661
#define mpz_clrbit __gmpz_clrbit
662
__GMP_DECLSPEC void mpz_clrbit __GMP_PROTO ((mpz_ptr, unsigned long int));
664
#define mpz_cmp __gmpz_cmp
665
__GMP_DECLSPEC int mpz_cmp __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
667
#define mpz_cmp_d __gmpz_cmp_d
668
__GMP_DECLSPEC int mpz_cmp_d __GMP_PROTO ((mpz_srcptr, double)) __GMP_ATTRIBUTE_PURE;
670
#define _mpz_cmp_si __gmpz_cmp_si
671
__GMP_DECLSPEC int _mpz_cmp_si __GMP_PROTO ((mpz_srcptr, signed long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
673
#define _mpz_cmp_ui __gmpz_cmp_ui
674
__GMP_DECLSPEC int _mpz_cmp_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
676
#define mpz_cmpabs __gmpz_cmpabs
677
__GMP_DECLSPEC int mpz_cmpabs __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
679
#define mpz_cmpabs_d __gmpz_cmpabs_d
680
__GMP_DECLSPEC int mpz_cmpabs_d __GMP_PROTO ((mpz_srcptr, double)) __GMP_ATTRIBUTE_PURE;
682
#define mpz_cmpabs_ui __gmpz_cmpabs_ui
683
__GMP_DECLSPEC int mpz_cmpabs_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
685
#define mpz_com __gmpz_com
686
__GMP_DECLSPEC void mpz_com __GMP_PROTO ((mpz_ptr, mpz_srcptr));
688
#define mpz_congruent_p __gmpz_congruent_p
689
__GMP_DECLSPEC int mpz_congruent_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
691
#define mpz_congruent_2exp_p __gmpz_congruent_2exp_p
692
__GMP_DECLSPEC int mpz_congruent_2exp_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr, unsigned long)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
694
#define mpz_congruent_ui_p __gmpz_congruent_ui_p
695
__GMP_DECLSPEC int mpz_congruent_ui_p __GMP_PROTO ((mpz_srcptr, unsigned long, unsigned long)) __GMP_ATTRIBUTE_PURE;
697
#define mpz_divexact __gmpz_divexact
698
__GMP_DECLSPEC void mpz_divexact __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
700
#define mpz_divexact_ui __gmpz_divexact_ui
701
__GMP_DECLSPEC void mpz_divexact_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));
703
#define mpz_divisible_p __gmpz_divisible_p
704
__GMP_DECLSPEC int mpz_divisible_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
706
#define mpz_divisible_ui_p __gmpz_divisible_ui_p
707
__GMP_DECLSPEC int mpz_divisible_ui_p __GMP_PROTO ((mpz_srcptr, unsigned long)) __GMP_ATTRIBUTE_PURE;
709
#define mpz_divisible_2exp_p __gmpz_divisible_2exp_p
710
__GMP_DECLSPEC int mpz_divisible_2exp_p __GMP_PROTO ((mpz_srcptr, unsigned long)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
712
#define mpz_dump __gmpz_dump
713
__GMP_DECLSPEC void mpz_dump __GMP_PROTO ((mpz_srcptr));
715
#define mpz_export __gmpz_export
716
__GMP_DECLSPEC void *mpz_export __GMP_PROTO ((void *, size_t *, int, size_t, int, size_t, mpz_srcptr));
718
#define mpz_fac_ui __gmpz_fac_ui
719
__GMP_DECLSPEC void mpz_fac_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
721
#define mpz_fdiv_q __gmpz_fdiv_q
722
__GMP_DECLSPEC void mpz_fdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
724
#define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp
725
__GMP_DECLSPEC void mpz_fdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
727
#define mpz_fdiv_q_ui __gmpz_fdiv_q_ui
728
__GMP_DECLSPEC unsigned long int mpz_fdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
730
#define mpz_fdiv_qr __gmpz_fdiv_qr
731
__GMP_DECLSPEC void mpz_fdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
733
#define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui
734
__GMP_DECLSPEC unsigned long int mpz_fdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
736
#define mpz_fdiv_r __gmpz_fdiv_r
737
__GMP_DECLSPEC void mpz_fdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
739
#define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp
740
__GMP_DECLSPEC void mpz_fdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
742
#define mpz_fdiv_r_ui __gmpz_fdiv_r_ui
743
__GMP_DECLSPEC unsigned long int mpz_fdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
745
#define mpz_fdiv_ui __gmpz_fdiv_ui
746
__GMP_DECLSPEC unsigned long int mpz_fdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
748
#define mpz_fib_ui __gmpz_fib_ui
749
__GMP_DECLSPEC void mpz_fib_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
751
#define mpz_fib2_ui __gmpz_fib2_ui
752
__GMP_DECLSPEC void mpz_fib2_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, unsigned long int));
754
#define mpz_fits_sint_p __gmpz_fits_sint_p
755
__GMP_DECLSPEC int mpz_fits_sint_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
757
#define mpz_fits_slong_p __gmpz_fits_slong_p
758
__GMP_DECLSPEC int mpz_fits_slong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
760
#define mpz_fits_sshort_p __gmpz_fits_sshort_p
761
__GMP_DECLSPEC int mpz_fits_sshort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
763
#define mpz_fits_uint_p __gmpz_fits_uint_p
764
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p)
765
__GMP_DECLSPEC int mpz_fits_uint_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
768
#define mpz_fits_ulong_p __gmpz_fits_ulong_p
769
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p)
770
__GMP_DECLSPEC int mpz_fits_ulong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
773
#define mpz_fits_ushort_p __gmpz_fits_ushort_p
774
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p)
775
__GMP_DECLSPEC int mpz_fits_ushort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
778
#define mpz_gcd __gmpz_gcd
779
__GMP_DECLSPEC void mpz_gcd __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
781
#define mpz_gcd_ui __gmpz_gcd_ui
782
__GMP_DECLSPEC unsigned long int mpz_gcd_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
784
#define mpz_gcdext __gmpz_gcdext
785
__GMP_DECLSPEC void mpz_gcdext __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
787
#define mpz_get_d __gmpz_get_d
788
__GMP_DECLSPEC double mpz_get_d __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
790
#define mpz_get_d_2exp __gmpz_get_d_2exp
791
__GMP_DECLSPEC double mpz_get_d_2exp __GMP_PROTO ((signed long int *, mpz_srcptr));
793
#define mpz_get_si __gmpz_get_si
794
__GMP_DECLSPEC /* signed */ long int mpz_get_si __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
796
#define mpz_get_str __gmpz_get_str
797
__GMP_DECLSPEC char *mpz_get_str __GMP_PROTO ((char *, int, mpz_srcptr));
799
#define mpz_get_ui __gmpz_get_ui
800
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui)
801
__GMP_DECLSPEC unsigned long int mpz_get_ui __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
804
#define mpz_getlimbn __gmpz_getlimbn
805
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn)
806
__GMP_DECLSPEC mp_limb_t mpz_getlimbn __GMP_PROTO ((mpz_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
809
#define mpz_hamdist __gmpz_hamdist
810
__GMP_DECLSPEC unsigned long int mpz_hamdist __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
812
#define mpz_import __gmpz_import
813
__GMP_DECLSPEC void mpz_import __GMP_PROTO ((mpz_ptr, size_t, int, size_t, int, size_t, const void *));
815
#define mpz_init __gmpz_init
816
__GMP_DECLSPEC void mpz_init __GMP_PROTO ((mpz_ptr));
818
#define mpz_init2 __gmpz_init2
819
__GMP_DECLSPEC void mpz_init2 __GMP_PROTO ((mpz_ptr, unsigned long));
821
#define mpz_init_set __gmpz_init_set
822
__GMP_DECLSPEC void mpz_init_set __GMP_PROTO ((mpz_ptr, mpz_srcptr));
824
#define mpz_init_set_d __gmpz_init_set_d
825
__GMP_DECLSPEC void mpz_init_set_d __GMP_PROTO ((mpz_ptr, double));
827
#define mpz_init_set_si __gmpz_init_set_si
828
__GMP_DECLSPEC void mpz_init_set_si __GMP_PROTO ((mpz_ptr, signed long int));
830
#define mpz_init_set_str __gmpz_init_set_str
831
__GMP_DECLSPEC int mpz_init_set_str __GMP_PROTO ((mpz_ptr, __gmp_const char *, int));
833
#define mpz_init_set_ui __gmpz_init_set_ui
834
__GMP_DECLSPEC void mpz_init_set_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
836
#define mpz_inp_raw __gmpz_inp_raw
837
#ifdef _GMP_H_HAVE_FILE
838
__GMP_DECLSPEC size_t mpz_inp_raw __GMP_PROTO ((mpz_ptr, FILE *));
841
#define mpz_inp_str __gmpz_inp_str
842
#ifdef _GMP_H_HAVE_FILE
843
__GMP_DECLSPEC size_t mpz_inp_str __GMP_PROTO ((mpz_ptr, FILE *, int));
846
#define mpz_invert __gmpz_invert
847
__GMP_DECLSPEC int mpz_invert __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
849
#define mpz_ior __gmpz_ior
850
__GMP_DECLSPEC void mpz_ior __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
852
#define mpz_jacobi __gmpz_jacobi
853
__GMP_DECLSPEC int mpz_jacobi __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
855
#define mpz_kronecker mpz_jacobi /* alias */
857
#define mpz_kronecker_si __gmpz_kronecker_si
858
__GMP_DECLSPEC int mpz_kronecker_si __GMP_PROTO ((mpz_srcptr, long)) __GMP_ATTRIBUTE_PURE;
860
#define mpz_kronecker_ui __gmpz_kronecker_ui
861
__GMP_DECLSPEC int mpz_kronecker_ui __GMP_PROTO ((mpz_srcptr, unsigned long)) __GMP_ATTRIBUTE_PURE;
863
#define mpz_si_kronecker __gmpz_si_kronecker
864
__GMP_DECLSPEC int mpz_si_kronecker __GMP_PROTO ((long, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
866
#define mpz_ui_kronecker __gmpz_ui_kronecker
867
__GMP_DECLSPEC int mpz_ui_kronecker __GMP_PROTO ((unsigned long, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
869
#define mpz_lcm __gmpz_lcm
870
__GMP_DECLSPEC void mpz_lcm __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
872
#define mpz_lcm_ui __gmpz_lcm_ui
873
__GMP_DECLSPEC void mpz_lcm_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));
875
#define mpz_legendre mpz_jacobi /* alias */
877
#define mpz_lucnum_ui __gmpz_lucnum_ui
878
__GMP_DECLSPEC void mpz_lucnum_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
880
#define mpz_lucnum2_ui __gmpz_lucnum2_ui
881
__GMP_DECLSPEC void mpz_lucnum2_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, unsigned long int));
883
#define mpz_millerrabin __gmpz_millerrabin
884
__GMP_DECLSPEC int mpz_millerrabin __GMP_PROTO ((mpz_srcptr, int)) __GMP_ATTRIBUTE_PURE;
886
#define mpz_mod __gmpz_mod
887
__GMP_DECLSPEC void mpz_mod __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
889
#define mpz_mul __gmpz_mul
890
__GMP_DECLSPEC void mpz_mul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
892
#define mpz_mul_2exp __gmpz_mul_2exp
893
__GMP_DECLSPEC void mpz_mul_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
895
#define mpz_mul_si __gmpz_mul_si
896
__GMP_DECLSPEC void mpz_mul_si __GMP_PROTO ((mpz_ptr, mpz_srcptr, long int));
898
#define mpz_mul_ui __gmpz_mul_ui
899
__GMP_DECLSPEC void mpz_mul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
901
#define mpz_neg __gmpz_neg
902
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg)
903
__GMP_DECLSPEC void mpz_neg __GMP_PROTO ((mpz_ptr, mpz_srcptr));
906
#define mpz_nextprime __gmpz_nextprime
907
__GMP_DECLSPEC void mpz_nextprime __GMP_PROTO ((mpz_ptr, mpz_srcptr));
909
#define mpz_out_raw __gmpz_out_raw
910
#ifdef _GMP_H_HAVE_FILE
911
__GMP_DECLSPEC size_t mpz_out_raw __GMP_PROTO ((FILE *, mpz_srcptr));
914
#define mpz_out_str __gmpz_out_str
915
#ifdef _GMP_H_HAVE_FILE
916
__GMP_DECLSPEC size_t mpz_out_str __GMP_PROTO ((FILE *, int, mpz_srcptr));
919
#define mpz_perfect_power_p __gmpz_perfect_power_p
920
__GMP_DECLSPEC int mpz_perfect_power_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
922
#define mpz_perfect_square_p __gmpz_perfect_square_p
923
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p)
924
__GMP_DECLSPEC int mpz_perfect_square_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
927
#define mpz_popcount __gmpz_popcount
928
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount)
929
__GMP_DECLSPEC unsigned long int mpz_popcount __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
932
#define mpz_pow_ui __gmpz_pow_ui
933
__GMP_DECLSPEC void mpz_pow_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
935
#define mpz_powm __gmpz_powm
936
__GMP_DECLSPEC void mpz_powm __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr));
938
#define mpz_powm_ui __gmpz_powm_ui
939
__GMP_DECLSPEC void mpz_powm_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr));
941
#define mpz_probab_prime_p __gmpz_probab_prime_p
942
__GMP_DECLSPEC int mpz_probab_prime_p __GMP_PROTO ((mpz_srcptr, int)) __GMP_ATTRIBUTE_PURE;
944
#define mpz_random __gmpz_random
945
__GMP_DECLSPEC void mpz_random __GMP_PROTO ((mpz_ptr, mp_size_t));
947
#define mpz_random2 __gmpz_random2
948
__GMP_DECLSPEC void mpz_random2 __GMP_PROTO ((mpz_ptr, mp_size_t));
950
#define mpz_realloc2 __gmpz_realloc2
951
__GMP_DECLSPEC void mpz_realloc2 __GMP_PROTO ((mpz_ptr, unsigned long));
953
#define mpz_remove __gmpz_remove
954
__GMP_DECLSPEC unsigned long int mpz_remove __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
956
#define mpz_root __gmpz_root
957
__GMP_DECLSPEC int mpz_root __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
959
#define mpz_rrandomb __gmpz_rrandomb
960
__GMP_DECLSPEC void mpz_rrandomb __GMP_PROTO ((mpz_ptr, gmp_randstate_t, unsigned long int));
962
#define mpz_scan0 __gmpz_scan0
963
__GMP_DECLSPEC unsigned long int mpz_scan0 __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
965
#define mpz_scan1 __gmpz_scan1
966
__GMP_DECLSPEC unsigned long int mpz_scan1 __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
968
#define mpz_set __gmpz_set
969
__GMP_DECLSPEC void mpz_set __GMP_PROTO ((mpz_ptr, mpz_srcptr));
971
#define mpz_set_d __gmpz_set_d
972
__GMP_DECLSPEC void mpz_set_d __GMP_PROTO ((mpz_ptr, double));
974
#define mpz_set_f __gmpz_set_f
975
__GMP_DECLSPEC void mpz_set_f __GMP_PROTO ((mpz_ptr, mpf_srcptr));
977
#define mpz_set_q __gmpz_set_q
978
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q)
979
__GMP_DECLSPEC void mpz_set_q __GMP_PROTO ((mpz_ptr, mpq_srcptr));
982
#define mpz_set_si __gmpz_set_si
983
__GMP_DECLSPEC void mpz_set_si __GMP_PROTO ((mpz_ptr, signed long int));
985
#define mpz_set_str __gmpz_set_str
986
__GMP_DECLSPEC int mpz_set_str __GMP_PROTO ((mpz_ptr, __gmp_const char *, int));
988
#define mpz_set_ui __gmpz_set_ui
989
__GMP_DECLSPEC void mpz_set_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
991
#define mpz_setbit __gmpz_setbit
992
__GMP_DECLSPEC void mpz_setbit __GMP_PROTO ((mpz_ptr, unsigned long int));
994
#define mpz_size __gmpz_size
995
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size)
996
__GMP_DECLSPEC size_t mpz_size __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
999
#define mpz_sizeinbase __gmpz_sizeinbase
1000
__GMP_DECLSPEC size_t mpz_sizeinbase __GMP_PROTO ((mpz_srcptr, int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1002
#define mpz_sqrt __gmpz_sqrt
1003
__GMP_DECLSPEC void mpz_sqrt __GMP_PROTO ((mpz_ptr, mpz_srcptr));
1005
#define mpz_sqrtrem __gmpz_sqrtrem
1006
__GMP_DECLSPEC void mpz_sqrtrem __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr));
1008
#define mpz_sub __gmpz_sub
1009
__GMP_DECLSPEC void mpz_sub __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1011
#define mpz_sub_ui __gmpz_sub_ui
1012
__GMP_DECLSPEC void mpz_sub_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1014
#define mpz_ui_sub __gmpz_ui_sub
1015
__GMP_DECLSPEC void mpz_ui_sub __GMP_PROTO ((mpz_ptr, unsigned long int, mpz_srcptr));
1017
#define mpz_submul __gmpz_submul
1018
__GMP_DECLSPEC void mpz_submul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1020
#define mpz_submul_ui __gmpz_submul_ui
1021
__GMP_DECLSPEC void mpz_submul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1023
#define mpz_swap __gmpz_swap
1024
__GMP_DECLSPEC void mpz_swap __GMP_PROTO ((mpz_ptr, mpz_ptr)) __GMP_NOTHROW;
1026
#define mpz_tdiv_ui __gmpz_tdiv_ui
1027
__GMP_DECLSPEC unsigned long int mpz_tdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
1029
#define mpz_tdiv_q __gmpz_tdiv_q
1030
__GMP_DECLSPEC void mpz_tdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1032
#define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp
1033
__GMP_DECLSPEC void mpz_tdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1035
#define mpz_tdiv_q_ui __gmpz_tdiv_q_ui
1036
__GMP_DECLSPEC unsigned long int mpz_tdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1038
#define mpz_tdiv_qr __gmpz_tdiv_qr
1039
__GMP_DECLSPEC void mpz_tdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
1041
#define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui
1042
__GMP_DECLSPEC unsigned long int mpz_tdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
1044
#define mpz_tdiv_r __gmpz_tdiv_r
1045
__GMP_DECLSPEC void mpz_tdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1047
#define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp
1048
__GMP_DECLSPEC void mpz_tdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1050
#define mpz_tdiv_r_ui __gmpz_tdiv_r_ui
1051
__GMP_DECLSPEC unsigned long int mpz_tdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1053
#define mpz_tstbit __gmpz_tstbit
1054
__GMP_DECLSPEC int mpz_tstbit __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1056
#define mpz_ui_pow_ui __gmpz_ui_pow_ui
1057
__GMP_DECLSPEC void mpz_ui_pow_ui __GMP_PROTO ((mpz_ptr, unsigned long int, unsigned long int));
1059
#define mpz_urandomb __gmpz_urandomb
1060
__GMP_DECLSPEC void mpz_urandomb __GMP_PROTO ((mpz_ptr, gmp_randstate_t, unsigned long int));
1062
#define mpz_urandomm __gmpz_urandomm
1063
__GMP_DECLSPEC void mpz_urandomm __GMP_PROTO ((mpz_ptr, gmp_randstate_t, mpz_srcptr));
1065
#define mpz_xor __gmpz_xor
1066
#define mpz_eor __gmpz_xor
1067
__GMP_DECLSPEC void mpz_xor __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1070
/**************** Rational (i.e. Q) routines. ****************/
1072
#define mpq_abs __gmpq_abs
1073
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs)
1074
__GMP_DECLSPEC void mpq_abs __GMP_PROTO ((mpq_ptr, mpq_srcptr));
1077
#define mpq_add __gmpq_add
1078
__GMP_DECLSPEC void mpq_add __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
1080
#define mpq_canonicalize __gmpq_canonicalize
1081
__GMP_DECLSPEC void mpq_canonicalize __GMP_PROTO ((mpq_ptr));
1083
#define mpq_clear __gmpq_clear
1084
__GMP_DECLSPEC void mpq_clear __GMP_PROTO ((mpq_ptr));
1086
#define mpq_cmp __gmpq_cmp
1087
__GMP_DECLSPEC int mpq_cmp __GMP_PROTO ((mpq_srcptr, mpq_srcptr)) __GMP_ATTRIBUTE_PURE;
1089
#define _mpq_cmp_si __gmpq_cmp_si
1090
__GMP_DECLSPEC int _mpq_cmp_si __GMP_PROTO ((mpq_srcptr, long, unsigned long)) __GMP_ATTRIBUTE_PURE;
1092
#define _mpq_cmp_ui __gmpq_cmp_ui
1093
__GMP_DECLSPEC int _mpq_cmp_ui __GMP_PROTO ((mpq_srcptr, unsigned long int, unsigned long int)) __GMP_ATTRIBUTE_PURE;
1095
#define mpq_div __gmpq_div
1096
__GMP_DECLSPEC void mpq_div __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
1098
#define mpq_div_2exp __gmpq_div_2exp
1099
__GMP_DECLSPEC void mpq_div_2exp __GMP_PROTO ((mpq_ptr, mpq_srcptr, unsigned long));
1101
#define mpq_equal __gmpq_equal
1102
__GMP_DECLSPEC int mpq_equal __GMP_PROTO ((mpq_srcptr, mpq_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1104
#define mpq_get_num __gmpq_get_num
1105
__GMP_DECLSPEC void mpq_get_num __GMP_PROTO ((mpz_ptr, mpq_srcptr));
1107
#define mpq_get_den __gmpq_get_den
1108
__GMP_DECLSPEC void mpq_get_den __GMP_PROTO ((mpz_ptr, mpq_srcptr));
1110
#define mpq_get_d __gmpq_get_d
1111
__GMP_DECLSPEC double mpq_get_d __GMP_PROTO ((mpq_srcptr)) __GMP_ATTRIBUTE_PURE;
1113
#define mpq_get_str __gmpq_get_str
1114
__GMP_DECLSPEC char *mpq_get_str __GMP_PROTO ((char *, int, mpq_srcptr));
1116
#define mpq_init __gmpq_init
1117
__GMP_DECLSPEC void mpq_init __GMP_PROTO ((mpq_ptr));
1119
#define mpq_inp_str __gmpq_inp_str
1120
#ifdef _GMP_H_HAVE_FILE
1121
__GMP_DECLSPEC size_t mpq_inp_str __GMP_PROTO ((mpq_ptr, FILE *, int));
1124
#define mpq_inv __gmpq_inv
1125
__GMP_DECLSPEC void mpq_inv __GMP_PROTO ((mpq_ptr, mpq_srcptr));
1127
#define mpq_mul __gmpq_mul
1128
__GMP_DECLSPEC void mpq_mul __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
1130
#define mpq_mul_2exp __gmpq_mul_2exp
1131
__GMP_DECLSPEC void mpq_mul_2exp __GMP_PROTO ((mpq_ptr, mpq_srcptr, unsigned long));
1133
#define mpq_neg __gmpq_neg
1134
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg)
1135
__GMP_DECLSPEC void mpq_neg __GMP_PROTO ((mpq_ptr, mpq_srcptr));
1138
#define mpq_out_str __gmpq_out_str
1139
#ifdef _GMP_H_HAVE_FILE
1140
__GMP_DECLSPEC size_t mpq_out_str __GMP_PROTO ((FILE *, int, mpq_srcptr));
1143
#define mpq_set __gmpq_set
1144
__GMP_DECLSPEC void mpq_set __GMP_PROTO ((mpq_ptr, mpq_srcptr));
1146
#define mpq_set_d __gmpq_set_d
1147
__GMP_DECLSPEC void mpq_set_d __GMP_PROTO ((mpq_ptr, double));
1149
#define mpq_set_den __gmpq_set_den
1150
__GMP_DECLSPEC void mpq_set_den __GMP_PROTO ((mpq_ptr, mpz_srcptr));
1152
#define mpq_set_f __gmpq_set_f
1153
__GMP_DECLSPEC void mpq_set_f __GMP_PROTO ((mpq_ptr, mpf_srcptr));
1155
#define mpq_set_num __gmpq_set_num
1156
__GMP_DECLSPEC void mpq_set_num __GMP_PROTO ((mpq_ptr, mpz_srcptr));
1158
#define mpq_set_si __gmpq_set_si
1159
__GMP_DECLSPEC void mpq_set_si __GMP_PROTO ((mpq_ptr, signed long int, unsigned long int));
1161
#define mpq_set_str __gmpq_set_str
1162
__GMP_DECLSPEC int mpq_set_str __GMP_PROTO ((mpq_ptr, const char *, int));
1164
#define mpq_set_ui __gmpq_set_ui
1165
__GMP_DECLSPEC void mpq_set_ui __GMP_PROTO ((mpq_ptr, unsigned long int, unsigned long int));
1167
#define mpq_set_z __gmpq_set_z
1168
__GMP_DECLSPEC void mpq_set_z __GMP_PROTO ((mpq_ptr, mpz_srcptr));
1170
#define mpq_sub __gmpq_sub
1171
__GMP_DECLSPEC void mpq_sub __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
1173
#define mpq_swap __gmpq_swap
1174
__GMP_DECLSPEC void mpq_swap __GMP_PROTO ((mpq_ptr, mpq_ptr)) __GMP_NOTHROW;
1177
/**************** Float (i.e. F) routines. ****************/
1179
#define mpf_abs __gmpf_abs
1180
__GMP_DECLSPEC void mpf_abs __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1182
#define mpf_add __gmpf_add
1183
__GMP_DECLSPEC void mpf_add __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
1185
#define mpf_add_ui __gmpf_add_ui
1186
__GMP_DECLSPEC void mpf_add_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1187
#define mpf_ceil __gmpf_ceil
1188
__GMP_DECLSPEC void mpf_ceil __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1190
#define mpf_clear __gmpf_clear
1191
__GMP_DECLSPEC void mpf_clear __GMP_PROTO ((mpf_ptr));
1193
#define mpf_cmp __gmpf_cmp
1194
__GMP_DECLSPEC int mpf_cmp __GMP_PROTO ((mpf_srcptr, mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1196
#define mpf_cmp_d __gmpf_cmp_d
1197
__GMP_DECLSPEC int mpf_cmp_d __GMP_PROTO ((mpf_srcptr, double)) __GMP_ATTRIBUTE_PURE;
1199
#define mpf_cmp_si __gmpf_cmp_si
1200
__GMP_DECLSPEC int mpf_cmp_si __GMP_PROTO ((mpf_srcptr, signed long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1202
#define mpf_cmp_ui __gmpf_cmp_ui
1203
__GMP_DECLSPEC int mpf_cmp_ui __GMP_PROTO ((mpf_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1205
#define mpf_div __gmpf_div
1206
__GMP_DECLSPEC void mpf_div __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
1208
#define mpf_div_2exp __gmpf_div_2exp
1209
__GMP_DECLSPEC void mpf_div_2exp __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1211
#define mpf_div_ui __gmpf_div_ui
1212
__GMP_DECLSPEC void mpf_div_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1214
#define mpf_dump __gmpf_dump
1215
__GMP_DECLSPEC void mpf_dump __GMP_PROTO ((mpf_srcptr));
1217
#define mpf_eq __gmpf_eq
1218
__GMP_DECLSPEC int mpf_eq __GMP_PROTO ((mpf_srcptr, mpf_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
1220
#define mpf_fits_sint_p __gmpf_fits_sint_p
1221
__GMP_DECLSPEC int mpf_fits_sint_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1223
#define mpf_fits_slong_p __gmpf_fits_slong_p
1224
__GMP_DECLSPEC int mpf_fits_slong_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1226
#define mpf_fits_sshort_p __gmpf_fits_sshort_p
1227
__GMP_DECLSPEC int mpf_fits_sshort_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1229
#define mpf_fits_uint_p __gmpf_fits_uint_p
1230
__GMP_DECLSPEC int mpf_fits_uint_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1232
#define mpf_fits_ulong_p __gmpf_fits_ulong_p
1233
__GMP_DECLSPEC int mpf_fits_ulong_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1235
#define mpf_fits_ushort_p __gmpf_fits_ushort_p
1236
__GMP_DECLSPEC int mpf_fits_ushort_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1238
#define mpf_floor __gmpf_floor
1239
__GMP_DECLSPEC void mpf_floor __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1241
#define mpf_get_d __gmpf_get_d
1242
__GMP_DECLSPEC double mpf_get_d __GMP_PROTO ((mpf_srcptr)) __GMP_ATTRIBUTE_PURE;
1244
#define mpf_get_d_2exp __gmpf_get_d_2exp
1245
__GMP_DECLSPEC double mpf_get_d_2exp __GMP_PROTO ((signed long int *, mpf_srcptr));
1247
#define mpf_get_default_prec __gmpf_get_default_prec
1248
__GMP_DECLSPEC unsigned long int mpf_get_default_prec __GMP_PROTO ((void)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1250
#define mpf_get_prec __gmpf_get_prec
1251
__GMP_DECLSPEC unsigned long int mpf_get_prec __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1253
#define mpf_get_si __gmpf_get_si
1254
__GMP_DECLSPEC long mpf_get_si __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1256
#define mpf_get_str __gmpf_get_str
1257
__GMP_DECLSPEC char *mpf_get_str __GMP_PROTO ((char *, mp_exp_t *, int, size_t, mpf_srcptr));
1259
#define mpf_get_ui __gmpf_get_ui
1260
__GMP_DECLSPEC unsigned long mpf_get_ui __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1262
#define mpf_init __gmpf_init
1263
__GMP_DECLSPEC void mpf_init __GMP_PROTO ((mpf_ptr));
1265
#define mpf_init2 __gmpf_init2
1266
__GMP_DECLSPEC void mpf_init2 __GMP_PROTO ((mpf_ptr, unsigned long int));
1268
#define mpf_init_set __gmpf_init_set
1269
__GMP_DECLSPEC void mpf_init_set __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1271
#define mpf_init_set_d __gmpf_init_set_d
1272
__GMP_DECLSPEC void mpf_init_set_d __GMP_PROTO ((mpf_ptr, double));
1274
#define mpf_init_set_si __gmpf_init_set_si
1275
__GMP_DECLSPEC void mpf_init_set_si __GMP_PROTO ((mpf_ptr, signed long int));
1277
#define mpf_init_set_str __gmpf_init_set_str
1278
__GMP_DECLSPEC int mpf_init_set_str __GMP_PROTO ((mpf_ptr, __gmp_const char *, int));
1280
#define mpf_init_set_ui __gmpf_init_set_ui
1281
__GMP_DECLSPEC void mpf_init_set_ui __GMP_PROTO ((mpf_ptr, unsigned long int));
1283
#define mpf_inp_str __gmpf_inp_str
1284
#ifdef _GMP_H_HAVE_FILE
1285
__GMP_DECLSPEC size_t mpf_inp_str __GMP_PROTO ((mpf_ptr, FILE *, int));
1288
#define mpf_integer_p __gmpf_integer_p
1289
__GMP_DECLSPEC int mpf_integer_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1291
#define mpf_mul __gmpf_mul
1292
__GMP_DECLSPEC void mpf_mul __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
1294
#define mpf_mul_2exp __gmpf_mul_2exp
1295
__GMP_DECLSPEC void mpf_mul_2exp __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1297
#define mpf_mul_ui __gmpf_mul_ui
1298
__GMP_DECLSPEC void mpf_mul_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1300
#define mpf_neg __gmpf_neg
1301
__GMP_DECLSPEC void mpf_neg __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1303
#define mpf_out_str __gmpf_out_str
1304
#ifdef _GMP_H_HAVE_FILE
1305
__GMP_DECLSPEC size_t mpf_out_str __GMP_PROTO ((FILE *, int, size_t, mpf_srcptr));
1308
#define mpf_pow_ui __gmpf_pow_ui
1309
__GMP_DECLSPEC void mpf_pow_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1311
#define mpf_random2 __gmpf_random2
1312
__GMP_DECLSPEC void mpf_random2 __GMP_PROTO ((mpf_ptr, mp_size_t, mp_exp_t));
1314
#define mpf_reldiff __gmpf_reldiff
1315
__GMP_DECLSPEC void mpf_reldiff __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
1317
#define mpf_set __gmpf_set
1318
__GMP_DECLSPEC void mpf_set __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1320
#define mpf_set_d __gmpf_set_d
1321
__GMP_DECLSPEC void mpf_set_d __GMP_PROTO ((mpf_ptr, double));
1323
#define mpf_set_default_prec __gmpf_set_default_prec
1324
__GMP_DECLSPEC void mpf_set_default_prec __GMP_PROTO ((unsigned long int)) __GMP_NOTHROW;
1326
#define mpf_set_prec __gmpf_set_prec
1327
__GMP_DECLSPEC void mpf_set_prec __GMP_PROTO ((mpf_ptr, unsigned long int));
1329
#define mpf_set_prec_raw __gmpf_set_prec_raw
1330
__GMP_DECLSPEC void mpf_set_prec_raw __GMP_PROTO ((mpf_ptr, unsigned long int)) __GMP_NOTHROW;
1332
#define mpf_set_q __gmpf_set_q
1333
__GMP_DECLSPEC void mpf_set_q __GMP_PROTO ((mpf_ptr, mpq_srcptr));
1335
#define mpf_set_si __gmpf_set_si
1336
__GMP_DECLSPEC void mpf_set_si __GMP_PROTO ((mpf_ptr, signed long int));
1338
#define mpf_set_str __gmpf_set_str
1339
__GMP_DECLSPEC int mpf_set_str __GMP_PROTO ((mpf_ptr, __gmp_const char *, int));
1341
#define mpf_set_ui __gmpf_set_ui
1342
__GMP_DECLSPEC void mpf_set_ui __GMP_PROTO ((mpf_ptr, unsigned long int));
1344
#define mpf_set_z __gmpf_set_z
1345
__GMP_DECLSPEC void mpf_set_z __GMP_PROTO ((mpf_ptr, mpz_srcptr));
1347
#define mpf_size __gmpf_size
1348
__GMP_DECLSPEC size_t mpf_size __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1350
#define mpf_sqrt __gmpf_sqrt
1351
__GMP_DECLSPEC void mpf_sqrt __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1353
#define mpf_sqrt_ui __gmpf_sqrt_ui
1354
__GMP_DECLSPEC void mpf_sqrt_ui __GMP_PROTO ((mpf_ptr, unsigned long int));
1356
#define mpf_sub __gmpf_sub
1357
__GMP_DECLSPEC void mpf_sub __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
1359
#define mpf_sub_ui __gmpf_sub_ui
1360
__GMP_DECLSPEC void mpf_sub_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1362
#define mpf_swap __gmpf_swap
1363
__GMP_DECLSPEC void mpf_swap __GMP_PROTO ((mpf_ptr, mpf_ptr)) __GMP_NOTHROW;
1365
#define mpf_trunc __gmpf_trunc
1366
__GMP_DECLSPEC void mpf_trunc __GMP_PROTO ((mpf_ptr, mpf_srcptr));
1368
#define mpf_ui_div __gmpf_ui_div
1369
__GMP_DECLSPEC void mpf_ui_div __GMP_PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
1371
#define mpf_ui_sub __gmpf_ui_sub
1372
__GMP_DECLSPEC void mpf_ui_sub __GMP_PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
1374
#define mpf_urandomb __gmpf_urandomb
1375
__GMP_DECLSPEC void mpf_urandomb __GMP_PROTO ((mpf_t, gmp_randstate_t, unsigned long int));
1378
/************ Low level positive-integer (i.e. N) routines. ************/
1380
/* This is ugly, but we need to make user calls reach the prefixed function. */
1382
#define mpn_add __MPN(add)
1383
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add)
1384
__GMP_DECLSPEC mp_limb_t mpn_add __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
1387
#define mpn_add_1 __MPN(add_1)
1388
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1)
1389
__GMP_DECLSPEC mp_limb_t mpn_add_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW;
1392
#define mpn_add_n __MPN(add_n)
1393
__GMP_DECLSPEC mp_limb_t mpn_add_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
1395
#define mpn_addmul_1 __MPN(addmul_1)
1396
__GMP_DECLSPEC mp_limb_t mpn_addmul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
1398
#define mpn_bdivmod __MPN(bdivmod)
1399
__GMP_DECLSPEC mp_limb_t mpn_bdivmod __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, unsigned long int));
1401
#define mpn_cmp __MPN(cmp)
1402
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp)
1403
__GMP_DECLSPEC int mpn_cmp __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1406
#define mpn_divexact_by3(dst,src,size) \
1407
mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0))
1409
#define mpn_divexact_by3c __MPN(divexact_by3c)
1410
__GMP_DECLSPEC mp_limb_t mpn_divexact_by3c __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
1412
#define mpn_divmod_1(qp,np,nsize,dlimb) \
1413
mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb)
1415
#define mpn_divrem __MPN(divrem)
1416
__GMP_DECLSPEC mp_limb_t mpn_divrem __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t));
1418
#define mpn_divrem_1 __MPN(divrem_1)
1419
__GMP_DECLSPEC mp_limb_t mpn_divrem_1 __GMP_PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t));
1421
#define mpn_divrem_2 __MPN(divrem_2)
1422
__GMP_DECLSPEC mp_limb_t mpn_divrem_2 __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr));
1424
#define mpn_gcd __MPN(gcd)
1425
__GMP_DECLSPEC mp_size_t mpn_gcd __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t));
1427
#define mpn_gcd_1 __MPN(gcd_1)
1428
__GMP_DECLSPEC mp_limb_t mpn_gcd_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE;
1430
#define mpn_gcdext __MPN(gcdext)
1431
__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));
1433
#define mpn_get_str __MPN(get_str)
1434
__GMP_DECLSPEC size_t mpn_get_str __GMP_PROTO ((unsigned char *, int, mp_ptr, mp_size_t));
1436
#define mpn_hamdist __MPN(hamdist)
1437
__GMP_DECLSPEC unsigned long int mpn_hamdist __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1439
#define mpn_lshift __MPN(lshift)
1440
__GMP_DECLSPEC mp_limb_t mpn_lshift __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
1442
#define mpn_mod_1 __MPN(mod_1)
1443
__GMP_DECLSPEC mp_limb_t mpn_mod_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE;
1445
#define mpn_mul __MPN(mul)
1446
__GMP_DECLSPEC mp_limb_t mpn_mul __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));
1448
#define mpn_mul_1 __MPN(mul_1)
1449
__GMP_DECLSPEC mp_limb_t mpn_mul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
1451
#define mpn_mul_n __MPN(mul_n)
1452
__GMP_DECLSPEC void mpn_mul_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
1454
#define mpn_perfect_square_p __MPN(perfect_square_p)
1455
__GMP_DECLSPEC int mpn_perfect_square_p __GMP_PROTO ((mp_srcptr, mp_size_t)) __GMP_ATTRIBUTE_PURE;
1457
#define mpn_popcount __MPN(popcount)
1458
__GMP_DECLSPEC unsigned long int mpn_popcount __GMP_PROTO ((mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
1460
#define mpn_pow_1 __MPN(pow_1)
1461
__GMP_DECLSPEC mp_size_t mpn_pow_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr));
1463
/* undocumented now, but retained here for upward compatibility */
1464
#define mpn_preinv_mod_1 __MPN(preinv_mod_1)
1465
__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;
1467
#define mpn_random __MPN(random)
1468
__GMP_DECLSPEC void mpn_random __GMP_PROTO ((mp_ptr, mp_size_t));
1470
#define mpn_random2 __MPN(random2)
1471
__GMP_DECLSPEC void mpn_random2 __GMP_PROTO ((mp_ptr, mp_size_t));
1473
#define mpn_rshift __MPN(rshift)
1474
__GMP_DECLSPEC mp_limb_t mpn_rshift __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
1476
#define mpn_scan0 __MPN(scan0)
1477
__GMP_DECLSPEC unsigned long int mpn_scan0 __GMP_PROTO ((mp_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
1479
#define mpn_scan1 __MPN(scan1)
1480
__GMP_DECLSPEC unsigned long int mpn_scan1 __GMP_PROTO ((mp_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
1482
#define mpn_set_str __MPN(set_str)
1483
__GMP_DECLSPEC mp_size_t mpn_set_str __GMP_PROTO ((mp_ptr, __gmp_const unsigned char *, size_t, int));
1485
#define mpn_sqrtrem __MPN(sqrtrem)
1486
__GMP_DECLSPEC mp_size_t mpn_sqrtrem __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t));
1488
#define mpn_sub __MPN(sub)
1489
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub)
1490
__GMP_DECLSPEC mp_limb_t mpn_sub __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
1493
#define mpn_sub_1 __MPN(sub_1)
1494
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1)
1495
__GMP_DECLSPEC mp_limb_t mpn_sub_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW;
1498
#define mpn_sub_n __MPN(sub_n)
1499
__GMP_DECLSPEC mp_limb_t mpn_sub_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
1501
#define mpn_submul_1 __MPN(submul_1)
1502
__GMP_DECLSPEC mp_limb_t mpn_submul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
1504
#define mpn_tdiv_qr __MPN(tdiv_qr)
1505
__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));
1508
/**************** mpz inlines ****************/
1510
/* The following are provided as inlines where possible, but always exist as
1511
library functions too, for binary compatibility.
1513
Within gmp itself this inlining generally isn't relied on, since it
1514
doesn't get done for all compilers, whereas if something is worth
1515
inlining then it's worth arranging always.
1517
There are two styles of inlining here. When the same bit of code is
1518
wanted for the inline as for the library version, then __GMP_FORCE_foo
1519
arranges for that code to be emitted and the __GMP_EXTERN_INLINE
1520
directive suppressed, eg. mpz_fits_uint_p. When a different bit of code
1521
is wanted for the inline than for the library version, then
1522
__GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs. */
1524
#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs)
1525
__GMP_EXTERN_INLINE void
1526
mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)
1528
if (__gmp_w != __gmp_u)
1529
mpz_set (__gmp_w, __gmp_u);
1530
__gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size);
1534
#if GMP_NAIL_BITS == 0
1535
#define __GMPZ_FITS_UTYPE_P(z,maxval) \
1536
mp_size_t __gmp_n = z->_mp_size; \
1537
mp_ptr __gmp_p = z->_mp_d; \
1538
return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval));
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
|| (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS)));
1547
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p)
1548
#if ! defined (__GMP_FORCE_mpz_fits_uint_p)
1552
mpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
1554
__GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_UINT_MAX);
1558
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p)
1559
#if ! defined (__GMP_FORCE_mpz_fits_ulong_p)
1563
mpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
1565
__GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_ULONG_MAX);
1569
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p)
1570
#if ! defined (__GMP_FORCE_mpz_fits_ushort_p)
1574
mpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
1576
__GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_USHRT_MAX);
1580
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui)
1581
#if ! defined (__GMP_FORCE_mpz_get_ui)
1585
mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW
1587
mp_ptr __gmp_p = __gmp_z->_mp_d;
1588
mp_size_t __gmp_n = __gmp_z->_mp_size;
1589
mp_limb_t __gmp_l = __gmp_p[0];
1590
if (__GMP_ULONG_MAX <= GMP_NUMB_MASK)
1591
return __gmp_l & (-(mp_limb_t) (__gmp_n != 0));
1592
#if GMP_NAIL_BITS != 0 /* redundant #if, shuts up compiler warnings */
1593
else /* happens for nails, but not if LONG_LONG_LIMB */
1594
{ /* assume two limbs are enough to fill an ulong */
1595
__gmp_n = __GMP_ABS (__gmp_n);
1597
return __gmp_l & (-(mp_limb_t) (__gmp_n != 0));
1599
return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS);
1605
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn)
1606
#if ! defined (__GMP_FORCE_mpz_getlimbn)
1610
mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW
1612
if (__GMP_ABS (__gmp_z->_mp_size) <= __gmp_n || __gmp_n < 0)
1615
return __gmp_z->_mp_d[__gmp_n];
1619
#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg)
1620
__GMP_EXTERN_INLINE void
1621
mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)
1623
if (__gmp_w != __gmp_u)
1624
mpz_set (__gmp_w, __gmp_u);
1625
__gmp_w->_mp_size = - __gmp_w->_mp_size;
1629
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p)
1630
#if ! defined (__GMP_FORCE_mpz_perfect_square_p)
1634
mpz_perfect_square_p (mpz_srcptr __gmp_a)
1636
mp_size_t __gmp_asize = __gmp_a->_mp_size;
1637
if (__gmp_asize <= 0)
1638
return (__gmp_asize == 0); /* zero is a square, negatives are not */
1640
return mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize);
1644
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount)
1645
#if ! defined (__GMP_FORCE_mpz_popcount)
1649
mpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW
1651
mp_size_t __gmp_usize = __gmp_u->_mp_size;
1653
if (__gmp_usize <= 0)
1654
return (__gmp_usize < 0 ? __GMP_ULONG_MAX : 0);
1656
return mpn_popcount (__gmp_u->_mp_d, __gmp_usize);
1660
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q)
1661
#if ! defined (__GMP_FORCE_mpz_set_q)
1665
mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u)
1667
mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u));
1671
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size)
1672
#if ! defined (__GMP_FORCE_mpz_size)
1676
mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW
1678
return __GMP_ABS (__gmp_z->_mp_size);
1683
/**************** mpq inlines ****************/
1685
#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs)
1686
__GMP_EXTERN_INLINE void
1687
mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)
1689
if (__gmp_w != __gmp_u)
1690
mpq_set (__gmp_w, __gmp_u);
1691
__gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size);
1695
#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg)
1696
__GMP_EXTERN_INLINE void
1697
mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)
1699
if (__gmp_w != __gmp_u)
1700
mpq_set (__gmp_w, __gmp_u);
1701
__gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size;
1706
/**************** mpn inlines ****************/
1708
/* The comments with __GMPN_ADD_1 below apply here too.
1710
The test for FUNCTION returning 0 should predict well. If it's assumed
1711
{yp,ysize} will usually have a random number of bits then the high limb
1712
won't be full and a carry out will occur a good deal less than 50% of the
1715
ysize==0 isn't a documented feature, but is used internally in a few
1718
Producing cout last stops it using up a register during the main part of
1719
the calculation, though gcc (as of 3.0) on an "if (mpn_add (...))"
1720
doesn't seem able to move the true and false legs of the conditional up
1721
to the two places cout is generated. */
1723
#define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST) \
1725
mp_size_t __gmp_i; \
1726
mp_limb_t __gmp_x; \
1728
/* ASSERT ((ysize) >= 0); */ \
1729
/* ASSERT ((xsize) >= (ysize)); */ \
1730
/* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */ \
1731
/* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */ \
1733
__gmp_i = (ysize); \
1736
if (FUNCTION (wp, xp, yp, __gmp_i)) \
1740
if (__gmp_i >= (xsize)) \
1745
__gmp_x = (xp)[__gmp_i]; \
1751
__GMPN_COPY_REST (wp, xp, xsize, __gmp_i); \
1757
#define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize) \
1758
__GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n, \
1759
(((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0))
1760
#define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize) \
1761
__GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n, \
1762
(((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0))
1765
/* The use of __gmp_i indexing is designed to ensure a compile time src==dst
1766
remains nice and clear to the compiler, so that __GMPN_COPY_REST can
1767
disappear, and the load/add/store gets a chance to become a
1768
read-modify-write on CISC CPUs.
1772
Using a pair of pointers instead of indexing would be possible, but gcc
1773
isn't able to recognise compile-time src==dst in that case, even when the
1774
pointers are incremented more or less together. Other compilers would
1775
very likely have similar difficulty.
1777
gcc could use "if (__builtin_constant_p(src==dst) && src==dst)" or
1778
similar to detect a compile-time src==dst. This works nicely on gcc
1779
2.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems
1780
to be always false, for a pointer p. But the current code form seems
1781
good enough for src==dst anyway.
1783
gcc on x86 as usual doesn't give particularly good flags handling for the
1784
carry/borrow detection. It's tempting to want some multi instruction asm
1785
blocks to help it, and this was tried, but in truth there's only a few
1786
instructions to save and any gain is all too easily lost by register
1787
juggling setting up for the asm. */
1789
#if GMP_NAIL_BITS == 0
1790
#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \
1792
mp_size_t __gmp_i; \
1793
mp_limb_t __gmp_x, __gmp_r; \
1795
/* ASSERT ((n) >= 1); */ \
1796
/* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \
1798
__gmp_x = (src)[0]; \
1799
__gmp_r = __gmp_x OP (v); \
1800
(dst)[0] = __gmp_r; \
1801
if (CB (__gmp_r, __gmp_x, (v))) \
1804
for (__gmp_i = 1; __gmp_i < (n);) \
1806
__gmp_x = (src)[__gmp_i]; \
1807
__gmp_r = __gmp_x OP 1; \
1808
(dst)[__gmp_i] = __gmp_r; \
1810
if (!CB (__gmp_r, __gmp_x, 1)) \
1812
if ((src) != (dst)) \
1813
__GMPN_COPY_REST (dst, src, n, __gmp_i); \
1821
if ((src) != (dst)) \
1822
__GMPN_COPY_REST (dst, src, n, 1); \
1828
#if GMP_NAIL_BITS >= 1
1829
#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \
1831
mp_size_t __gmp_i; \
1832
mp_limb_t __gmp_x, __gmp_r; \
1834
/* ASSERT ((n) >= 1); */ \
1835
/* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \
1837
__gmp_x = (src)[0]; \
1838
__gmp_r = __gmp_x OP (v); \
1839
(dst)[0] = __gmp_r & GMP_NUMB_MASK; \
1840
if (__gmp_r >> GMP_NUMB_BITS != 0) \
1843
for (__gmp_i = 1; __gmp_i < (n);) \
1845
__gmp_x = (src)[__gmp_i]; \
1846
__gmp_r = __gmp_x OP 1; \
1847
(dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK; \
1849
if (__gmp_r >> GMP_NUMB_BITS == 0) \
1851
if ((src) != (dst)) \
1852
__GMPN_COPY_REST (dst, src, n, __gmp_i); \
1860
if ((src) != (dst)) \
1861
__GMPN_COPY_REST (dst, src, n, 1); \
1867
#define __GMPN_ADDCB(r,x,y) ((r) < (y))
1868
#define __GMPN_SUBCB(r,x,y) ((x) < (y))
1870
#define __GMPN_ADD_1(cout, dst, src, n, v) \
1871
__GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB)
1872
#define __GMPN_SUB_1(cout, dst, src, n, v) \
1873
__GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB)
1876
/* Compare {xp,size} and {yp,size}, setting "result" to positive, zero or
1877
negative. size==0 is allowed. On random data usually only one limb will
1878
need to be examined to get a result, so it's worth having it inline. */
1879
#define __GMPN_CMP(result, xp, yp, size) \
1881
mp_size_t __gmp_i; \
1882
mp_limb_t __gmp_x, __gmp_y; \
1884
/* ASSERT ((size) >= 0); */ \
1888
while (--__gmp_i >= 0) \
1890
__gmp_x = (xp)[__gmp_i]; \
1891
__gmp_y = (yp)[__gmp_i]; \
1892
if (__gmp_x != __gmp_y) \
1894
/* Cannot use __gmp_x - __gmp_y, may overflow an "int" */ \
1895
(result) = (__gmp_x > __gmp_y ? 1 : -1); \
1902
/* For power and powerpc we want an inline ldu/stu/bdnz loop for copying.
1903
On ppc630 for instance this is optimal since it can sustain only 1 store
1906
gcc 2.95.x (powerpc64 -maix64, or powerpc32) doesn't recognise the "for"
1907
loop in the generic code below can become ldu/stu/bdnz. The do/while
1908
here helps it get to that.
1910
In gcc -mpowerpc64 mode, without -maix64, __size seems to want to be an
1911
mp_limb_t to get into the ctr register, and even then the loop is a
1912
curious ldu/stu/bdz/b. But let's not worry about that unless there's a
1913
system using this. An asm block could force what we want if necessary.
1915
xlc 3.1 already generates ldu/stu/bdnz from the generic C, and does so
1916
from this loop too. */
1918
#if __GMP_HAVE_HOST_CPU_FAMILY_power || __GMP_HAVE_HOST_CPU_FAMILY_powerpc
1919
#define __GMPN_COPY_INCR(dst, src, size) \
1921
/* ASSERT ((size) >= 0); */ \
1922
/* ASSERT (MPN_SAME_OR_INCR_P (dst, src, size)); */ \
1925
mp_ptr __gmp_copy_incr_dst = (dst) - 1; \
1926
mp_srcptr __gmp_copy_incr_src = (src) - 1; \
1927
mp_size_t __gmp_copy_incr_size = (size); \
1929
*++__gmp_copy_incr_dst = *++__gmp_copy_incr_src; \
1930
while (--__gmp_copy_incr_size != 0); \
1933
#define __GMPN_COPY(dst, src, size) \
1935
/* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */ \
1936
__GMPN_COPY_INCR (dst, src, size); \
1940
#if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST)
1941
#define __GMPN_COPY_REST(dst, src, size, start) \
1943
/* ASSERT ((start) >= 0); */ \
1944
/* ASSERT ((start) <= (size)); */ \
1945
__GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \
1949
/* Copy {src,size} to {dst,size}, starting at "start". This is designed to
1950
keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1,
1952
#if ! defined (__GMPN_COPY_REST)
1953
#define __GMPN_COPY_REST(dst, src, size, start) \
1955
mp_size_t __gmp_j; \
1956
/* ASSERT ((size) >= 0); */ \
1957
/* ASSERT ((start) >= 0); */ \
1958
/* ASSERT ((start) <= (size)); */ \
1959
/* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */ \
1960
for (__gmp_j = (start); __gmp_j < (size); __gmp_j++) \
1961
(dst)[__gmp_j] = (src)[__gmp_j]; \
1965
/* Enhancement: Use some of the smarter code from gmp-impl.h. Maybe use
1966
mpn_copyi if there's a native version, and if we don't mind demanding
1967
binary compatibility for it (on targets which use it). */
1969
#if ! defined (__GMPN_COPY)
1970
#define __GMPN_COPY(dst, src, size) __GMPN_COPY_REST (dst, src, size, 0)
1974
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add)
1975
#if ! defined (__GMP_FORCE_mpn_add)
1979
mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)
1982
__GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);
1987
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1)
1988
#if ! defined (__GMP_FORCE_mpn_add_1)
1992
mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW
1995
__GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);
2000
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp)
2001
#if ! defined (__GMP_FORCE_mpn_cmp)
2005
mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW
2008
__GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size);
2009
return __gmp_result;
2013
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub)
2014
#if ! defined (__GMP_FORCE_mpn_sub)
2018
mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)
2021
__GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);
2026
#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1)
2027
#if ! defined (__GMP_FORCE_mpn_sub_1)
2031
mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW
2034
__GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);
2039
#if defined (__cplusplus)
2044
/* Allow faster testing for negative, zero, and positive. */
2045
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
2046
#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)
2047
#define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0)
2049
/* When using GCC, optimize certain common comparisons. */
2050
#if defined (__GNUC__)
2051
#define mpz_cmp_ui(Z,UI) \
2052
(__builtin_constant_p (UI) && (UI) == 0 \
2053
? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))
2054
#define mpz_cmp_si(Z,SI) \
2055
(__builtin_constant_p (SI) && (SI) == 0 ? mpz_sgn (Z) \
2056
: __builtin_constant_p (SI) && (SI) > 0 \
2057
? _mpz_cmp_ui (Z, __GMP_CAST (unsigned long int, SI)) \
2058
: _mpz_cmp_si (Z,SI))
2059
#define mpq_cmp_ui(Q,NUI,DUI) \
2060
(__builtin_constant_p (NUI) && (NUI) == 0 \
2061
? mpq_sgn (Q) : _mpq_cmp_ui (Q,NUI,DUI))
2062
#define mpq_cmp_si(q,n,d) \
2063
(__builtin_constant_p ((n) >= 0) && (n) >= 0 \
2064
? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d) \
2065
: _mpq_cmp_si (q, n, d))
2067
#define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI)
2068
#define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI)
2069
#define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI)
2070
#define mpq_cmp_si(q,n,d) _mpq_cmp_si(q,n,d)
2074
/* Using "&" rather than "&&" means these can come out branch-free. Every
2075
mpz_t has at least one limb allocated, so fetching the low limb is always
2077
#define mpz_odd_p(z) (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0]))
2078
#define mpz_even_p(z) (! mpz_odd_p (z))
2081
/**************** C++ routines ****************/
2084
__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr);
2085
__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr);
2086
__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr);
2087
__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr);
2088
__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr);
2089
__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr);
2093
/* Compatibility with GMP 2 and earlier. */
2094
#define mpn_divmod(qp,np,nsize,dp,dsize) \
2095
mpn_divrem (qp, (mp_size_t) 0, np, nsize, dp, dsize)
2097
/* Compatibility with GMP 1. */
2098
#define mpz_mdiv mpz_fdiv_q
2099
#define mpz_mdivmod mpz_fdiv_qr
2100
#define mpz_mmod mpz_fdiv_r
2101
#define mpz_mdiv_ui mpz_fdiv_q_ui
2102
#define mpz_mdivmod_ui(q,r,n,d) \
2103
(((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d))
2104
#define mpz_mmod_ui(r,n,d) \
2105
(((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d))
2107
/* Useful synonyms, but not quite compatible with GMP 1. */
2108
#define mpz_div mpz_fdiv_q
2109
#define mpz_divmod mpz_fdiv_qr
2110
#define mpz_div_ui mpz_fdiv_q_ui
2111
#define mpz_divmod_ui mpz_fdiv_qr_ui
2112
#define mpz_mod_ui mpz_fdiv_r_ui
2113
#define mpz_div_2exp mpz_fdiv_q_2exp
2114
#define mpz_mod_2exp mpz_fdiv_r_2exp
2119
GMP_ERROR_UNSUPPORTED_ARGUMENT = 1,
2120
GMP_ERROR_DIVISION_BY_ZERO = 2,
2121
GMP_ERROR_SQRT_OF_NEGATIVE = 4,
2122
GMP_ERROR_INVALID_ARGUMENT = 8,
2123
GMP_ERROR_ALLOCATE = 16,
2124
GMP_ERROR_BAD_STRING = 32,
2125
GMP_ERROR_UNUSED_ERROR
2128
/* Major version number is the value of __GNU_MP__ too, above and in mp.h. */
2129
#define __GNU_MP_VERSION 4
2130
#define __GNU_MP_VERSION_MINOR 1
2131
#define __GNU_MP_VERSION_PATCHLEVEL 3
2134
#endif /* __GMP_H__ */