Don't try to setup and use X11 shared memory if
[tangerine.git] / compiler / clib / __math.h
blob7f15ec00a2074770b90c255db09b3da7cec35f33
1 /*
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
8 * is preserved.
9 * ====================================================
13 * from: @(#)fdlibm.h 5.1 93/09/24
14 * from: $FreeBSD: src/lib/msun/src/math_private.h,v 1.6 1999/08/28 00:06:43 peter Exp $
15 * $Id$
18 #ifndef _MATH_PRIVATE_H_
19 #define _MATH_PRIVATE_H_
21 #include <aros/system.h>
22 #include <stdint.h>
24 /* The original fdlibm code used statements like:
25 n0 = ((*(int*)&one)>>29)^1; * index of high word *
26 ix0 = *(n0+(int*)&x); * high word of x *
27 ix1 = *((1-n0)+(int*)&x); * low word of x *
28 to dig two 32 bit words out of the 64 bit IEEE floating point
29 value. That is non-ANSI, and, moreover, the gcc instruction
30 scheduler gets it wrong. We instead use the following macros.
31 Unlike the original code, we determine the endianness at compile
32 time, not at run time; I don't see much benefit to selecting
33 endianness at run time. */
35 /* A union which permits us to convert between a double and two 32 bit
36 ints. */
38 #if AROS_BIG_ENDIAN == 1
40 typedef union
42 double value;
43 struct
45 uint32_t msw;
46 uint32_t lsw;
47 } parts;
48 } ieee_double_shape_type;
50 #endif
52 #if AROS_BIG_ENDIAN == 0
54 typedef union
56 double value;
57 struct
59 uint32_t lsw;
60 uint32_t msw;
61 } parts;
62 } ieee_double_shape_type;
64 #endif
66 /* Get two 32 bit ints from a double. */
68 #define EXTRACT_WORDS(ix0,ix1,d) \
69 do { \
70 ieee_double_shape_type ew_u; \
71 ew_u.value = (d); \
72 (ix0) = ew_u.parts.msw; \
73 (ix1) = ew_u.parts.lsw; \
74 } while (0)
76 /* Get the more significant 32 bit int from a double. */
78 #define GET_HIGH_WORD(i,d) \
79 do { \
80 ieee_double_shape_type gh_u; \
81 gh_u.value = (d); \
82 (i) = gh_u.parts.msw; \
83 } while (0)
85 /* Get the less significant 32 bit int from a double. */
87 #define GET_LOW_WORD(i,d) \
88 do { \
89 ieee_double_shape_type gl_u; \
90 gl_u.value = (d); \
91 (i) = gl_u.parts.lsw; \
92 } while (0)
94 /* Set a double from two 32 bit ints. */
96 #define INSERT_WORDS(d,ix0,ix1) \
97 do { \
98 ieee_double_shape_type iw_u; \
99 iw_u.parts.msw = (ix0); \
100 iw_u.parts.lsw = (ix1); \
101 (d) = iw_u.value; \
102 } while (0)
104 /* Set the more significant 32 bits of a double from an int. */
106 #define SET_HIGH_WORD(d,v) \
107 do { \
108 ieee_double_shape_type sh_u; \
109 sh_u.value = (d); \
110 sh_u.parts.msw = (v); \
111 (d) = sh_u.value; \
112 } while (0)
114 /* Set the less significant 32 bits of a double from an int. */
116 #define SET_LOW_WORD(d,v) \
117 do { \
118 ieee_double_shape_type sl_u; \
119 sl_u.value = (d); \
120 sl_u.parts.lsw = (v); \
121 (d) = sl_u.value; \
122 } while (0)
124 /* A union which permits us to convert between a float and a 32 bit
125 int. */
127 typedef union
129 float value;
130 uint32_t word;
131 } ieee_float_shape_type;
133 /* Get a 32 bit int from a float. */
135 #define GET_FLOAT_WORD(i,d) \
136 do { \
137 ieee_float_shape_type gf_u; \
138 gf_u.value = (d); \
139 (i) = gf_u.word; \
140 } while (0)
142 /* Set a float from a 32 bit int. */
144 #define SET_FLOAT_WORD(d,i) \
145 do { \
146 ieee_float_shape_type sf_u; \
147 sf_u.word = (i); \
148 (d) = sf_u.value; \
149 } while (0)
151 /* ieee style elementary functions */
152 extern double __ieee754_sqrt (double);
153 extern double __ieee754_acos (double);
154 extern double __ieee754_acosh (double);
155 extern double __ieee754_log (double);
156 extern double __ieee754_atanh (double);
157 extern double __ieee754_asin (double);
158 extern double __ieee754_atan2 (double,double);
159 extern double __ieee754_exp (double);
160 extern double __ieee754_cosh (double);
161 extern double __ieee754_fmod (double,double);
162 extern double __ieee754_pow (double,double);
163 extern double __ieee754_lgamma_r (double,int *);
164 extern double __ieee754_gamma_r (double,int *);
165 extern double __ieee754_lgamma (double);
166 extern double __ieee754_gamma (double);
167 extern double __ieee754_log10 (double);
168 extern double __ieee754_sinh (double);
169 extern double __ieee754_hypot (double,double);
170 extern double __ieee754_j0 (double);
171 extern double __ieee754_j1 (double);
172 extern double __ieee754_y0 (double);
173 extern double __ieee754_y1 (double);
174 extern double __ieee754_jn (int,double);
175 extern double __ieee754_yn (int,double);
176 extern double __ieee754_remainder (double,double);
177 extern int32_t __ieee754_rem_pio2 (double,double*);
178 extern double __ieee754_scalb (double,double);
180 /* fdlibm kernel function */
181 extern double __kernel_standard (double,double,int);
182 extern double __kernel_sin (double,double,int);
183 extern double __kernel_cos (double,double);
184 extern double __kernel_tan (double,double,int);
185 extern int __kernel_rem_pio2 (double*,double*,int,int,int,const int32_t*);
188 /* ieee style elementary float functions */
189 extern float __ieee754_sqrtf (float);
190 extern float __ieee754_acosf (float);
191 extern float __ieee754_acoshf (float);
192 extern float __ieee754_logf (float);
193 extern float __ieee754_atanhf (float);
194 extern float __ieee754_asinf (float);
195 extern float __ieee754_atan2f (float,float);
196 extern float __ieee754_expf (float);
197 extern float __ieee754_coshf (float);
198 extern float __ieee754_fmodf (float,float);
199 extern float __ieee754_powf (float,float);
200 extern float __ieee754_lgammaf_r (float,int *);
201 extern float __ieee754_gammaf_r (float,int *);
202 extern float __ieee754_lgammaf (float);
203 extern float __ieee754_gammaf (float);
204 extern float __ieee754_log10f (float);
205 extern float __ieee754_sinhf (float);
206 extern float __ieee754_hypotf (float,float);
207 extern float __ieee754_j0f (float);
208 extern float __ieee754_j1f (float);
209 extern float __ieee754_y0f (float);
210 extern float __ieee754_y1f (float);
211 extern float __ieee754_jnf (int,float);
212 extern float __ieee754_ynf (int,float);
213 extern float __ieee754_remainderf (float,float);
214 extern int32_t __ieee754_rem_pio2f (float,float*);
215 extern float __ieee754_scalbf (float,float);
217 /* float versions of fdlibm kernel functions */
218 extern float __kernel_sinf (float,float,int);
219 extern float __kernel_cosf (float,float);
220 extern float __kernel_tanf (float,float,int);
221 extern int __kernel_rem_pio2f (float*,float*,int,int,int,const int32_t*);
224 This is how to specify which are implemented in assembler,
225 unfortunately we do not do this quite yet.
226 #ifdef __alpha__
228 #define __generic___ieee754_acos __ieee754_acos
229 #define __generic___ieee754_asin __ieee754_asin
230 #define __generic___ieee754_atan2 __ieee754_atan2
231 #define __generic___ieee754_exp __ieee754_exp
232 #define __generic___ieee754_fmod __ieee754_fmod
233 #define __generic___ieee754_log __ieee754_log
234 #define __generic___ieee754_log10 __ieee754_log10
235 #define __generic___ieee754_remainder __ieee754_remainder
236 #define __generic___ieee754_scalb __ieee754_scalb
237 #define __generic___ieee754_sqrt __ieee754_sqrt
238 #define __generic_atan atan
239 #define __generic_ceil ceil
240 #define __generic_copysign copysign
241 #define __generic_cos cos
242 #define __generic_finite finite
243 #define __generic_floor floor
244 #define __generic_ilogb ilogb
245 #define __generic_log1p log1p
246 #define __generic_logb logb
247 #define __generic_rint rint
248 #define __generic_scalbn scalbn
249 #define __generic_significand significand
250 #define __generic_sin sin
251 #define __generic_tan tan
253 #endif
256 #endif /* _MATH_PRIVATE_H_ */