2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 * Developed at SunPro, a Sun Microsystems, Inc. business.
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
9 * ====================================================
13 * from: @(#)fdlibm.h 5.1 93/09/24
16 #ifndef _MATH_PRIVATE_H_
17 #define _MATH_PRIVATE_H_
22 #include <sys/types.h>
24 /* Gather machine dependent _Floatn support. */
25 #include <bits/floatn.h>
27 /* The original fdlibm code used statements like:
28 n0 = ((*(int*)&one)>>29)^1; * index of high word *
29 ix0 = *(n0+(int*)&x); * high word of x *
30 ix1 = *((1-n0)+(int*)&x); * low word of x *
31 to dig two 32 bit words out of the 64 bit IEEE floating point
32 value. That is non-ANSI, and, moreover, the gcc instruction
33 scheduler gets it wrong. We instead use the following macros.
34 Unlike the original code, we determine the endianness at compile
35 time, not at run time; I don't see much benefit to selecting
36 endianness at run time. */
38 /* A union which permits us to convert between a double and two 32 bit
41 #if __FLOAT_WORD_ORDER == __BIG_ENDIAN
52 } ieee_double_shape_type
;
56 #if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
67 } ieee_double_shape_type
;
71 /* Get two 32 bit ints from a double. */
73 #define EXTRACT_WORDS(ix0,ix1,d) \
75 ieee_double_shape_type ew_u; \
77 (ix0) = ew_u.parts.msw; \
78 (ix1) = ew_u.parts.lsw; \
81 /* Get the more significant 32 bit int from a double. */
84 # define GET_HIGH_WORD(i,d) \
86 ieee_double_shape_type gh_u; \
88 (i) = gh_u.parts.msw; \
92 /* Get the less significant 32 bit int from a double. */
95 # define GET_LOW_WORD(i,d) \
97 ieee_double_shape_type gl_u; \
99 (i) = gl_u.parts.lsw; \
103 /* Get all in one, efficient on 64-bit machines. */
104 #ifndef EXTRACT_WORDS64
105 # define EXTRACT_WORDS64(i,d) \
107 ieee_double_shape_type gh_u; \
113 /* Set a double from two 32 bit ints. */
115 # define INSERT_WORDS(d,ix0,ix1) \
117 ieee_double_shape_type iw_u; \
118 iw_u.parts.msw = (ix0); \
119 iw_u.parts.lsw = (ix1); \
124 /* Get all in one, efficient on 64-bit machines. */
125 #ifndef INSERT_WORDS64
126 # define INSERT_WORDS64(d,i) \
128 ieee_double_shape_type iw_u; \
134 /* Set the more significant 32 bits of a double from an int. */
135 #ifndef SET_HIGH_WORD
136 #define SET_HIGH_WORD(d,v) \
138 ieee_double_shape_type sh_u; \
140 sh_u.parts.msw = (v); \
145 /* Set the less significant 32 bits of a double from an int. */
147 # define SET_LOW_WORD(d,v) \
149 ieee_double_shape_type sl_u; \
151 sl_u.parts.lsw = (v); \
156 /* We need to guarantee an expansion of name when building
157 ldbl-128 files as another type (e.g _Float128). */
158 #define mathx_hidden_def(name) hidden_def(name)
160 /* Get long double macros from a separate header. */
161 #include <math_ldbl.h>
163 /* Include function declarations for each floating-point. */
164 #define _Mdouble_ double
166 #include <math_private_calls.h>
170 #define _Mdouble_ float
172 #define __MATH_DECLARING_FLOAT
173 #include <math_private_calls.h>
174 #undef __MATH_DECLARING_FLOAT
178 #define _Mdouble_ long double
180 #define __MATH_DECLARING_LONG_DOUBLE
181 #include <math_private_calls.h>
182 #undef __MATH_DECLARING_LONG_DOUBLE
186 #if __HAVE_DISTINCT_FLOAT128
187 # define _Mdouble_ _Float128
189 # define __MATH_DECLARING_FLOATN
190 # include <math_private_calls.h>
191 # undef __MATH_DECLARING_FLOATN
198 /* Prototypes for functions of the IBM Accurate Mathematical Library. */
199 extern double __sin (double __x
);
200 extern double __cos (double __x
);
201 extern int __branred (double __x
, double *__a
, double *__aa
);
203 #endif /* _MATH_PRIVATE_H_ */