Merge branch 'vendor/TEXINFO'
[dragonfly.git] / contrib / mpfr / mpfr.h
1 /* mpfr.h -- Include file for mpfr.
2
3 Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by the Arenaire and Cacao projects, INRIA.
5
6 This file is part of the GNU MPFR Library.
7
8 The GNU MPFR 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 MPFR 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 MPFR Library; see the file COPYING.LIB.  If not, write to
20 the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21 MA 02110-1301, USA. */
22
23 #ifndef __MPFR_H
24 #define __MPFR_H
25
26 /* Define MPFR version number */
27 #define MPFR_VERSION_MAJOR 2
28 #define MPFR_VERSION_MINOR 4
29 #define MPFR_VERSION_PATCHLEVEL 2
30 #define MPFR_VERSION_STRING "2.4.2-p3"
31
32 /* Macros dealing with MPFR VERSION */
33 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
34 #define MPFR_VERSION \
35 MPFR_VERSION_NUM(MPFR_VERSION_MAJOR,MPFR_VERSION_MINOR,MPFR_VERSION_PATCHLEVEL)
36
37 /* Check if GMP is included, and try to include it (Works with local GMP) */
38 #ifndef __GMP_H__
39 # include <gmp.h>
40 #endif
41
42 /* Check if stdio.h is included or if the user wants FILE */
43 #if defined (_GMP_H_HAVE_FILE) || defined (MPFR_USE_FILE)
44 # define _MPFR_H_HAVE_FILE 1
45 #endif
46
47 #if defined (_GMP_H_HAVE_VA_LIST)
48 # define _MPFR_H_HAVE_VA_LIST 1
49 #endif
50
51 /* Check if <stdint.h> / <inttypes.h> is included or if the user
52    explicitly wants intmax_t, by checking INTMAX_C and UINTMAX_C.
53    We do not check INTMAX_MAX and UINTMAX_MAX because under Solaris,
54    these macros are always defined by <limits.h> (i.e. even when
55    <stdint.h> and <inttypes.h> are not included).
56    Note: with C++ implementations, the test of the C99 macros will
57    work only if the user has defined __STDC_CONSTANT_MACROS before
58    <stdint.h> has been included (see ISO C99 standard); that's why
59    _STDINT_H (defined by the glibc) and _STDINT_H_ (defined under
60    Mac OS X) are tested too, but under other OS, MPFR_USE_INTMAX_T
61    may need to be defined. */
62 #if (defined (INTMAX_C) && defined (UINTMAX_C)) || \
63   defined (MPFR_USE_INTMAX_T) || defined (_STDINT_H) || defined (_STDINT_H_)
64 # define _MPFR_H_HAVE_INTMAX_T 1
65 #endif
66
67 /* Definition of rounding modes (DON'T USE GMP_RNDNA!).
68    Warning! Changing the contents of this enum should be seen as an
69    interface change since the old and the new types are not compatible
70    (the integer type compatible with the enumerated type can even change,
71    see ISO C99, 6.7.2.2#4), and in Makefile.am, AGE should be set to 0. */
72 typedef enum {
73   GMP_RNDN=0,  /* round to nearest, with ties to even */
74   GMP_RNDZ,    /* round toward zero */
75   GMP_RNDU,    /* round toward +Inf */
76   GMP_RNDD,    /* round toward -Inf */
77   GMP_RND_MAX, /* gives number of supported rounding modes, those after are
78                   only supported by some functions */
79   GMP_RNDNA=-1 /* round to nearest, with ties away from zero (mpfr_round) */
80 } mpfr_rnd_t;
81
82 /* Define precision : 1 (short), 2 (int) or 3 (long) (DON'T USE IT!)*/
83 #ifndef _MPFR_PREC_FORMAT
84 # if __GMP_MP_SIZE_T_INT == 1
85 #  define _MPFR_PREC_FORMAT 2
86 # else
87 #  define _MPFR_PREC_FORMAT 3
88 # endif
89 #endif
90
91 #if   _MPFR_PREC_FORMAT == 1
92 typedef unsigned short mpfr_prec_t;
93 #elif _MPFR_PREC_FORMAT == 2
94 typedef unsigned int   mpfr_prec_t;
95 #elif _MPFR_PREC_FORMAT == 3
96 typedef unsigned long  mpfr_prec_t;
97 #else
98 # error "Invalid MPFR Prec format"
99 #endif
100
101 /* Definition of precision limits */
102 #define MPFR_PREC_MIN 2
103 #define MPFR_PREC_MAX ((mpfr_prec_t)((mpfr_prec_t)(~(mpfr_prec_t)0)>>1))
104
105 /* Definition of sign */
106 typedef int          mpfr_sign_t;
107
108 /* Definition of the standard exponent limits */
109 #define MPFR_EMAX_DEFAULT ((mp_exp_t) (((unsigned long) 1 << 30) - 1))
110 #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
111
112 /* Definition of the main structure */
113 typedef struct {
114   mpfr_prec_t  _mpfr_prec;
115   mpfr_sign_t  _mpfr_sign;
116   mp_exp_t     _mpfr_exp;
117   mp_limb_t   *_mpfr_d;
118 } __mpfr_struct;
119
120 /* Compatibility with previous types of MPFR */
121 #ifndef mp_rnd_t
122 # define mp_rnd_t  mpfr_rnd_t
123 #endif
124 #ifndef mp_prec_t
125 # define mp_prec_t mpfr_prec_t
126 #endif
127
128 /*
129    The represented number is
130       _sign*(_d[k-1]/B+_d[k-2]/B^2+...+_d[0]/B^k)*2^_exp
131    where k=ceil(_mp_prec/BITS_PER_MP_LIMB) and B=2^BITS_PER_MP_LIMB.
132
133    For the msb (most significant bit) normalized representation, we must have
134       _d[k-1]>=B/2, unless the number is singular.
135
136    We must also have the last k*BITS_PER_MP_LIMB-_prec bits set to zero.
137 */
138
139 typedef __mpfr_struct mpfr_t[1];
140 typedef __mpfr_struct *mpfr_ptr;
141 typedef __gmp_const __mpfr_struct *mpfr_srcptr;
142
143 /* For those who need a direct and fast access to the sign field.
144    However it is not in the API, thus use it at your own risk: it might
145    not be supported, or change name, in further versions!
146    Unfortunately, it must be defined here (instead of MPFR's internal
147    header file mpfr-impl.h) because it is used by some macros below.
148 */
149 #define MPFR_SIGN(x) ((x)->_mpfr_sign)
150
151 /* Stack interface */
152 typedef enum {
153   MPFR_NAN_KIND = 0,
154   MPFR_INF_KIND = 1, MPFR_ZERO_KIND = 2, MPFR_REGULAR_KIND = 3
155 } mpfr_kind_t;
156
157 /* GMP defines:
158     + size_t:                Standard size_t
159     + __GMP_ATTRIBUTE_PURE   Attribute for math functions.
160     + __GMP_NOTHROW          For C++: can't throw .
161     + __GMP_EXTERN_INLINE    Attribute for inline function.
162     * __gmp_const            const (Supports for K&R compiler only for mpfr.h).
163     + __GMP_DECLSPEC_EXPORT  compiling to go into a DLL
164     + __GMP_DECLSPEC_IMPORT  compiling to go into a application
165 */
166 /* Extra MPFR defines */
167 #define __MPFR_SENTINEL_ATTR
168 #if defined (__GNUC__)
169 # if __GNUC__ >= 4
170 #  undef __MPFR_SENTINEL_ATTR
171 #  define __MPFR_SENTINEL_ATTR __attribute__ ((sentinel))
172 # endif
173 #endif
174
175 /* Prototypes: Support of K&R compiler */
176 #if defined (__GMP_PROTO)
177 # define _MPFR_PROTO __GMP_PROTO
178 #elif defined (__STDC__) || defined (__cplusplus)
179 # define _MPFR_PROTO(x) x
180 #else
181 # define _MPFR_PROTO(x) ()
182 #endif
183 /* Support for WINDOWS Dll:
184    Check if we are inside a MPFR build, and if so export the functions.
185    Otherwise does the same thing as GMP */
186 #if defined(__MPFR_WITHIN_MPFR) && __GMP_LIBGMP_DLL
187 # define __MPFR_DECLSPEC __GMP_DECLSPEC_EXPORT
188 #else
189 # define __MPFR_DECLSPEC __GMP_DECLSPEC
190 #endif
191
192 /* Note: In order to be declared, some functions need a specific
193    system header to be included *before* "mpfr.h". If the user
194    forgets to include the header, the MPFR function prototype in
195    the user object file is not correct. To avoid wrong results,
196    we raise a linker error in that case by changing their internal
197    name in the library (prefixed by __gmpfr instead of mpfr). See
198    the lines of the form "#define mpfr_xxx __gmpfr_xxx" below. */
199
200 #if defined (__cplusplus)
201 extern "C" {
202 #endif
203
204 __MPFR_DECLSPEC __gmp_const char * mpfr_get_version _MPFR_PROTO ((void));
205 __MPFR_DECLSPEC __gmp_const char * mpfr_get_patches _MPFR_PROTO ((void));
206
207 __MPFR_DECLSPEC mp_exp_t mpfr_get_emin     _MPFR_PROTO ((void));
208 __MPFR_DECLSPEC int      mpfr_set_emin     _MPFR_PROTO ((mp_exp_t));
209 __MPFR_DECLSPEC mp_exp_t mpfr_get_emin_min _MPFR_PROTO ((void));
210 __MPFR_DECLSPEC mp_exp_t mpfr_get_emin_max _MPFR_PROTO ((void));
211 __MPFR_DECLSPEC mp_exp_t mpfr_get_emax     _MPFR_PROTO ((void));
212 __MPFR_DECLSPEC int      mpfr_set_emax     _MPFR_PROTO ((mp_exp_t));
213 __MPFR_DECLSPEC mp_exp_t mpfr_get_emax_min _MPFR_PROTO ((void));
214 __MPFR_DECLSPEC mp_exp_t mpfr_get_emax_max _MPFR_PROTO ((void));
215
216 __MPFR_DECLSPEC void mpfr_set_default_rounding_mode _MPFR_PROTO((mpfr_rnd_t));
217 __MPFR_DECLSPEC mp_rnd_t mpfr_get_default_rounding_mode _MPFR_PROTO((void));
218 __MPFR_DECLSPEC __gmp_const char *
219    mpfr_print_rnd_mode _MPFR_PROTO((mpfr_rnd_t));
220
221 __MPFR_DECLSPEC void mpfr_clear_flags _MPFR_PROTO ((void));
222 __MPFR_DECLSPEC void mpfr_clear_underflow _MPFR_PROTO ((void));
223 __MPFR_DECLSPEC void mpfr_clear_overflow _MPFR_PROTO ((void));
224 __MPFR_DECLSPEC void mpfr_clear_nanflag _MPFR_PROTO ((void));
225 __MPFR_DECLSPEC void mpfr_clear_inexflag _MPFR_PROTO ((void));
226 __MPFR_DECLSPEC void mpfr_clear_erangeflag _MPFR_PROTO ((void));
227
228 __MPFR_DECLSPEC void mpfr_set_underflow _MPFR_PROTO ((void));
229 __MPFR_DECLSPEC void mpfr_set_overflow _MPFR_PROTO ((void));
230 __MPFR_DECLSPEC void mpfr_set_nanflag _MPFR_PROTO ((void));
231 __MPFR_DECLSPEC void mpfr_set_inexflag _MPFR_PROTO ((void));
232 __MPFR_DECLSPEC void mpfr_set_erangeflag _MPFR_PROTO ((void));
233
234 __MPFR_DECLSPEC int mpfr_underflow_p _MPFR_PROTO ((void));
235 __MPFR_DECLSPEC int mpfr_overflow_p _MPFR_PROTO ((void));
236 __MPFR_DECLSPEC int mpfr_nanflag_p _MPFR_PROTO ((void));
237 __MPFR_DECLSPEC int mpfr_inexflag_p _MPFR_PROTO ((void));
238 __MPFR_DECLSPEC int mpfr_erangeflag_p _MPFR_PROTO ((void));
239
240 __MPFR_DECLSPEC int
241   mpfr_check_range _MPFR_PROTO ((mpfr_ptr, int, mpfr_rnd_t));
242
243 __MPFR_DECLSPEC void mpfr_init2 _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t));
244 __MPFR_DECLSPEC void mpfr_init _MPFR_PROTO ((mpfr_ptr));
245 __MPFR_DECLSPEC void mpfr_clear _MPFR_PROTO ((mpfr_ptr));
246
247 __MPFR_DECLSPEC void
248   mpfr_inits2 _MPFR_PROTO ((mp_prec_t, mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
249 __MPFR_DECLSPEC void
250   mpfr_inits _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
251 __MPFR_DECLSPEC void
252   mpfr_clears _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
253
254 __MPFR_DECLSPEC int
255   mpfr_prec_round _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t, mpfr_rnd_t));
256 __MPFR_DECLSPEC int
257   mpfr_can_round _MPFR_PROTO ((mpfr_srcptr, mp_exp_t, mpfr_rnd_t, mpfr_rnd_t,
258                                mpfr_prec_t));
259
260 __MPFR_DECLSPEC mp_exp_t mpfr_get_exp _MPFR_PROTO ((mpfr_srcptr));
261 __MPFR_DECLSPEC int mpfr_set_exp _MPFR_PROTO ((mpfr_ptr, mp_exp_t));
262 __MPFR_DECLSPEC mp_prec_t mpfr_get_prec _MPFR_PROTO((mpfr_srcptr));
263 __MPFR_DECLSPEC void mpfr_set_prec _MPFR_PROTO((mpfr_ptr, mpfr_prec_t));
264 __MPFR_DECLSPEC void mpfr_set_prec_raw _MPFR_PROTO((mpfr_ptr, mpfr_prec_t));
265 __MPFR_DECLSPEC void mpfr_set_default_prec _MPFR_PROTO((mpfr_prec_t));
266 __MPFR_DECLSPEC mp_prec_t mpfr_get_default_prec _MPFR_PROTO((void));
267
268 __MPFR_DECLSPEC int mpfr_set_d _MPFR_PROTO ((mpfr_ptr, double, mpfr_rnd_t));
269 #ifdef MPFR_WANT_DECIMAL_FLOATS
270 __MPFR_DECLSPEC int mpfr_set_decimal64 _MPFR_PROTO ((mpfr_ptr, _Decimal64,
271                                                      mp_rnd_t));
272 #endif
273 __MPFR_DECLSPEC int
274   mpfr_set_ld _MPFR_PROTO ((mpfr_ptr, long double, mpfr_rnd_t));
275 __MPFR_DECLSPEC int
276   mpfr_set_z _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, mpfr_rnd_t));
277 __MPFR_DECLSPEC void mpfr_set_nan _MPFR_PROTO ((mpfr_ptr));
278 __MPFR_DECLSPEC void mpfr_set_inf _MPFR_PROTO ((mpfr_ptr, int));
279 __MPFR_DECLSPEC int
280   mpfr_set_f _MPFR_PROTO ((mpfr_ptr, mpf_srcptr, mpfr_rnd_t));
281 __MPFR_DECLSPEC int
282   mpfr_get_f _MPFR_PROTO ((mpf_ptr, mpfr_srcptr, mpfr_rnd_t));
283 __MPFR_DECLSPEC int mpfr_set_si _MPFR_PROTO ((mpfr_ptr, long, mpfr_rnd_t));
284 __MPFR_DECLSPEC int
285   mpfr_set_ui _MPFR_PROTO ((mpfr_ptr, unsigned long, mpfr_rnd_t));
286 __MPFR_DECLSPEC int
287   mpfr_set_si_2exp _MPFR_PROTO ((mpfr_ptr, long, mp_exp_t, mpfr_rnd_t));
288 __MPFR_DECLSPEC int
289   mpfr_set_ui_2exp _MPFR_PROTO ((mpfr_ptr,unsigned long,mp_exp_t,mpfr_rnd_t));
290 __MPFR_DECLSPEC int
291   mpfr_set_q _MPFR_PROTO ((mpfr_ptr, mpq_srcptr, mpfr_rnd_t));
292 __MPFR_DECLSPEC int
293   mpfr_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int, mpfr_rnd_t));
294 __MPFR_DECLSPEC int
295   mpfr_init_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int,
296                                   mpfr_rnd_t));
297 __MPFR_DECLSPEC int
298   mpfr_set4 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t, int));
299 __MPFR_DECLSPEC int
300   mpfr_abs _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
301 __MPFR_DECLSPEC int
302   mpfr_set _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
303 __MPFR_DECLSPEC int mpfr_neg _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
304 __MPFR_DECLSPEC int mpfr_signbit _MPFR_PROTO ((mpfr_srcptr));
305 __MPFR_DECLSPEC int
306   mpfr_setsign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, int, mpfr_rnd_t));
307 __MPFR_DECLSPEC int
308   mpfr_copysign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t));
309
310 #ifdef _MPFR_H_HAVE_INTMAX_T
311 #define mpfr_set_sj __gmpfr_set_sj
312 #define mpfr_set_sj_2exp __gmpfr_set_sj_2exp
313 #define mpfr_set_uj __gmpfr_set_uj
314 #define mpfr_set_uj_2exp __gmpfr_set_uj_2exp
315 #define mpfr_get_sj __gmpfr_mpfr_get_sj
316 #define mpfr_get_uj __gmpfr_mpfr_get_uj
317 __MPFR_DECLSPEC int mpfr_set_sj _MPFR_PROTO ((mpfr_t, intmax_t, mpfr_rnd_t));
318 __MPFR_DECLSPEC int
319   mpfr_set_sj_2exp _MPFR_PROTO ((mpfr_t, intmax_t, intmax_t, mpfr_rnd_t));
320 __MPFR_DECLSPEC int mpfr_set_uj _MPFR_PROTO ((mpfr_t, uintmax_t, mpfr_rnd_t));
321 __MPFR_DECLSPEC int
322   mpfr_set_uj_2exp _MPFR_PROTO ((mpfr_t, uintmax_t, intmax_t, mpfr_rnd_t));
323 __MPFR_DECLSPEC intmax_t mpfr_get_sj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
324 __MPFR_DECLSPEC uintmax_t mpfr_get_uj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
325 #endif
326
327 __MPFR_DECLSPEC mp_exp_t mpfr_get_z_exp _MPFR_PROTO ((mpz_ptr, mpfr_srcptr));
328 __MPFR_DECLSPEC double mpfr_get_d _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
329 #ifdef MPFR_WANT_DECIMAL_FLOATS
330 __MPFR_DECLSPEC _Decimal64 mpfr_get_decimal64 _MPFR_PROTO ((mpfr_srcptr,
331                                                            mp_rnd_t));
332 #endif
333 __MPFR_DECLSPEC long double mpfr_get_ld _MPFR_PROTO ((mpfr_srcptr,
334                                                       mpfr_rnd_t));
335 __MPFR_DECLSPEC double mpfr_get_d1 _MPFR_PROTO ((mpfr_srcptr));
336 __MPFR_DECLSPEC double mpfr_get_d_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
337                                                      mpfr_rnd_t));
338 __MPFR_DECLSPEC long double mpfr_get_ld_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
339                                                            mpfr_rnd_t));
340 __MPFR_DECLSPEC long mpfr_get_si _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
341 __MPFR_DECLSPEC unsigned long mpfr_get_ui _MPFR_PROTO ((mpfr_srcptr,
342                                                         mpfr_rnd_t));
343 __MPFR_DECLSPEC char*mpfr_get_str _MPFR_PROTO ((char*, mp_exp_t*, int, size_t,
344                                                 mpfr_srcptr, mpfr_rnd_t));
345 __MPFR_DECLSPEC void mpfr_get_z _MPFR_PROTO ((mpz_ptr z, mpfr_srcptr f,
346                                               mpfr_rnd_t));
347
348 __MPFR_DECLSPEC void mpfr_free_str _MPFR_PROTO ((char *));
349
350
351 __MPFR_DECLSPEC void mpfr_random _MPFR_PROTO ((mpfr_ptr));
352 __MPFR_DECLSPEC void mpfr_random2 _MPFR_PROTO ((mpfr_ptr,mp_size_t,mp_exp_t));
353 __MPFR_DECLSPEC int mpfr_urandomb _MPFR_PROTO ((mpfr_ptr, gmp_randstate_t));
354
355 __MPFR_DECLSPEC void mpfr_nextabove _MPFR_PROTO ((mpfr_ptr));
356 __MPFR_DECLSPEC void mpfr_nextbelow _MPFR_PROTO ((mpfr_ptr));
357 __MPFR_DECLSPEC void mpfr_nexttoward _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr));
358
359 #ifdef _MPFR_H_HAVE_FILE
360 #define mpfr_inp_str __gmpfr_inp_str
361 #define mpfr_out_str __gmpfr_out_str
362 __MPFR_DECLSPEC size_t mpfr_inp_str _MPFR_PROTO ((mpfr_ptr, FILE*, int,
363                                                   mpfr_rnd_t));
364 __MPFR_DECLSPEC size_t mpfr_out_str _MPFR_PROTO ((FILE*, int, size_t,
365                                                   mpfr_srcptr, mpfr_rnd_t));
366 #define mpfr_fprintf __gmpfr_fprintf
367 __MPFR_DECLSPEC int mpfr_fprintf _MPFR_PROTO ((FILE*, __gmp_const char*,
368                                                ...));
369 #endif
370 __MPFR_DECLSPEC int mpfr_printf _MPFR_PROTO ((__gmp_const char*, ...));
371 __MPFR_DECLSPEC int mpfr_asprintf _MPFR_PROTO ((char**, __gmp_const char*,
372                                                 ...));
373 __MPFR_DECLSPEC int mpfr_sprintf _MPFR_PROTO ((char*, __gmp_const char*,
374                                                ...));
375 __MPFR_DECLSPEC int mpfr_snprintf _MPFR_PROTO ((char*, size_t,
376                                                 __gmp_const char*, ...));
377
378 #ifdef _MPFR_H_HAVE_VA_LIST
379 #ifdef _MPFR_H_HAVE_FILE
380 #define mpfr_vfprintf __gmpfr_vfprintf
381 __MPFR_DECLSPEC int mpfr_vfprintf _MPFR_PROTO ((FILE*, __gmp_const char*,
382                                                 va_list));
383 #endif /* _MPFR_H_HAVE_FILE */
384 #define mpfr_vprintf __gmpfr_vprintf
385 #define mpfr_vasprintf __gmpfr_vasprintf
386 #define mpfr_vsprintf __gmpfr_vsprintf
387 #define mpfr_vsnprintf __gmpfr_vsnprintf
388 __MPFR_DECLSPEC int mpfr_vprintf _MPFR_PROTO ((__gmp_const char*, va_list));
389 __MPFR_DECLSPEC int mpfr_vasprintf _MPFR_PROTO ((char**, __gmp_const char*,
390                                                  va_list));
391 __MPFR_DECLSPEC int mpfr_vsprintf _MPFR_PROTO ((char*, __gmp_const char*,
392                                                va_list));
393 __MPFR_DECLSPEC int mpfr_vsnprintf _MPFR_PROTO ((char*, size_t,
394                                                 __gmp_const char*, va_list));
395 #endif /* _MPFR_H_HAVE_VA_LIST */
396
397 __MPFR_DECLSPEC int mpfr_pow _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
398                                            mpfr_srcptr, mpfr_rnd_t));
399 __MPFR_DECLSPEC int mpfr_pow_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
400                                               long int, mpfr_rnd_t));
401 __MPFR_DECLSPEC int mpfr_pow_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
402                                               unsigned long int, mpfr_rnd_t));
403 __MPFR_DECLSPEC int mpfr_ui_pow_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
404                                              unsigned long int, mpfr_rnd_t));
405 __MPFR_DECLSPEC int mpfr_ui_pow _MPFR_PROTO ((mpfr_ptr, unsigned long int,
406                                               mpfr_srcptr, mpfr_rnd_t));
407 __MPFR_DECLSPEC int mpfr_pow_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
408                                              mpz_srcptr, mpfr_rnd_t));
409
410 __MPFR_DECLSPEC int mpfr_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
411                                             mpfr_rnd_t));
412 __MPFR_DECLSPEC int mpfr_sqrt_ui _MPFR_PROTO ((mpfr_ptr, unsigned long,
413                                                mpfr_rnd_t));
414 __MPFR_DECLSPEC int mpfr_rec_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
415                                                 mpfr_rnd_t));
416
417 __MPFR_DECLSPEC int mpfr_add _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
418                                            mpfr_srcptr, mpfr_rnd_t));
419 __MPFR_DECLSPEC int mpfr_sub _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
420                                            mpfr_srcptr, mpfr_rnd_t));
421 __MPFR_DECLSPEC int mpfr_mul _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
422                                            mpfr_srcptr, mpfr_rnd_t));
423 __MPFR_DECLSPEC int mpfr_div _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
424                                            mpfr_srcptr, mpfr_rnd_t));
425
426 __MPFR_DECLSPEC int mpfr_add_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
427                                               unsigned long, mpfr_rnd_t));
428 __MPFR_DECLSPEC int mpfr_sub_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
429                                               unsigned long, mpfr_rnd_t));
430 __MPFR_DECLSPEC int mpfr_ui_sub _MPFR_PROTO ((mpfr_ptr, unsigned long,
431                                               mpfr_srcptr, mpfr_rnd_t));
432 __MPFR_DECLSPEC int mpfr_mul_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
433                                               unsigned long, mpfr_rnd_t));
434 __MPFR_DECLSPEC int mpfr_div_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
435                                               unsigned long, mpfr_rnd_t));
436 __MPFR_DECLSPEC int mpfr_ui_div _MPFR_PROTO ((mpfr_ptr, unsigned long,
437                                               mpfr_srcptr, mpfr_rnd_t));
438
439 __MPFR_DECLSPEC int mpfr_add_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
440                                               long int, mpfr_rnd_t));
441 __MPFR_DECLSPEC int mpfr_sub_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
442                                               long int, mpfr_rnd_t));
443 __MPFR_DECLSPEC int mpfr_si_sub _MPFR_PROTO ((mpfr_ptr, long int,
444                                               mpfr_srcptr, mpfr_rnd_t));
445 __MPFR_DECLSPEC int mpfr_mul_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
446                                               long int, mpfr_rnd_t));
447 __MPFR_DECLSPEC int mpfr_div_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
448                                               long int, mpfr_rnd_t));
449 __MPFR_DECLSPEC int mpfr_si_div _MPFR_PROTO ((mpfr_ptr, long int,
450                                               mpfr_srcptr, mpfr_rnd_t));
451
452 __MPFR_DECLSPEC int mpfr_add_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
453                                               double, mpfr_rnd_t));
454 __MPFR_DECLSPEC int mpfr_sub_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
455                                               double, mpfr_rnd_t));
456 __MPFR_DECLSPEC int mpfr_d_sub _MPFR_PROTO ((mpfr_ptr, double,
457                                               mpfr_srcptr, mpfr_rnd_t));
458 __MPFR_DECLSPEC int mpfr_mul_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
459                                               double, mpfr_rnd_t));
460 __MPFR_DECLSPEC int mpfr_div_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
461                                               double, mpfr_rnd_t));
462 __MPFR_DECLSPEC int mpfr_d_div _MPFR_PROTO ((mpfr_ptr, double,
463                                               mpfr_srcptr, mpfr_rnd_t));
464
465 __MPFR_DECLSPEC int mpfr_sqr _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
466
467 __MPFR_DECLSPEC int mpfr_const_pi _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
468 __MPFR_DECLSPEC int mpfr_const_log2 _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
469 __MPFR_DECLSPEC int mpfr_const_euler _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
470 __MPFR_DECLSPEC int mpfr_const_catalan _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
471
472 __MPFR_DECLSPEC int mpfr_agm _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
473                                            mpfr_rnd_t));
474
475 __MPFR_DECLSPEC int mpfr_log _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
476 __MPFR_DECLSPEC int mpfr_log2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
477 __MPFR_DECLSPEC int mpfr_log10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
478                                              mpfr_rnd_t));
479 __MPFR_DECLSPEC int mpfr_log1p _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
480                                              mpfr_rnd_t));
481
482 __MPFR_DECLSPEC int mpfr_exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
483 __MPFR_DECLSPEC int mpfr_exp2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
484 __MPFR_DECLSPEC int mpfr_exp10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
485                                              mpfr_rnd_t));
486 __MPFR_DECLSPEC int mpfr_expm1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
487                                              mpfr_rnd_t));
488 __MPFR_DECLSPEC int mpfr_eint _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
489 __MPFR_DECLSPEC int mpfr_li2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
490
491 __MPFR_DECLSPEC int mpfr_cmp  _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
492 __MPFR_DECLSPEC int mpfr_cmp3 _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr, int));
493 __MPFR_DECLSPEC int mpfr_cmp_d _MPFR_PROTO ((mpfr_srcptr, double));
494 __MPFR_DECLSPEC int mpfr_cmp_ld _MPFR_PROTO ((mpfr_srcptr, long double));
495 __MPFR_DECLSPEC int mpfr_cmpabs _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
496 __MPFR_DECLSPEC int mpfr_cmp_ui _MPFR_PROTO ((mpfr_srcptr, unsigned long));
497 __MPFR_DECLSPEC int mpfr_cmp_si _MPFR_PROTO ((mpfr_srcptr, long));
498 __MPFR_DECLSPEC int mpfr_cmp_ui_2exp _MPFR_PROTO ((mpfr_srcptr, unsigned long,
499                                                    mp_exp_t));
500 __MPFR_DECLSPEC int mpfr_cmp_si_2exp _MPFR_PROTO ((mpfr_srcptr, long,
501                                                    mp_exp_t));
502 __MPFR_DECLSPEC void mpfr_reldiff _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
503                                                 mpfr_srcptr, mpfr_rnd_t));
504 __MPFR_DECLSPEC int mpfr_eq _MPFR_PROTO((mpfr_srcptr, mpfr_srcptr,
505                                          unsigned long));
506 __MPFR_DECLSPEC int mpfr_sgn _MPFR_PROTO ((mpfr_srcptr));
507
508 __MPFR_DECLSPEC int mpfr_mul_2exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
509                                                 unsigned long, mpfr_rnd_t));
510 __MPFR_DECLSPEC int mpfr_div_2exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
511                                                 unsigned long, mpfr_rnd_t));
512 __MPFR_DECLSPEC int mpfr_mul_2ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
513                                                unsigned long, mpfr_rnd_t));
514 __MPFR_DECLSPEC int mpfr_div_2ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
515                                                unsigned long, mpfr_rnd_t));
516 __MPFR_DECLSPEC int mpfr_mul_2si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
517                                                long, mpfr_rnd_t));
518 __MPFR_DECLSPEC int mpfr_div_2si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
519                                                long, mpfr_rnd_t));
520
521 __MPFR_DECLSPEC int mpfr_rint _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
522 __MPFR_DECLSPEC int mpfr_round _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
523 __MPFR_DECLSPEC int mpfr_trunc _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
524 __MPFR_DECLSPEC int mpfr_ceil _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
525 __MPFR_DECLSPEC int mpfr_floor _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
526 __MPFR_DECLSPEC int mpfr_rint_round _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
527                                                   mpfr_rnd_t));
528 __MPFR_DECLSPEC int mpfr_rint_trunc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
529                                                   mpfr_rnd_t));
530 __MPFR_DECLSPEC int mpfr_rint_ceil _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
531                                                  mpfr_rnd_t));
532 __MPFR_DECLSPEC int mpfr_rint_floor _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
533                                                   mpfr_rnd_t));
534 __MPFR_DECLSPEC int mpfr_frac _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
535 __MPFR_DECLSPEC int mpfr_modf _MPFR_PROTO ((mpfr_ptr, mpfr_ptr, mpfr_srcptr,
536                                                   mpfr_rnd_t));
537 __MPFR_DECLSPEC int mpfr_remquo _MPFR_PROTO ((mpfr_ptr, long*, mpfr_srcptr,
538                                               mpfr_srcptr, mp_rnd_t));
539 __MPFR_DECLSPEC int mpfr_remainder _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
540                                                  mpfr_srcptr, mp_rnd_t));
541 __MPFR_DECLSPEC int mpfr_fmod _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
542                                                  mpfr_srcptr, mp_rnd_t));
543
544 __MPFR_DECLSPEC int mpfr_fits_ulong_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
545 __MPFR_DECLSPEC int mpfr_fits_slong_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
546 __MPFR_DECLSPEC int mpfr_fits_uint_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
547 __MPFR_DECLSPEC int mpfr_fits_sint_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
548 __MPFR_DECLSPEC int mpfr_fits_ushort_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
549 __MPFR_DECLSPEC int mpfr_fits_sshort_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
550 __MPFR_DECLSPEC int mpfr_fits_uintmax_p _MPFR_PROTO((mpfr_srcptr,mpfr_rnd_t));
551 __MPFR_DECLSPEC int mpfr_fits_intmax_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
552
553 __MPFR_DECLSPEC void mpfr_extract _MPFR_PROTO ((mpz_ptr, mpfr_srcptr,
554                                                 unsigned int));
555 __MPFR_DECLSPEC void mpfr_swap _MPFR_PROTO ((mpfr_ptr, mpfr_ptr));
556 __MPFR_DECLSPEC void mpfr_dump _MPFR_PROTO ((mpfr_srcptr));
557
558 __MPFR_DECLSPEC int mpfr_nan_p _MPFR_PROTO((mpfr_srcptr));
559 __MPFR_DECLSPEC int mpfr_inf_p _MPFR_PROTO((mpfr_srcptr));
560 __MPFR_DECLSPEC int mpfr_number_p _MPFR_PROTO((mpfr_srcptr));
561 __MPFR_DECLSPEC int mpfr_integer_p _MPFR_PROTO ((mpfr_srcptr));
562 __MPFR_DECLSPEC int mpfr_zero_p _MPFR_PROTO ((mpfr_srcptr));
563
564 __MPFR_DECLSPEC int mpfr_greater_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
565 __MPFR_DECLSPEC int mpfr_greaterequal_p _MPFR_PROTO ((mpfr_srcptr,
566                                                       mpfr_srcptr));
567 __MPFR_DECLSPEC int mpfr_less_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
568 __MPFR_DECLSPEC int mpfr_lessequal_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
569 __MPFR_DECLSPEC int mpfr_lessgreater_p _MPFR_PROTO((mpfr_srcptr,mpfr_srcptr));
570 __MPFR_DECLSPEC int mpfr_equal_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
571 __MPFR_DECLSPEC int mpfr_unordered_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
572
573 __MPFR_DECLSPEC int mpfr_atanh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
574 __MPFR_DECLSPEC int mpfr_acosh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
575 __MPFR_DECLSPEC int mpfr_asinh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
576 __MPFR_DECLSPEC int mpfr_cosh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
577 __MPFR_DECLSPEC int mpfr_sinh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
578 __MPFR_DECLSPEC int mpfr_tanh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
579 __MPFR_DECLSPEC int mpfr_sinh_cosh _MPFR_PROTO ((mpfr_ptr, mpfr_ptr,
580                                                mpfr_srcptr, mpfr_rnd_t));
581
582 __MPFR_DECLSPEC int mpfr_sech _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
583 __MPFR_DECLSPEC int mpfr_csch _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
584 __MPFR_DECLSPEC int mpfr_coth _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
585
586 __MPFR_DECLSPEC int mpfr_acos _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
587 __MPFR_DECLSPEC int mpfr_asin _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
588 __MPFR_DECLSPEC int mpfr_atan _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
589 __MPFR_DECLSPEC int mpfr_sin _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
590 __MPFR_DECLSPEC int mpfr_sin_cos _MPFR_PROTO ((mpfr_ptr, mpfr_ptr,
591                                                mpfr_srcptr, mpfr_rnd_t));
592 __MPFR_DECLSPEC int mpfr_cos _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
593 __MPFR_DECLSPEC int mpfr_tan _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
594 __MPFR_DECLSPEC int mpfr_atan2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_srcptr,
595                                              mpfr_rnd_t));
596 __MPFR_DECLSPEC int mpfr_sec _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
597 __MPFR_DECLSPEC int mpfr_csc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
598 __MPFR_DECLSPEC int mpfr_cot _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
599
600 __MPFR_DECLSPEC int mpfr_hypot _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
601                                              mpfr_srcptr, mpfr_rnd_t));
602 __MPFR_DECLSPEC int mpfr_erf _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
603 __MPFR_DECLSPEC int mpfr_erfc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
604 __MPFR_DECLSPEC int mpfr_cbrt _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
605 __MPFR_DECLSPEC int mpfr_root _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,unsigned long,mpfr_rnd_t));
606 __MPFR_DECLSPEC int mpfr_gamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
607 __MPFR_DECLSPEC int mpfr_lngamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
608 __MPFR_DECLSPEC int mpfr_lgamma _MPFR_PROTO((mpfr_ptr,int*,mpfr_srcptr,mpfr_rnd_t));
609 __MPFR_DECLSPEC int mpfr_zeta _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
610 __MPFR_DECLSPEC int mpfr_zeta_ui _MPFR_PROTO ((mpfr_ptr,unsigned long,mpfr_rnd_t));
611 __MPFR_DECLSPEC int mpfr_fac_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
612                                               mpfr_rnd_t));
613 __MPFR_DECLSPEC int mpfr_j0 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
614 __MPFR_DECLSPEC int mpfr_j1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
615 __MPFR_DECLSPEC int mpfr_jn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr,
616                                           mpfr_rnd_t));
617 __MPFR_DECLSPEC int mpfr_y0 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
618 __MPFR_DECLSPEC int mpfr_y1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
619 __MPFR_DECLSPEC int mpfr_yn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr,
620                                           mpfr_rnd_t));
621
622 __MPFR_DECLSPEC int mpfr_min _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
623                                            mpfr_rnd_t));
624 __MPFR_DECLSPEC int mpfr_max _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
625                                            mpfr_rnd_t));
626 __MPFR_DECLSPEC int mpfr_dim _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
627                                            mpfr_rnd_t));
628
629 __MPFR_DECLSPEC int mpfr_mul_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
630                                              mpz_srcptr, mpfr_rnd_t));
631 __MPFR_DECLSPEC int mpfr_div_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
632                                              mpz_srcptr, mpfr_rnd_t));
633 __MPFR_DECLSPEC int mpfr_add_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
634                                              mpz_srcptr, mpfr_rnd_t));
635 __MPFR_DECLSPEC int mpfr_sub_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
636                                              mpz_srcptr, mpfr_rnd_t));
637 __MPFR_DECLSPEC int mpfr_cmp_z _MPFR_PROTO ((mpfr_srcptr, mpz_srcptr));
638
639 __MPFR_DECLSPEC int mpfr_mul_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
640                                              mpq_srcptr, mpfr_rnd_t));
641 __MPFR_DECLSPEC int mpfr_div_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
642                                              mpq_srcptr, mpfr_rnd_t));
643 __MPFR_DECLSPEC int mpfr_add_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
644                                              mpq_srcptr, mpfr_rnd_t));
645 __MPFR_DECLSPEC int mpfr_sub_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
646                                              mpq_srcptr, mpfr_rnd_t));
647 __MPFR_DECLSPEC int mpfr_cmp_q _MPFR_PROTO ((mpfr_srcptr, mpq_srcptr));
648
649 __MPFR_DECLSPEC int mpfr_cmp_f _MPFR_PROTO ((mpfr_srcptr, mpf_srcptr));
650
651 __MPFR_DECLSPEC int mpfr_fma _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
652                                            mpfr_srcptr, mpfr_rnd_t));
653 __MPFR_DECLSPEC int mpfr_fms _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
654                                            mpfr_srcptr, mpfr_rnd_t));
655 __MPFR_DECLSPEC int mpfr_sum _MPFR_PROTO ((mpfr_ptr, mpfr_ptr *__gmp_const,
656                                            unsigned long, mpfr_rnd_t));
657
658 __MPFR_DECLSPEC void mpfr_free_cache _MPFR_PROTO ((void));
659
660 __MPFR_DECLSPEC int  mpfr_subnormalize _MPFR_PROTO ((mpfr_ptr, int,
661                                                      mp_rnd_t));
662
663 __MPFR_DECLSPEC int  mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *,
664                                                 char **, int, mpfr_rnd_t));
665
666 __MPFR_DECLSPEC size_t mpfr_custom_get_size   _MPFR_PROTO ((mp_prec_t));
667 __MPFR_DECLSPEC void   mpfr_custom_init       _MPFR_PROTO ((void *, mp_prec_t));
668 __MPFR_DECLSPEC void * mpfr_custom_get_mantissa _MPFR_PROTO ((mpfr_srcptr));
669 __MPFR_DECLSPEC mp_exp_t mpfr_custom_get_exp  _MPFR_PROTO ((mpfr_srcptr));
670 __MPFR_DECLSPEC void   mpfr_custom_move       _MPFR_PROTO ((mpfr_ptr, void *));
671 __MPFR_DECLSPEC void   mpfr_custom_init_set   _MPFR_PROTO ((mpfr_ptr, int,
672                                                mp_exp_t, mp_prec_t, void *));
673 __MPFR_DECLSPEC int    mpfr_custom_get_kind   _MPFR_PROTO ((mpfr_srcptr));
674
675 #if defined (__cplusplus)
676 }
677 #endif
678
679 /* DON'T USE THIS! (For MPFR-public macros only, see below.)
680    The mpfr_sgn macro uses the fact that __MPFR_EXP_NAN and __MPFR_EXP_ZERO
681    are the smallest values. */
682 #if __GMP_MP_SIZE_T_INT
683 #define __MPFR_EXP_NAN  ((mp_exp_t)((~((~(unsigned int)0)>>1))+2))
684 #define __MPFR_EXP_ZERO ((mp_exp_t)((~((~(unsigned int)0)>>1))+1))
685 #define __MPFR_EXP_INF  ((mp_exp_t)((~((~(unsigned int)0)>>1))+3))
686 #else
687 #define __MPFR_EXP_NAN  ((mp_exp_t)((~((~(unsigned long)0)>>1))+2))
688 #define __MPFR_EXP_ZERO ((mp_exp_t)((~((~(unsigned long)0)>>1))+1))
689 #define __MPFR_EXP_INF  ((mp_exp_t)((~((~(unsigned long)0)>>1))+3))
690 #endif
691
692 /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
693 #ifndef MPFR_EXTENSION
694 # if defined(MPFR_USE_EXTENSION)
695 #  define MPFR_EXTENSION __extension__
696 # else
697 #  define MPFR_EXTENSION
698 # endif
699 #endif
700
701 /* Warning! This macro doesn't work with K&R C and shouldn't be used
702    internally. For public use only, but see the MPFR manual. */
703 #define MPFR_DECL_INIT(_x, _p)                                        \
704   MPFR_EXTENSION mp_limb_t __gmpfr_local_tab_##_x[((_p)-1)/GMP_NUMB_BITS+1]; \
705   MPFR_EXTENSION mpfr_t _x = {{(_p),1,__MPFR_EXP_NAN,__gmpfr_local_tab_##_x}}
706
707 /* Fast access macros to replace function interface.
708    If the USER don't want to use the macro interface, let him make happy
709    even if it produces faster and smaller code. */
710 #ifndef MPFR_USE_NO_MACRO
711
712 /* Inlining theses functions is both faster and smaller */
713 #define mpfr_nan_p(_x)    ((_x)->_mpfr_exp == __MPFR_EXP_NAN)
714 #define mpfr_inf_p(_x)    ((_x)->_mpfr_exp == __MPFR_EXP_INF)
715 #define mpfr_zero_p(_x)   ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
716 #define mpfr_sgn(_x)                                          \
717   ((_x)->_mpfr_exp < __MPFR_EXP_INF ?                         \
718    (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (void) 0), 0 : \
719    MPFR_SIGN (_x))
720
721 /* Prevent them from using as lvalues */
722 #define mpfr_get_prec(_x) ((_x)->_mpfr_prec + 0)
723 #define mpfr_get_exp(_x)  ((_x)->_mpfr_exp + 0)
724
725 #define mpfr_round(a,b) mpfr_rint((a), (b), GMP_RNDNA)
726 #define mpfr_trunc(a,b) mpfr_rint((a), (b), GMP_RNDZ)
727 #define mpfr_ceil(a,b)  mpfr_rint((a), (b), GMP_RNDU)
728 #define mpfr_floor(a,b) mpfr_rint((a), (b), GMP_RNDD)
729
730 #define mpfr_cmp_ui(b,i) mpfr_cmp_ui_2exp((b),(i),0)
731 #define mpfr_cmp_si(b,i) mpfr_cmp_si_2exp((b),(i),0)
732 #define mpfr_set(a,b,r)  mpfr_set4(a,b,r,MPFR_SIGN(b))
733 #define mpfr_abs(a,b,r)  mpfr_set4(a,b,r,1)
734 #define mpfr_copysign(a,b,c,r) mpfr_set4(a,b,r,MPFR_SIGN(c))
735 #define mpfr_setsign(a,b,s,r) mpfr_set4(a,b,r,(s) ? -1 : 1)
736 #define mpfr_signbit(x)  (MPFR_SIGN(x) < 0)
737 #define mpfr_cmp(b, c)   mpfr_cmp3(b, c, 1)
738 #define mpfr_mul_2exp(y,x,n,r) mpfr_mul_2ui((y),(x),(n),(r))
739 #define mpfr_div_2exp(y,x,n,r) mpfr_div_2ui((y),(x),(n),(r))
740
741
742 /* When using GCC, optimize certain common comparisons and affectations.
743    + Remove ICC since it defines __GNUC__ but produces a
744      huge number of warnings if you use this code.
745      VL: I couldn't reproduce a single warning when enabling these macros
746      with icc 10.1 20080212 on Itanium. But with this version, __ICC isn't
747      defined (__INTEL_COMPILER is, though), so that these macros are enabled
748      anyway. Checking with other ICC versions is needed. Possibly detect
749      whether warnings are produced or not with a configure test.
750    + Remove C++ too, since it complains too much. */
751 #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
752 #if (__GNUC__ >= 2)
753 #undef mpfr_cmp_ui
754 /* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */
755 #define mpfr_cmp_ui(_f,_u)                 \
756  (__builtin_constant_p (_u) && (_u) == 0 ? \
757    mpfr_sgn (_f) :                         \
758    mpfr_cmp_ui_2exp ((_f),(_u),0))
759 #undef mpfr_cmp_si
760 #define mpfr_cmp_si(_f,_s)                 \
761  (__builtin_constant_p (_s) && (_s) >= 0 ? \
762    mpfr_cmp_ui ((_f), (_s)) :              \
763    mpfr_cmp_si_2exp ((_f), (_s), 0))
764 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
765 #undef mpfr_set_ui
766 #define mpfr_set_ui(_f,_u,_r)              \
767  (__builtin_constant_p (_u) && (_u) == 0 ? \
768    __extension__ ({                        \
769      mpfr_ptr _p = (_f);                   \
770      _p->_mpfr_sign = 1;                   \
771      _p->_mpfr_exp = __MPFR_EXP_ZERO;      \
772      (void) (_r); 0; }) :                  \
773    mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
774 #endif
775 #undef mpfr_set_si
776 #define mpfr_set_si(_f,_s,_r)              \
777  (__builtin_constant_p (_s) && (_s) >= 0 ? \
778    mpfr_set_ui ((_f), (_s), (_r)) :        \
779    mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
780 #endif
781 #endif
782
783 /* Macro version of mpfr_stack interface for fast access */
784 #define mpfr_custom_get_size(p) ((size_t)                            \
785        (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t)))
786 #define mpfr_custom_init(m,p) do {} while (0)
787 #define mpfr_custom_get_mantissa(x) ((void*)((x)->_mpfr_d))
788 #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp)
789 #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0)
790 #define mpfr_custom_init_set(x,k,e,p,m) do {                    \
791   mpfr_ptr _x = (x);                                           \
792   mp_exp_t _e;                                                 \
793   mpfr_kind_t _t;                                              \
794   int _s, _k;                                                  \
795   _k = (k);                                                    \
796   if (_k >= 0)  {                                              \
797     _t = (mpfr_kind_t) _k;                                     \
798     _s = 1;                                                    \
799   } else {                                                     \
800     _t = (mpfr_kind_t) -k;                                     \
801     _s = -1;                                                   \
802   }                                                            \
803   _e = _t == MPFR_REGULAR_KIND ? (e) :                         \
804     _t == MPFR_NAN_KIND ? __MPFR_EXP_NAN :                     \
805     _t == MPFR_INF_KIND ? __MPFR_EXP_INF : __MPFR_EXP_ZERO;    \
806   _x->_mpfr_prec = (p);                                        \
807   _x->_mpfr_sign = _s;                                         \
808   _x->_mpfr_exp  = _e;                                         \
809   _x->_mpfr_d    = (mp_limb_t*) (m);                           \
810  } while (0)
811 #define mpfr_custom_get_kind(x)                                              \
812   ( (x)->_mpfr_exp >  __MPFR_EXP_INF ? (int)MPFR_REGULAR_KIND*MPFR_SIGN (x) \
813   : (x)->_mpfr_exp == __MPFR_EXP_INF ? (int)MPFR_INF_KIND*MPFR_SIGN (x)     \
814   : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (int)MPFR_NAN_KIND                   \
815   : (int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
816
817
818 #endif /* MPFR_USE_NO_MACRO */
819
820 /* Theses are defined to be macros */
821 #define mpfr_init_set_si(x, i, rnd) \
822  ( mpfr_init(x), mpfr_set_si((x), (i), (rnd)) )
823 #define mpfr_init_set_ui(x, i, rnd) \
824  ( mpfr_init(x), mpfr_set_ui((x), (i), (rnd)) )
825 #define mpfr_init_set_d(x, d, rnd) \
826  ( mpfr_init(x), mpfr_set_d((x), (d), (rnd)) )
827 #define mpfr_init_set_ld(x, d, rnd) \
828  ( mpfr_init(x), mpfr_set_ld((x), (d), (rnd)) )
829 #define mpfr_init_set_z(x, i, rnd) \
830  ( mpfr_init(x), mpfr_set_z((x), (i), (rnd)) )
831 #define mpfr_init_set_q(x, i, rnd) \
832  ( mpfr_init(x), mpfr_set_q((x), (i), (rnd)) )
833 #define mpfr_init_set(x, y, rnd) \
834  ( mpfr_init(x), mpfr_set((x), (y), (rnd)) )
835 #define mpfr_init_set_f(x, y, rnd) \
836  ( mpfr_init(x), mpfr_set_f((x), (y), (rnd)) )
837
838 /* Compatibility layer -- obsolete functions and macros */
839 #define mpfr_cmp_abs mpfr_cmpabs
840 #define mpfr_round_prec(x,r,p) mpfr_prec_round(x,p,r)
841 #define __gmp_default_rounding_mode (mpfr_get_default_rounding_mode())
842 #define __mpfr_emin (mpfr_get_emin())
843 #define __mpfr_emax (mpfr_get_emax())
844 #define __mpfr_default_fp_bit_precision (mpfr_get_default_fp_bit_precision())
845 #define MPFR_EMIN_MIN mpfr_get_emin_min()
846 #define MPFR_EMIN_MAX mpfr_get_emin_max()
847 #define MPFR_EMAX_MIN mpfr_get_emax_min()
848 #define MPFR_EMAX_MAX mpfr_get_emax_max()
849 #define mpfr_version (mpfr_get_version())
850 #ifndef mpz_set_fr
851 # define mpz_set_fr mpfr_get_z
852 #endif
853 #define mpfr_add_one_ulp(x,r) \
854  (mpfr_sgn (x) > 0 ? mpfr_nextabove (x) : mpfr_nextbelow (x))
855 #define mpfr_sub_one_ulp(x,r) \
856  (mpfr_sgn (x) > 0 ? mpfr_nextbelow (x) : mpfr_nextabove (x))
857
858 #endif /* __MPFR_H*/