1 /* Configuration data for libmath subpart of libstdc++. */
3 /* Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
5 This file is part of the GNU ISO C++ Library. This library is free
6 software; you can redistribute it and/or modify it under the
7 terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option)
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this library; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 As a special exception, you may use this file as part of a free software
22 library without restriction. Specifically, if other files instantiate
23 templates or use macros or inline functions from this file, or you compile
24 this file and link it with other files to produce an executable, this
25 file does not by itself cause the resulting executable to be covered by
26 the GNU General Public License. This exception does not however
27 invalidate any other reasons why the executable file might be covered by
28 the GNU General Public License. */
31 #include <bits/c++config.h>
33 #ifdef _GLIBCPP_HAVE_ENDIAN_H
36 # ifdef _GLIBCPP_HAVE_MACHINE_ENDIAN_H
37 # include <machine/endian.h>
39 # ifdef _GLIBCPP_HAVE_SYS_MACHINE_H
40 # include <sys/machine.h>
42 # if defined _GLIBCPP_HAVE_SYS_ISA_DEFS_H || defined _GLIBCPP_HAVE_MACHINE_PARAM_H
43 /* This is on Solaris. */
44 # ifdef _GLIBCPP_HAVE_SYS_ISA_DEFS_H
45 # include <sys/isa_defs.h>
47 # ifdef _GLIBCPP_HAVE_MACHINE_PARAM_H
48 # include <machine/param.h>
50 # ifdef _LITTLE_ENDIAN
51 # define LITTLE_ENDIAN 1
58 /* We have to rely on the AC_C_BIGENDIAN test. */
59 # ifdef WORDS_BIGENDIAN
62 # define LITTLE_ENDIAN 1
70 typedef unsigned int U_int32_t
__attribute ((mode (SI
)));
71 typedef int Int32_t
__attribute ((mode (SI
)));
72 typedef unsigned int U_int64_t
__attribute ((mode (DI
)));
73 typedef int Uint64_t
__attribute ((mode (DI
)));
75 #ifdef _GLIBCPP_HAVE_NAN_H
84 #ifdef _GLIBCPP_HAVE_IEEEFP_H
88 #ifdef _GLIBCPP_HAVE_FP_H
92 #ifdef _GLIBCPP_HAVE_FLOAT_H
96 /* `float' variant of HUGE_VAL. */
99 # define HUGE_VALF HUGE_VALf
101 # define HUGE_VALF HUGE_VAL
105 /* `long double' variant of HUGE_VAL. */
108 # define HUGE_VALL HUGE_VALl
110 # define HUGE_VALL HUGE_VAL
114 /* Make sure that at least HUGE_VAL is defined. */
117 # define HUGE_VAL HUGE
120 # define HUGE_VAL MAXFLOAT
122 # error "We need HUGE_VAL!"
128 # define M_PI 3.14159265358979323846
131 /* Test whether number is finite. */
133 /* This is an ISO C 9x function. */
134 # define FINITE_P(X) isfinite (X)
135 # define FINITEF_P(X) isfinite (X)
136 # define FINITEL_P(X) isfinite (X)
139 /* This is for Solaris, which does not have special macros for other
141 # define FINITE_P(X) (!IsNANorINF (X))
142 # define FINITEF_P(X) (!IsNANorINF (X))
143 # define FINITEL_P(X) (!IsNANorINF (X))
145 # if defined _GLIBCPP_HAVE_ISINF && defined _GLIBCPP_HAVE_ISNAN
146 # define FINITE_P(X) ({ double __x = (X); !isinf (__x) && !isnan (__x); })
148 # ifdef _GLIBCPP_HAVE_FINITE
149 # define FINITE_P(X) finite (X)
151 # error "We need FINITE_P"
154 # if defined _GLIBCPP_HAVE_ISINFF && defined _GLIBCPP_HAVE_ISNANF
155 # define FINITEF_P(X) ({ float __x = (X); !isinff (__x) && !isnanf (__x); })
157 # ifdef _GLIBCPP_HAVE_FINITE
158 # define FINITEF_P(X) finite (X)
160 # define FINITEF_P(X) FINITE_P (X)
163 # if defined _GLIBCPP_HAVE_ISINFL && defined _GLIBCPP_HAVE_ISNANL
164 # define FINITEL_P(X) ({ long double __x = (X); \
165 !isinfl (__x) && !isnanl (__x); })
167 # ifdef _GLIBCPP_HAVE_QFINITE
168 # define FINITEL_P(X) qfinite (X)
170 # define FINITEL_P(X) FINITE_P (X)
176 /* Test whether number is infinite. */
178 /* This is an ISO C 9x macro. */
179 # define INFINITE_P(X) isinf (X)
180 # define INFINITEF_P(X) isinf (X)
181 # define INFINITEL_P(X) isinf (X)
184 /* This is for Solaris, which does not have special macros for other
186 # define INFINITE_P(X) IsINF (X)
187 # define INFINITEF_P(X) IsINF (X)
188 # define INFINITEL_P(X) IsINF (X)
190 # if defined _GLIBCPP_HAVE_ISINF
191 # define INFINITE_P(X) isinf (X)
193 # ifdef _GLIBCPP_HAVE_FPCLASS
194 # ifdef _FPCLASS_PINF
195 /* Mingw defines _FPCLASS_PINF. */
196 # define FP_PINF _FPCLASS_PINF
198 /* This is for Irix and Mingw. */
199 # define INFINITE_P(X) (fpclass (fabs (X)) == FP_PINF)
202 /* This is for AIX. */
203 # define INFINITE_P(X) ({ double __d = (X); IS_INF (__d); })
205 # error "We need INFINITE_P"
209 # if defined _GLIBCPP_HAVE_ISINFF
210 # define INFINITEF_P(X) isinff (X)
212 # define INFINITEF_P(X) INFINITE_P (X)
214 # if defined _GLIBCPP_HAVE_ISINFL
215 # define INFINITEL_P(X) isinfl (X)
217 # ifdef _GLIBCPP_HAVE_QFPCLASS
218 # define INFINITEL_P(X) (qfpclass (fabsl (X)) == FP_PINF)
220 # define INFINITEL_P(X) INFINITE_P (X)
230 #ifdef _GLIBCPP_HAVE_COMPLEX_H
231 # include <complex.h>
233 # include "complex-stub.h"
235 __complex__
double c_log (__complex__
double x
);
236 __complex__
float c_logf (__complex__
float x
);
237 __complex__
long double c_logl (__complex__
long double x
);
239 /* signbit is a macro in ISO C 9x. */
241 extern int __signbitf (float);
242 extern int __signbit (double);
243 extern int __signbitl (long double);
245 # define signbit(x) \
246 (sizeof (x) == sizeof (float) ? \
248 : sizeof (x) == sizeof (double) ? \
249 __signbit (x) : __signbitl (x))
252 #if BYTE_ORDER == BIG_ENDIAN
261 } ieee_double_shape_type
;
263 #if BYTE_ORDER == LITTLE_ENDIAN
272 } ieee_double_shape_type
;
274 /* Get the more significant 32 bit int from a double. */
275 #define GET_HIGH_WORD(i,d) \
277 ieee_double_shape_type gh_u; \
279 (i) = gh_u.parts.msw; \
287 } ieee_float_shape_type
;
288 /* Get a 32 bit int from a float. */
289 #define GET_FLOAT_WORD(i,d) \
291 ieee_float_shape_type gf_u; \
297 #if BYTE_ORDER == BIG_ENDIAN
303 unsigned int sign_exponent
:16;
304 unsigned int empty
:16;
308 } ieee_long_double_shape_type
;
310 #if BYTE_ORDER == LITTLE_ENDIAN
318 unsigned int sign_exponent
:16;
319 unsigned int empty
:16;
321 } ieee_long_double_shape_type
;
323 /* Get int from the exponent of a long double. */
324 #define GET_LDOUBLE_EXP(exp,d) \
326 ieee_long_double_shape_type ge_u; \
328 (exp) = ge_u.parts.sign_exponent; \
331 #if BYTE_ORDER == BIG_ENDIAN
342 U_int32_t w0
, w1
, w2
, w3
;
344 } ieee_quad_double_shape_type
;
346 #if BYTE_ORDER == LITTLE_ENDIAN
357 U_int32_t w3
, w2
, w1
, w0
;
359 } ieee_quad_double_shape_type
;
361 /* Get most significant 64 bit int from a quad long double. */
362 #define GET_LDOUBLE_MSW64(msw,d) \
364 ieee_quad_double_shape_type qw_u; \
366 (ix0) = qw_u.parts64.msw; \
370 /* Replacement for non-existing float functions. */
371 #if !defined(_GLIBCPP_HAVE_FABSF) && !defined(_GLIBCPP_HAVE___BUILTIN_FABSF)
372 # define fabsf(x) fabs (x)
374 #if !defined(_GLIBCPP_HAVE_COSF) && !defined(_GLIBCPP_HAVE___BUILTIN_COSF)
375 # define cosf(x) cos (x)
377 #ifndef _GLIBCPP_HAVE_COSHF
378 # define coshf(x) cosh (x)
380 #ifndef _GLIBCPP_HAVE_EXPF
381 # define expf(x) expf (x)
383 #ifndef _GLIBCPP_HAVE_LOGF
384 # define logf(x) log(x)
386 #ifndef _GLIBCPP_HAVE_LOG10F
387 # define log10f(x) log10 (x)
389 #ifndef _GLIBCPP_HAVE_POWF
390 # define powf(x, y) pow (x, y)
392 #if !defined(_GLIBCPP_HAVE_SINF) && !defined(_GLIBCPP_HAVE___BUILTIN_SINF)
393 # define sinf(x) sin (x)
395 #ifndef _GLIBCPP_HAVE_SINHF
396 # define sinhf(x) sinh (x)
398 #if !defined(_GLIBCPP_HAVE_SQRTF) && !defined(_GLIBCPP_HAVE___BUILTIN_SQRTF)
399 # define sqrtf(x) sqrt (x)
401 #ifndef _GLIBCPP_HAVE_TANF
402 # define tanf(x) tan (x)
404 #ifndef _GLIBCPP_HAVE_TANHF
405 # define tanhf(x) tanh (x)
407 #ifndef _GLIBCPP_HAVE_STRTOF
408 # define strtof(s, e) strtod (s, e)