* sparc/sol2.h (CPLUSPLUS_CPP_SPEC): Add all of CPP_SPEC instead
[official-gcc.git] / libstdc++-v3 / libmath / mathconf.h
bloba730770a256581cc38c9f56b017bdc7dc17224d9
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)
9 any later version.
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,
19 USA.
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
34 # include <endian.h>
35 #else
36 # ifdef _GLIBCPP_HAVE_MACHINE_ENDIAN_H
37 # include <machine/endian.h>
38 # else
39 # ifdef _GLIBCPP_HAVE_SYS_MACHINE_H
40 # include <sys/machine.h>
41 # else
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>
46 # endif
47 # ifdef _GLIBCPP_HAVE_MACHINE_PARAM_H
48 # include <machine/param.h>
49 # endif
50 # ifdef _LITTLE_ENDIAN
51 # define LITTLE_ENDIAN 1
52 # endif
53 # ifdef _BIG_ENDIAN
54 # define BIG_ENDIAN 1
55 # endif
56 # define BYTE_ORDER 1
57 # else
58 /* We have to rely on the AC_C_BIGENDIAN test. */
59 # ifdef WORDS_BIGENDIAN
60 # define BIG_ENDIAN 1
61 # else
62 # define LITTLE_ENDIAN 1
63 # endif
64 # define BYTE_ORDER 1
65 # endif
66 # endif
67 # endif
68 #endif
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 Int64_t __attribute ((mode (DI)));
75 #ifdef _GLIBCPP_HAVE_NAN_H
76 # include <nan.h>
77 #endif
79 #ifndef NAN
80 # define NAN (nan())
81 double nan (void);
82 #endif
84 #ifdef _GLIBCPP_HAVE_IEEEFP_H
85 # include <ieeefp.h>
86 #endif
88 #ifdef _GLIBCPP_HAVE_FP_H
89 # include <fp.h>
90 #endif
92 #ifdef _GLIBCPP_HAVE_FLOAT_H
93 # include <float.h>
94 #endif
96 /* `float' variant of HUGE_VAL. */
97 #ifndef HUGE_VALF
98 # ifdef HUGE_VALf
99 # define HUGE_VALF HUGE_VALf
100 # else
101 # define HUGE_VALF HUGE_VAL
102 # endif
103 #endif
105 /* `long double' variant of HUGE_VAL. */
106 #ifndef HUGE_VALL
107 # ifdef HUGE_VALl
108 # define HUGE_VALL HUGE_VALl
109 # else
110 # define HUGE_VALL HUGE_VAL
111 # endif
112 #endif
114 /* Make sure that at least HUGE_VAL is defined. */
115 #ifndef HUGE_VAL
116 # ifdef HUGE
117 # define HUGE_VAL HUGE
118 # else
119 # ifdef MAXFLOAT
120 # define HUGE_VAL MAXFLOAT
121 # else
122 # error "We need HUGE_VAL!"
123 # endif
124 # endif
125 #endif
127 #ifndef M_PI
128 # define M_PI 3.14159265358979323846
129 #endif
132 #ifdef __cplusplus
133 extern "C" {
134 #endif
136 /* signbit is a macro in ISO C99. */
137 #ifndef signbit
138 extern int __signbitf (float);
139 extern int __signbit (double);
140 extern int __signbitl (long double);
142 # define signbit(x) \
143 (sizeof (x) == sizeof (float) ? \
144 __signbitf (x) \
145 : sizeof (x) == sizeof (double) ? \
146 __signbit (x) : __signbitl (x))
147 #endif
149 #if BYTE_ORDER == BIG_ENDIAN
150 typedef union
152 double value;
153 struct
155 U_int32_t msw;
156 U_int32_t lsw;
157 } parts;
158 } ieee_double_shape_type;
159 #endif
160 #if BYTE_ORDER == LITTLE_ENDIAN
161 typedef union
163 double value;
164 struct
166 U_int32_t lsw;
167 U_int32_t msw;
168 } parts;
169 } ieee_double_shape_type;
170 #endif
171 /* Get the more significant 32 bit int from a double. */
172 #define GET_HIGH_WORD(i,d) \
173 do { \
174 ieee_double_shape_type gh_u; \
175 gh_u.value = (d); \
176 (i) = gh_u.parts.msw; \
177 } while (0)
180 typedef union
182 float value;
183 U_int32_t word;
184 } ieee_float_shape_type;
185 /* Get a 32 bit int from a float. */
186 #define GET_FLOAT_WORD(i,d) \
187 do { \
188 ieee_float_shape_type gf_u; \
189 gf_u.value = (d); \
190 (i) = gf_u.word; \
191 } while (0)
194 #if BYTE_ORDER == BIG_ENDIAN
195 typedef union
197 long double value;
198 struct
200 unsigned int sign_exponent:16;
201 unsigned int empty:16;
202 U_int32_t msw;
203 U_int32_t lsw;
204 } parts;
205 } ieee_long_double_shape_type;
206 #endif
207 #if BYTE_ORDER == LITTLE_ENDIAN
208 typedef union
210 long double value;
211 struct
213 U_int32_t lsw;
214 U_int32_t msw;
215 unsigned int sign_exponent:16;
216 unsigned int empty:16;
217 } parts;
218 } ieee_long_double_shape_type;
219 #endif
220 /* Get int from the exponent of a long double. */
221 #define GET_LDOUBLE_EXP(exp,d) \
222 do { \
223 ieee_long_double_shape_type ge_u; \
224 ge_u.value = (d); \
225 (exp) = ge_u.parts.sign_exponent; \
226 } while (0)
228 #if BYTE_ORDER == BIG_ENDIAN
229 typedef union
231 long double value;
232 struct
234 U_int64_t msw;
235 U_int64_t lsw;
236 } parts64;
237 struct
239 U_int32_t w0, w1, w2, w3;
240 } parts32;
241 } ieee_quad_double_shape_type;
242 #endif
243 #if BYTE_ORDER == LITTLE_ENDIAN
244 typedef union
246 long double value;
247 struct
249 U_int64_t lsw;
250 U_int64_t msw;
251 } parts64;
252 struct
254 U_int32_t w3, w2, w1, w0;
255 } parts32;
256 } ieee_quad_double_shape_type;
257 #endif
258 /* Get most significant 64 bit int from a quad long double. */
259 #define GET_LDOUBLE_MSW64(msw,d) \
260 do { \
261 ieee_quad_double_shape_type qw_u; \
262 qw_u.value = (d); \
263 (msw) = qw_u.parts64.msw; \
264 } while (0)
267 /* Replacement for non-existing float functions. */
268 #if !defined(_GLIBCPP_HAVE_FABSF) && !defined(_GLIBCPP_HAVE___BUILTIN_FABSF)
269 # define fabsf(x) fabs (x)
270 #endif
271 #if !defined(_GLIBCPP_HAVE_COSF) && !defined(_GLIBCPP_HAVE___BUILTIN_COSF)
272 # define cosf(x) cos (x)
273 #endif
274 #ifndef _GLIBCPP_HAVE_COSHF
275 # define coshf(x) cosh (x)
276 #endif
277 #ifndef _GLIBCPP_HAVE_EXPF
278 # define expf(x) expf (x)
279 #endif
280 #ifndef _GLIBCPP_HAVE_LOGF
281 # define logf(x) log(x)
282 #endif
283 #ifndef _GLIBCPP_HAVE_LOG10F
284 # define log10f(x) log10 (x)
285 #endif
286 #ifndef _GLIBCPP_HAVE_POWF
287 # define powf(x, y) pow (x, y)
288 #endif
289 #if !defined(_GLIBCPP_HAVE_SINF) && !defined(_GLIBCPP_HAVE___BUILTIN_SINF)
290 # define sinf(x) sin (x)
291 #endif
292 #ifndef _GLIBCPP_HAVE_SINHF
293 # define sinhf(x) sinh (x)
294 #endif
295 #if !defined(_GLIBCPP_HAVE_SQRTF) && !defined(_GLIBCPP_HAVE___BUILTIN_SQRTF)
296 # define sqrtf(x) sqrt (x)
297 #endif
298 #ifndef _GLIBCPP_HAVE_TANF
299 # define tanf(x) tan (x)
300 #endif
301 #ifndef _GLIBCPP_HAVE_TANHF
302 # define tanhf(x) tanh (x)
303 #endif
304 #ifndef _GLIBCPP_HAVE_STRTOF
305 # define strtof(s, e) strtod (s, e)
306 #endif
308 #ifdef __cplusplus
310 #endif