2 /* @(#)fdlibm.h 5.1 93/09/24 */
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
11 * ====================================================
14 #ifndef __CLASSPATH_FDLIBM_H__
15 #define __CLASSPATH_FDLIBM_H__
17 /* AIX needs _XOPEN_SOURCE */
25 /* GCJ LOCAL: Include files. */
30 /* CYGNUS LOCAL: Default to XOPEN_MODE. */
44 #define HUGE ((float)3.40282346638528860e+38)
48 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
49 * (one may replace the following line by "#include <values.h>")
52 #define X_TLOSS 1.41484755040568800000e+16
54 /* These typedefs are true for the targets running Java. */
65 #if !defined(isnan) && !defined(HAVE_ISNAN)
66 #define isnan(x) ((x) != (x))
69 /* ieee style elementary functions */
70 extern double __ieee754_fmod __P((double,double));
73 * Functions callable from C, intended to support IEEE arithmetic.
75 extern double copysign __P((double, double));
77 /* The original code used statements like
78 n0 = ((*(int*)&one)>>29)^1; * index of high word *
79 ix0 = *(n0+(int*)&x); * high word of x *
80 ix1 = *((1-n0)+(int*)&x); * low word of x *
81 to dig two 32 bit words out of the 64 bit IEEE floating point
82 value. That is non-ANSI, and, moreover, the gcc instruction
83 scheduler gets it wrong. We instead use the following macros.
84 Unlike the original code, we determine the endianness at compile
85 time, not at run time; I don't see much benefit to selecting
86 endianness at run time. */
88 #ifndef __IEEE_BIG_ENDIAN
89 #ifndef __IEEE_LITTLE_ENDIAN
90 #error Must define endianness
94 /* A union which permits us to convert between a double and two 32 bit
97 #ifdef __IEEE_BIG_ENDIAN
107 } ieee_double_shape_type;
111 #ifdef __IEEE_LITTLE_ENDIAN
121 } ieee_double_shape_type;
125 /* Get two 32 bit ints from a double. */
127 #define EXTRACT_WORDS(ix0,ix1,d) \
129 ieee_double_shape_type ew_u; \
131 (ix0) = ew_u.parts.msw; \
132 (ix1) = ew_u.parts.lsw; \
135 /* Get the more significant 32 bit int from a double. */
137 #define GET_HIGH_WORD(i,d) \
139 ieee_double_shape_type gh_u; \
141 (i) = gh_u.parts.msw; \
144 /* Get the less significant 32 bit int from a double. */
146 #define GET_LOW_WORD(i,d) \
148 ieee_double_shape_type gl_u; \
150 (i) = gl_u.parts.lsw; \
153 /* Set a double from two 32 bit ints. */
155 #define INSERT_WORDS(d,ix0,ix1) \
157 ieee_double_shape_type iw_u; \
158 iw_u.parts.msw = (ix0); \
159 iw_u.parts.lsw = (ix1); \
163 /* Set the more significant 32 bits of a double from an int. */
165 #define SET_HIGH_WORD(d,v) \
167 ieee_double_shape_type sh_u; \
169 sh_u.parts.msw = (v); \
173 /* Set the less significant 32 bits of a double from an int. */
175 #define SET_LOW_WORD(d,v) \
177 ieee_double_shape_type sl_u; \
179 sl_u.parts.lsw = (v); \
183 /* A union which permits us to convert between a float and a 32 bit
190 } ieee_float_shape_type;
192 /* Get a 32 bit int from a float. */
194 #define GET_FLOAT_WORD(i,d) \
196 ieee_float_shape_type gf_u; \
201 /* Set a float from a 32 bit int. */
203 #define SET_FLOAT_WORD(d,i) \
205 ieee_float_shape_type sf_u; \
214 #endif /* __CLASSPATH_FDLIBM_H__ */