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
14 * $Id: math_private.h,v 1.3 2004/02/09 07:10:38 andersen Exp $
17 #ifndef _MATH_PRIVATE_H_
18 #define _MATH_PRIVATE_H_
21 #include <sys/types.h>
23 /* The original fdlibm code used statements like:
24 n0 = ((*(int*)&one)>>29)^1; * index of high word *
25 ix0 = *(n0+(int*)&x); * high word of x *
26 ix1 = *((1-n0)+(int*)&x); * low word of x *
27 to dig two 32 bit words out of the 64 bit IEEE floating point
28 value. That is non-ANSI, and, moreover, the gcc instruction
29 scheduler gets it wrong. We instead use the following macros.
30 Unlike the original code, we determine the endianness at compile
31 time, not at run time; I don't see much benefit to selecting
32 endianness at run time. */
34 /* A union which permits us to convert between a double and two 32 bit
38 * Math on arm is special (read: stupid):
39 * For FPA, float words are always big-endian.
40 * For VFP, float words follow the memory system mode.
41 * For Maverick, float words are always little-endian.
44 #if !defined(__MAVERICK__) && ((__BYTE_ORDER == __BIG_ENDIAN) || \
45 (!defined(__VFP_FP__) && (defined(__arm__) || defined(__thumb__))))
55 } ieee_double_shape_type;
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. */
83 #define GET_HIGH_WORD(i,d) \
85 ieee_double_shape_type gh_u; \
87 (i) = gh_u.parts.msw; \
90 /* Get the less significant 32 bit int from a double. */
92 #define GET_LOW_WORD(i,d) \
94 ieee_double_shape_type gl_u; \
96 (i) = gl_u.parts.lsw; \
99 /* Set a double from two 32 bit ints. */
101 #define INSERT_WORDS(d,ix0,ix1) \
103 ieee_double_shape_type iw_u; \
104 iw_u.parts.msw = (ix0); \
105 iw_u.parts.lsw = (ix1); \
109 /* Set the more significant 32 bits of a double from an int. */
111 #define SET_HIGH_WORD(d,v) \
113 ieee_double_shape_type sh_u; \
115 sh_u.parts.msw = (v); \
119 /* Set the less significant 32 bits of a double from an int. */
121 #define SET_LOW_WORD(d,v) \
123 ieee_double_shape_type sl_u; \
125 sl_u.parts.lsw = (v); \
129 /* A union which permits us to convert between a float and a 32 bit
136 } ieee_float_shape_type;
138 /* Get a 32 bit int from a float. */
140 #define GET_FLOAT_WORD(i,d) \
142 ieee_float_shape_type gf_u; \
147 /* Set a float from a 32 bit int. */
149 #define SET_FLOAT_WORD(d,i) \
151 ieee_float_shape_type sf_u; \
156 /* ieee style elementary functions */
157 extern double __ieee754_sqrt (double) attribute_hidden;
158 extern double __ieee754_acos (double) attribute_hidden;
159 extern double __ieee754_acosh (double) attribute_hidden;
160 extern double __ieee754_log (double) attribute_hidden;
161 extern double __ieee754_log2 (double) attribute_hidden;
162 extern double __ieee754_atanh (double) attribute_hidden;
163 extern double __ieee754_asin (double) attribute_hidden;
164 extern double __ieee754_atan2 (double,double) attribute_hidden;
165 extern double __ieee754_exp (double) attribute_hidden;
166 extern double __ieee754_cosh (double) attribute_hidden;
167 extern double __ieee754_fmod (double,double) attribute_hidden;
168 extern double __ieee754_pow (double,double) attribute_hidden;
169 extern double __ieee754_lgamma_r (double,int *) attribute_hidden;
170 extern double __ieee754_gamma_r (double,int *) attribute_hidden;
171 extern double __ieee754_lgamma (double) attribute_hidden;
172 extern double __ieee754_gamma (double) attribute_hidden;
173 extern double __ieee754_log10 (double) attribute_hidden;
174 extern double __ieee754_sinh (double) attribute_hidden;
175 extern double __ieee754_hypot (double,double) attribute_hidden;
176 extern double __ieee754_j0 (double) attribute_hidden;
177 extern double __ieee754_j1 (double) attribute_hidden;
178 extern double __ieee754_y0 (double) attribute_hidden;
179 extern double __ieee754_y1 (double) attribute_hidden;
180 extern double __ieee754_jn (int,double) attribute_hidden;
181 extern double __ieee754_yn (int,double) attribute_hidden;
182 extern double __ieee754_remainder (double,double) attribute_hidden;
183 extern int __ieee754_rem_pio2 (double,double*) attribute_hidden;
184 #if defined(_SCALB_INT)
185 extern double __ieee754_scalb (double,int) attribute_hidden;
187 extern double __ieee754_scalb (double,double) attribute_hidden;
190 /* fdlibm kernel function */
192 extern double __kernel_standard (double,double,int) attribute_hidden;
194 extern double __kernel_sin (double,double,int) attribute_hidden;
195 extern double __kernel_cos (double,double) attribute_hidden;
196 extern double __kernel_tan (double,double,int) attribute_hidden;
197 extern int __kernel_rem_pio2 (double*,double*,int,int,int,const int*) attribute_hidden;
199 #endif /* _MATH_PRIVATE_H_ */