Imported GNU Classpath 0.20
[official-gcc.git] / libjava / classpath / native / fdlibm / fdlibm.h
blob13ee449d78e34c05e1b760243122add4fbfefaa3
2 /* @(#)fdlibm.h 5.1 93/09/24 */
3 /*
4 * ====================================================
5 * Copyright (C) 1993, 2000 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
10 * is preserved.
11 * ====================================================
14 #ifndef __CLASSPATH_FDLIBM_H__
15 #define __CLASSPATH_FDLIBM_H__
17 /* AIX needs _XOPEN_SOURCE */
18 #ifdef _AIX
19 #define _XOPEN_SOURCE
20 #endif
22 #include <config.h>
23 #include <stdlib.h>
25 /* GCJ LOCAL: Include files. */
26 #include "ieeefp.h"
27 /* CLASSPATH LOCAL: */
28 #include "namespace.h"
30 #include "mprec.h"
32 /* CYGNUS LOCAL: Default to XOPEN_MODE. */
33 #define _XOPEN_MODE
35 #ifdef __P
36 #undef __P
37 #endif
39 #ifdef __STDC__
40 #define __P(p) p
41 #else
42 #define __P(p) ()
43 #endif
45 #ifndef HUGE
46 #define HUGE ((float)3.40282346638528860e+38)
47 #endif
49 /*
50 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
51 * (one may replace the following line by "#include <values.h>")
54 #define X_TLOSS 1.41484755040568800000e+16
56 /* These typedefs are true for the targets running Java. */
58 #define _IEEE_LIBM
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
65 * ANSI/POSIX
67 extern double acos __P((double));
68 extern double asin __P((double));
69 extern double atan __P((double));
70 extern double atan2 __P((double, double));
71 extern double cos __P((double));
72 extern double sin __P((double));
73 extern double tan __P((double));
75 extern double cosh __P((double));
76 extern double sinh __P((double));
77 extern double tanh __P((double));
79 extern double exp __P((double));
80 extern double frexp __P((double, int *));
81 extern double ldexp __P((double, int));
82 extern double log __P((double));
83 extern double log10 __P((double));
84 extern double modf __P((double, double *));
86 extern double pow __P((double, double));
87 extern double sqrt __P((double));
89 extern double ceil __P((double));
90 extern double fabs __P((double));
91 extern double floor __P((double));
92 extern double fmod __P((double, double));
94 extern double erf __P((double));
95 extern double erfc __P((double));
96 extern double gamma __P((double));
97 extern double hypot __P((double, double));
99 #if !defined(isnan) && !defined(HAVE_ISNAN)
100 #define isnan(x) ((x) != (x))
101 #endif
103 extern int finite __P((double));
104 extern double j0 __P((double));
105 extern double j1 __P((double));
106 extern double jn __P((int, double));
107 extern double lgamma __P((double));
108 extern double y0 __P((double));
109 extern double y1 __P((double));
110 extern double yn __P((int, double));
112 extern double acosh __P((double));
113 extern double asinh __P((double));
114 extern double atanh __P((double));
115 extern double cbrt __P((double));
116 extern double logb __P((double));
117 extern double nextafter __P((double, double));
118 extern double remainder __P((double, double));
120 /* Functions that are not documented, and are not in <math.h>. */
122 extern double logb __P((double));
123 #ifdef _SCALB_INT
124 extern double scalb __P((double, int));
125 #else
126 extern double scalb __P((double, double));
127 #endif
128 extern double significand __P((double));
130 /* ieee style elementary functions */
131 extern double __ieee754_sqrt __P((double));
132 extern double __ieee754_acos __P((double));
133 extern double __ieee754_acosh __P((double));
134 extern double __ieee754_log __P((double));
135 extern double __ieee754_atanh __P((double));
136 extern double __ieee754_asin __P((double));
137 extern double __ieee754_atan2 __P((double,double));
138 extern double __ieee754_exp __P((double));
139 extern double __ieee754_cosh __P((double));
140 extern double __ieee754_fmod __P((double,double));
141 extern double __ieee754_pow __P((double,double));
142 extern double __ieee754_lgamma_r __P((double,int *));
143 extern double __ieee754_gamma_r __P((double,int *));
144 extern double __ieee754_log10 __P((double));
145 extern double __ieee754_sinh __P((double));
146 extern double __ieee754_hypot __P((double,double));
147 extern double __ieee754_j0 __P((double));
148 extern double __ieee754_j1 __P((double));
149 extern double __ieee754_y0 __P((double));
150 extern double __ieee754_y1 __P((double));
151 extern double __ieee754_jn __P((int,double));
152 extern double __ieee754_yn __P((int,double));
153 extern double __ieee754_remainder __P((double,double));
154 extern int32_t __ieee754_rem_pio2 __P((double,double*));
155 #ifdef _SCALB_INT
156 extern double __ieee754_scalb __P((double,int));
157 #else
158 extern double __ieee754_scalb __P((double,double));
159 #endif
161 /* fdlibm kernel function */
162 extern double __kernel_standard __P((double,double,int));
163 extern double __kernel_sin __P((double,double,int));
164 extern double __kernel_cos __P((double,double));
165 extern double __kernel_tan __P((double,double,int));
166 extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int32_t*));
168 /* Undocumented float functions. */
169 extern float logbf __P((float));
170 #ifdef _SCALB_INT
171 extern float scalbf __P((float, int));
172 #else
173 extern float scalbf __P((float, float));
174 #endif
175 extern float significandf __P((float));
178 * Functions callable from C, intended to support IEEE arithmetic.
180 extern double copysign __P((double, double));
181 extern int ilogb __P((double));
182 extern double rint __P((double));
183 extern float rintf __P((float));
184 extern double scalbn __P((double, int));
186 /* ieee style elementary float functions */
187 extern float __ieee754_sqrtf __P((float));
188 extern float __ieee754_acosf __P((float));
189 extern float __ieee754_acoshf __P((float));
190 extern float __ieee754_logf __P((float));
191 extern float __ieee754_atanhf __P((float));
192 extern float __ieee754_asinf __P((float));
193 extern float __ieee754_atan2f __P((float,float));
194 extern float __ieee754_expf __P((float));
195 extern float __ieee754_coshf __P((float));
196 extern float __ieee754_fmodf __P((float,float));
197 extern float __ieee754_powf __P((float,float));
198 extern float __ieee754_lgammaf_r __P((float,int *));
199 extern float __ieee754_gammaf_r __P((float,int *));
200 extern float __ieee754_log10f __P((float));
201 extern float __ieee754_sinhf __P((float));
202 extern float __ieee754_hypotf __P((float,float));
203 extern float __ieee754_j0f __P((float));
204 extern float __ieee754_j1f __P((float));
205 extern float __ieee754_y0f __P((float));
206 extern float __ieee754_y1f __P((float));
207 extern float __ieee754_jnf __P((int,float));
208 extern float __ieee754_ynf __P((int,float));
209 extern float __ieee754_remainderf __P((float,float));
210 extern int32_t __ieee754_rem_pio2f __P((float,float*));
211 #ifdef _SCALB_INT
212 extern float __ieee754_scalbf __P((float,int));
213 #else
214 extern float __ieee754_scalbf __P((float,float));
215 #endif
217 /* float versions of fdlibm kernel functions */
218 extern float __kernel_sinf __P((float,float,int));
219 extern float __kernel_cosf __P((float,float));
220 extern float __kernel_tanf __P((float,float,int));
221 extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const int32_t*));
223 /* The original code used statements like
224 n0 = ((*(int*)&one)>>29)^1; * index of high word *
225 ix0 = *(n0+(int*)&x); * high word of x *
226 ix1 = *((1-n0)+(int*)&x); * low word of x *
227 to dig two 32 bit words out of the 64 bit IEEE floating point
228 value. That is non-ANSI, and, moreover, the gcc instruction
229 scheduler gets it wrong. We instead use the following macros.
230 Unlike the original code, we determine the endianness at compile
231 time, not at run time; I don't see much benefit to selecting
232 endianness at run time. */
234 #ifndef __IEEE_BIG_ENDIAN
235 #ifndef __IEEE_LITTLE_ENDIAN
236 #error Must define endianness
237 #endif
238 #endif
240 /* A union which permits us to convert between a double and two 32 bit
241 ints. */
243 #ifdef __IEEE_BIG_ENDIAN
245 typedef union
247 double value;
248 struct
250 uint32_t msw;
251 uint32_t lsw;
252 } parts;
253 } ieee_double_shape_type;
255 #endif
257 #ifdef __IEEE_LITTLE_ENDIAN
259 typedef union
261 double value;
262 struct
264 uint32_t lsw;
265 uint32_t msw;
266 } parts;
267 } ieee_double_shape_type;
269 #endif
271 /* Get two 32 bit ints from a double. */
273 #define EXTRACT_WORDS(ix0,ix1,d) \
274 do { \
275 ieee_double_shape_type ew_u; \
276 ew_u.value = (d); \
277 (ix0) = ew_u.parts.msw; \
278 (ix1) = ew_u.parts.lsw; \
279 } while (0)
281 /* Get the more significant 32 bit int from a double. */
283 #define GET_HIGH_WORD(i,d) \
284 do { \
285 ieee_double_shape_type gh_u; \
286 gh_u.value = (d); \
287 (i) = gh_u.parts.msw; \
288 } while (0)
290 /* Get the less significant 32 bit int from a double. */
292 #define GET_LOW_WORD(i,d) \
293 do { \
294 ieee_double_shape_type gl_u; \
295 gl_u.value = (d); \
296 (i) = gl_u.parts.lsw; \
297 } while (0)
299 /* Set a double from two 32 bit ints. */
301 #define INSERT_WORDS(d,ix0,ix1) \
302 do { \
303 ieee_double_shape_type iw_u; \
304 iw_u.parts.msw = (ix0); \
305 iw_u.parts.lsw = (ix1); \
306 (d) = iw_u.value; \
307 } while (0)
309 /* Set the more significant 32 bits of a double from an int. */
311 #define SET_HIGH_WORD(d,v) \
312 do { \
313 ieee_double_shape_type sh_u; \
314 sh_u.value = (d); \
315 sh_u.parts.msw = (v); \
316 (d) = sh_u.value; \
317 } while (0)
319 /* Set the less significant 32 bits of a double from an int. */
321 #define SET_LOW_WORD(d,v) \
322 do { \
323 ieee_double_shape_type sl_u; \
324 sl_u.value = (d); \
325 sl_u.parts.lsw = (v); \
326 (d) = sl_u.value; \
327 } while (0)
329 /* A union which permits us to convert between a float and a 32 bit
330 int. */
332 typedef union
334 float value;
335 uint32_t word;
336 } ieee_float_shape_type;
338 /* Get a 32 bit int from a float. */
340 #define GET_FLOAT_WORD(i,d) \
341 do { \
342 ieee_float_shape_type gf_u; \
343 gf_u.value = (d); \
344 (i) = gf_u.word; \
345 } while (0)
347 /* Set a float from a 32 bit int. */
349 #define SET_FLOAT_WORD(d,i) \
350 do { \
351 ieee_float_shape_type sf_u; \
352 sf_u.word = (i); \
353 (d) = sf_u.value; \
354 } while (0)
356 #ifdef __cplusplus
358 #endif
360 #endif /* __CLASSPATH_FDLIBM_H__ */