Work around shortest-stem feature in make 3.82+
[glibc.git] / math / math_private.h
blobe5ca61f0b850ed0d10b7cc56f416af7744515a4c
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
16 #ifndef _MATH_PRIVATE_H_
17 #define _MATH_PRIVATE_H_
19 #include <endian.h>
20 #include <stdint.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
35 ints. */
37 #if __FLOAT_WORD_ORDER == BIG_ENDIAN
39 typedef union
41 double value;
42 struct
44 u_int32_t msw;
45 u_int32_t lsw;
46 } parts;
47 uint64_t word;
48 } ieee_double_shape_type;
50 #endif
52 #if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
54 typedef union
56 double value;
57 struct
59 u_int32_t lsw;
60 u_int32_t msw;
61 } parts;
62 uint64_t word;
63 } ieee_double_shape_type;
65 #endif
67 /* Get two 32 bit ints from a double. */
69 #define EXTRACT_WORDS(ix0,ix1,d) \
70 do { \
71 ieee_double_shape_type ew_u; \
72 ew_u.value = (d); \
73 (ix0) = ew_u.parts.msw; \
74 (ix1) = ew_u.parts.lsw; \
75 } while (0)
77 /* Get the more significant 32 bit int from a double. */
79 #define GET_HIGH_WORD(i,d) \
80 do { \
81 ieee_double_shape_type gh_u; \
82 gh_u.value = (d); \
83 (i) = gh_u.parts.msw; \
84 } while (0)
86 /* Get the less significant 32 bit int from a double. */
88 #define GET_LOW_WORD(i,d) \
89 do { \
90 ieee_double_shape_type gl_u; \
91 gl_u.value = (d); \
92 (i) = gl_u.parts.lsw; \
93 } while (0)
95 /* Get all in one, efficient on 64-bit machines. */
96 #define EXTRACT_WORDS64(i,d) \
97 do { \
98 ieee_double_shape_type gh_u; \
99 gh_u.value = (d); \
100 (i) = gh_u.word; \
101 } while (0)
103 /* Set a double from two 32 bit ints. */
105 #define INSERT_WORDS(d,ix0,ix1) \
106 do { \
107 ieee_double_shape_type iw_u; \
108 iw_u.parts.msw = (ix0); \
109 iw_u.parts.lsw = (ix1); \
110 (d) = iw_u.value; \
111 } while (0)
113 /* Get all in one, efficient on 64-bit machines. */
114 #define INSERT_WORDS64(d,i) \
115 do { \
116 ieee_double_shape_type iw_u; \
117 iw_u.word = (i); \
118 (d) = iw_u.value; \
119 } while (0)
121 /* Set the more significant 32 bits of a double from an int. */
123 #define SET_HIGH_WORD(d,v) \
124 do { \
125 ieee_double_shape_type sh_u; \
126 sh_u.value = (d); \
127 sh_u.parts.msw = (v); \
128 (d) = sh_u.value; \
129 } while (0)
131 /* Set the less significant 32 bits of a double from an int. */
133 #define SET_LOW_WORD(d,v) \
134 do { \
135 ieee_double_shape_type sl_u; \
136 sl_u.value = (d); \
137 sl_u.parts.lsw = (v); \
138 (d) = sl_u.value; \
139 } while (0)
141 /* A union which permits us to convert between a float and a 32 bit
142 int. */
144 typedef union
146 float value;
147 u_int32_t word;
148 } ieee_float_shape_type;
150 /* Get a 32 bit int from a float. */
152 #define GET_FLOAT_WORD(i,d) \
153 do { \
154 ieee_float_shape_type gf_u; \
155 gf_u.value = (d); \
156 (i) = gf_u.word; \
157 } while (0)
159 /* Set a float from a 32 bit int. */
161 #define SET_FLOAT_WORD(d,i) \
162 do { \
163 ieee_float_shape_type sf_u; \
164 sf_u.word = (i); \
165 (d) = sf_u.value; \
166 } while (0)
168 /* Get long double macros from a separate header. */
169 #include <math_ldbl.h>
171 /* ieee style elementary functions */
172 extern double __ieee754_sqrt (double);
173 extern double __ieee754_acos (double);
174 extern double __ieee754_acosh (double);
175 extern double __ieee754_log (double);
176 extern double __ieee754_atanh (double);
177 extern double __ieee754_asin (double);
178 extern double __ieee754_atan2 (double,double);
179 extern double __ieee754_exp (double);
180 extern double __ieee754_exp2 (double);
181 extern double __ieee754_exp10 (double);
182 extern double __ieee754_cosh (double);
183 extern double __ieee754_fmod (double,double);
184 extern double __ieee754_pow (double,double);
185 extern double __ieee754_lgamma_r (double,int *);
186 extern double __ieee754_gamma_r (double,int *);
187 extern double __ieee754_lgamma (double);
188 extern double __ieee754_gamma (double);
189 extern double __ieee754_log10 (double);
190 extern double __ieee754_log2 (double);
191 extern double __ieee754_sinh (double);
192 extern double __ieee754_hypot (double,double);
193 extern double __ieee754_j0 (double);
194 extern double __ieee754_j1 (double);
195 extern double __ieee754_y0 (double);
196 extern double __ieee754_y1 (double);
197 extern double __ieee754_jn (int,double);
198 extern double __ieee754_yn (int,double);
199 extern double __ieee754_remainder (double,double);
200 extern int32_t __ieee754_rem_pio2 (double,double*);
201 extern double __ieee754_scalb (double,double);
203 /* fdlibm kernel function */
204 extern double __kernel_standard (double,double,int);
205 extern double __kernel_sin (double,double,int);
206 extern double __kernel_cos (double,double);
207 extern double __kernel_tan (double,double,int);
208 extern int __kernel_rem_pio2 (double*,double*,int,int,int, const int32_t*);
210 /* internal functions. */
211 extern double __copysign (double x, double __y);
213 #if __GNUC_PREREQ (4, 0)
214 extern inline double __copysign (double x, double y)
215 { return __builtin_copysign (x, y); }
216 #endif
218 /* ieee style elementary float functions */
219 extern float __ieee754_sqrtf (float);
220 extern float __ieee754_acosf (float);
221 extern float __ieee754_acoshf (float);
222 extern float __ieee754_logf (float);
223 extern float __ieee754_atanhf (float);
224 extern float __ieee754_asinf (float);
225 extern float __ieee754_atan2f (float,float);
226 extern float __ieee754_expf (float);
227 extern float __ieee754_exp2f (float);
228 extern float __ieee754_exp10f (float);
229 extern float __ieee754_coshf (float);
230 extern float __ieee754_fmodf (float,float);
231 extern float __ieee754_powf (float,float);
232 extern float __ieee754_lgammaf_r (float,int *);
233 extern float __ieee754_gammaf_r (float,int *);
234 extern float __ieee754_lgammaf (float);
235 extern float __ieee754_gammaf (float);
236 extern float __ieee754_log10f (float);
237 extern float __ieee754_log2f (float);
238 extern float __ieee754_sinhf (float);
239 extern float __ieee754_hypotf (float,float);
240 extern float __ieee754_j0f (float);
241 extern float __ieee754_j1f (float);
242 extern float __ieee754_y0f (float);
243 extern float __ieee754_y1f (float);
244 extern float __ieee754_jnf (int,float);
245 extern float __ieee754_ynf (int,float);
246 extern float __ieee754_remainderf (float,float);
247 extern int32_t __ieee754_rem_pio2f (float,float*);
248 extern float __ieee754_scalbf (float,float);
251 /* float versions of fdlibm kernel functions */
252 extern float __kernel_sinf (float,float,int);
253 extern float __kernel_cosf (float,float);
254 extern float __kernel_tanf (float,float,int);
255 extern int __kernel_rem_pio2f (float*,float*,int,int,int, const int32_t*);
257 /* internal functions. */
258 extern float __copysignf (float x, float __y);
260 #if __GNUC_PREREQ (4, 0)
261 extern inline float __copysignf (float x, float y)
262 { return __builtin_copysignf (x, y); }
263 #endif
265 /* ieee style elementary long double functions */
266 extern long double __ieee754_sqrtl (long double);
267 extern long double __ieee754_acosl (long double);
268 extern long double __ieee754_acoshl (long double);
269 extern long double __ieee754_logl (long double);
270 extern long double __ieee754_atanhl (long double);
271 extern long double __ieee754_asinl (long double);
272 extern long double __ieee754_atan2l (long double,long double);
273 extern long double __ieee754_expl (long double);
274 extern long double __ieee754_exp2l (long double);
275 extern long double __ieee754_exp10l (long double);
276 extern long double __ieee754_coshl (long double);
277 extern long double __ieee754_fmodl (long double,long double);
278 extern long double __ieee754_powl (long double,long double);
279 extern long double __ieee754_lgammal_r (long double,int *);
280 extern long double __ieee754_gammal_r (long double,int *);
281 extern long double __ieee754_lgammal (long double);
282 extern long double __ieee754_gammal (long double);
283 extern long double __ieee754_log10l (long double);
284 extern long double __ieee754_log2l (long double);
285 extern long double __ieee754_sinhl (long double);
286 extern long double __ieee754_hypotl (long double,long double);
287 extern long double __ieee754_j0l (long double);
288 extern long double __ieee754_j1l (long double);
289 extern long double __ieee754_y0l (long double);
290 extern long double __ieee754_y1l (long double);
291 extern long double __ieee754_jnl (int,long double);
292 extern long double __ieee754_ynl (int,long double);
293 extern long double __ieee754_remainderl (long double,long double);
294 extern int __ieee754_rem_pio2l (long double,long double*);
295 extern long double __ieee754_scalbl (long double,long double);
297 /* long double versions of fdlibm kernel functions */
298 extern long double __kernel_sinl (long double,long double,int);
299 extern long double __kernel_cosl (long double,long double);
300 extern long double __kernel_tanl (long double,long double,int);
301 extern void __kernel_sincosl (long double,long double,
302 long double *,long double *, int);
303 extern int __kernel_rem_pio2l (long double*,long double*,int,int,
304 int,const int*);
306 #ifndef NO_LONG_DOUBLE
307 /* prototypes required to compile the ldbl-96 support without warnings */
308 extern int __finitel (long double);
309 extern int __ilogbl (long double);
310 extern int __isinfl (long double);
311 extern int __isnanl (long double);
312 extern long double __atanl (long double);
313 extern long double __copysignl (long double, long double);
314 extern long double __expm1l (long double);
315 extern long double __floorl (long double);
316 extern long double __frexpl (long double, int *);
317 extern long double __ldexpl (long double, int);
318 extern long double __log1pl (long double);
319 extern long double __nanl (const char *);
320 extern long double __rintl (long double);
321 extern long double __scalbnl (long double, int);
322 extern long double __sqrtl (long double x);
323 extern long double fabsl (long double x);
324 extern void __sincosl (long double, long double *, long double *);
325 extern long double __logbl (long double x);
326 extern long double __significandl (long double x);
328 #if __GNUC_PREREQ (4, 0)
329 extern inline long double __copysignl (long double x, long double y)
330 { return __builtin_copysignl (x, y); }
331 #endif
333 #endif
335 /* Prototypes for functions of the IBM Accurate Mathematical Library. */
336 extern double __exp1 (double __x, double __xx, double __error);
337 extern double __sin (double __x);
338 extern double __cos (double __x);
339 extern int __branred (double __x, double *__a, double *__aa);
340 extern void __doasin (double __x, double __dx, double __v[]);
341 extern void __dubsin (double __x, double __dx, double __v[]);
342 extern void __dubcos (double __x, double __dx, double __v[]);
343 extern double __halfulp (double __x, double __y);
344 extern double __sin32 (double __x, double __res, double __res1);
345 extern double __cos32 (double __x, double __res, double __res1);
346 extern double __mpsin (double __x, double __dx);
347 extern double __mpcos (double __x, double __dx);
348 extern double __mpsin1 (double __x);
349 extern double __mpcos1 (double __x);
350 extern double __slowexp (double __x);
351 extern double __slowpow (double __x, double __y, double __z);
352 extern void __docos (double __x, double __dx, double __v[]);
354 #ifndef math_opt_barrier
355 #define math_opt_barrier(x) \
356 ({ __typeof (x) __x = x; __asm ("" : "+m" (__x)); __x; })
357 #define math_force_eval(x) __asm __volatile ("" : : "m" (x))
358 #endif
360 #endif /* _MATH_PRIVATE_H_ */