Update contrib.
3 * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies).
8 /* @(#)fdlibm.h 5.1 93/09/24 */
10 * ====================================================
11 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
13 * Developed at SunPro, a Sun Microsystems, Inc. business.
14 * Permission to use, copy, modify, and distribute this
15 * software is freely granted, provided that this notice
17 * ====================================================
33 typedef unsigned long __uint32_t;
34 typedef long __int32_t;
37 /* warning C4056: overflow in floating-point constant arithmetic
38 * Caused by negative floating point constants, it seems!
39 * For example, static double foo = -1.0;
41 #pragma warning( disable: 4056 )
44 /* Warning: #222-D: floating-point operation result is out of range
45 * The compiler detects constant math that overflows, we want overflow though!
47 #pragma diag_suppress 222
54 #define HUGE ((float)3.40282346638528860e+38)
57 set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
58 (one may replace the following line by "#include <values.h>")
61 #define X_TLOSS 1.41484755040568800000e+16
64 ieee style elementary functions - ESTLIB is exporting
65 these functions directly, so we simply map the names across
68 #define __ieee754_cosh cosh
69 #define __ieee754_sinh sinh
70 #define __ieee754_tanh tanh
71 #define __ieee754_exp exp
73 /* The original code used statements like
74 n0 = ((*(int*)&one)>>29)^1; * index of high word *
75 ix0 = *(n0+(int*)&x); * high word of x *
76 ix1 = *((1-n0)+(int*)&x); * low word of x *
77 to dig two 32 bit words out of the 64 bit IEEE floating point
78 value. That is non-ANSI, and, moreover, the gcc instruction
79 scheduler gets it wrong. We instead use the following macros.
80 Unlike the original code, we determine the endianness at compile
81 time, not at run time; I don't see much benefit to selecting
82 endianness at run time. */
84 #ifndef __IEEE_BIG_ENDIAN
85 #ifndef __IEEE_LITTLE_ENDIAN
86 #error Must define endianness
90 /* A union which permits us to convert between a double and two 32 bit
93 #ifdef __IEEE_BIG_ENDIAN
105 } ieee_double_shape_type;
109 #ifdef __IEEE_LITTLE_ENDIAN
121 } ieee_double_shape_type;
127 Get two 32 bit ints from a double.
130 #define EXTRACT_WORDS(ix0,ix1,d) \
132 ieee_double_shape_type ew_u; \
134 (ix0) = ew_u.parts.msw; \
135 (ix1) = ew_u.parts.lsw; \
139 Get the more significant 32 bit int from a double.
142 #define GET_HIGH_WORD(i,d) \
144 ieee_double_shape_type gh_u; \
146 (i) = gh_u.parts.msw; \
150 Get the less significant 32 bit int from a double.
153 #define GET_LOW_WORD(i,d) \
155 ieee_double_shape_type gl_u; \
157 (i) = gl_u.parts.lsw; \
161 Set a double from two 32 bit ints.
164 #define INSERT_WORDS(d,ix0,ix1) \
166 ieee_double_shape_type iw_u; \
167 iw_u.parts.msw = (ix0); \
168 iw_u.parts.lsw = (ix1); \
173 Set the more significant 32 bits of a double from an int.
176 #define SET_HIGH_WORD(d,v) \
178 ieee_double_shape_type sh_u; \
180 sh_u.parts.msw = (v); \
185 Set the less significant 32 bits of a double from an int.
188 #define SET_LOW_WORD(d,v) \
190 ieee_double_shape_type sl_u; \
192 sl_u.parts.lsw = (v); \
197 A union which permits us to convert between a float and a 32 bit
205 } ieee_float_shape_type;
208 Get a 32 bit int from a float.
211 #define GET_FLOAT_WORD(i,d) \
213 ieee_float_shape_type gf_u; \
219 Set a float from a 32 bit int.
222 #define SET_FLOAT_WORD(d,i) \
224 ieee_float_shape_type sf_u; \
230 Test a 32-bit value for being 0.
231 (x==0)? 0: (some value with top bit set to 1)
235 #define CHECK_ZERO(x) ((x)|-(__int32_t)(x))