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 /* A union which permits us to convert between a float and a 32 bit
163 } ieee_float_shape_type
;
165 /* Get a 32 bit int from a float. */
166 #ifndef GET_FLOAT_WORD
167 # define GET_FLOAT_WORD(i,d) \
169 ieee_float_shape_type gf_u; \
175 /* Set a float from a 32 bit int. */
176 #ifndef SET_FLOAT_WORD
177 # define SET_FLOAT_WORD(d,i) \
179 ieee_float_shape_type sf_u; \
185 /* We need to guarantee an expansion of name when building
186 ldbl-128 files as another type (e.g _Float128). */
187 #define mathx_hidden_def(name) hidden_def(name)
189 /* Get long double macros from a separate header. */
190 #include <math_ldbl.h>
192 /* Include function declarations for each floating-point. */
193 #define _Mdouble_ double
195 #include <math_private_calls.h>
199 #define _Mdouble_ float
201 #define __MATH_DECLARING_FLOAT
202 #include <math_private_calls.h>
203 #undef __MATH_DECLARING_FLOAT
207 #define _Mdouble_ long double
209 #define __MATH_DECLARING_LONG_DOUBLE
210 #include <math_private_calls.h>
211 #undef __MATH_DECLARING_LONG_DOUBLE
215 #if __HAVE_DISTINCT_FLOAT128
216 # define _Mdouble_ _Float128
218 # define __MATH_DECLARING_FLOATN
219 # include <math_private_calls.h>
220 # undef __MATH_DECLARING_FLOATN
227 /* Prototypes for functions of the IBM Accurate Mathematical Library. */
228 extern double __sin (double __x
);
229 extern double __cos (double __x
);
230 extern int __branred (double __x
, double *__a
, double *__aa
);
231 extern void __doasin (double __x
, double __dx
, double __v
[]);
232 extern void __dubsin (double __x
, double __dx
, double __v
[]);
233 extern void __dubcos (double __x
, double __dx
, double __v
[]);
234 extern double __sin32 (double __x
, double __res
, double __res1
);
235 extern double __cos32 (double __x
, double __res
, double __res1
);
236 extern double __mpsin (double __x
, double __dx
, bool __range_reduce
);
237 extern double __mpcos (double __x
, double __dx
, bool __range_reduce
);
238 extern void __docos (double __x
, double __dx
, double __v
[]);
240 #endif /* _MATH_PRIVATE_H_ */