Prepare Mono for Android NDK with unified headers (#5680)
[mono.git] / support / libm / math_private.h
1 /*
2  * ====================================================
3  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
4  *
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  * ====================================================
10  */
11
12 /*
13  * from: @(#)fdlibm.h 5.1 93/09/24
14  * $FreeBSD$
15  */
16
17 #ifndef _MATH_PRIVATE_H_
18 #define _MATH_PRIVATE_H_
19
20 #include <sys/types.h>
21
22 #if HAVE_MACHINE_ENDIAN_H
23 #include <machine/endian.h>
24 #elif HAVE_SYS_ENDIAN_H && HOST_ANDROID
25 /* Android unified headers don't have machine/endian.h */
26 #include <sys/endian.h>
27 #endif
28
29 /*
30  * The original fdlibm code used statements like:
31  *      n0 = ((*(int*)&one)>>29)^1;             * index of high word *
32  *      ix0 = *(n0+(int*)&x);                   * high word of x *
33  *      ix1 = *((1-n0)+(int*)&x);               * low word of x *
34  * to dig two 32 bit words out of the 64 bit IEEE floating point
35  * value.  That is non-ANSI, and, moreover, the gcc instruction
36  * scheduler gets it wrong.  We instead use the following macros.
37  * Unlike the original code, we determine the endianness at compile
38  * time, not at run time; I don't see much benefit to selecting
39  * endianness at run time.
40  */
41
42 /*
43  * A union which permits us to convert between a double and two 32 bit
44  * ints.
45  */
46
47 #ifdef __arm__
48 #if defined(__VFP_FP__) || defined(__ARM_EABI__)
49 #define IEEE_WORD_ORDER BYTE_ORDER
50 #else
51 #define IEEE_WORD_ORDER BIG_ENDIAN
52 #endif
53 #else /* __arm__ */
54 #define IEEE_WORD_ORDER BYTE_ORDER
55 #endif
56
57 #if IEEE_WORD_ORDER == BIG_ENDIAN
58
59 typedef union
60 {
61   double value;
62   struct
63   {
64     u_int32_t msw;
65     u_int32_t lsw;
66   } parts;
67   struct
68   {
69     u_int64_t w;
70   } xparts;
71 } ieee_double_shape_type;
72
73 #endif
74
75 #if IEEE_WORD_ORDER == LITTLE_ENDIAN
76
77 typedef union
78 {
79   double value;
80   struct
81   {
82     u_int32_t lsw;
83     u_int32_t msw;
84   } parts;
85   struct
86   {
87     u_int64_t w;
88   } xparts;
89 } ieee_double_shape_type;
90
91 #endif
92
93 /* Get two 32 bit ints from a double.  */
94
95 #define EXTRACT_WORDS(ix0,ix1,d)                                \
96 do {                                                            \
97   ieee_double_shape_type ew_u;                                  \
98   ew_u.value = (d);                                             \
99   (ix0) = ew_u.parts.msw;                                       \
100   (ix1) = ew_u.parts.lsw;                                       \
101 } while (0)
102
103 /* Get a 64-bit int from a double. */
104 #define EXTRACT_WORD64(ix,d)                                    \
105 do {                                                            \
106   ieee_double_shape_type ew_u;                                  \
107   ew_u.value = (d);                                             \
108   (ix) = ew_u.xparts.w;                                         \
109 } while (0)
110
111 /* Get the more significant 32 bit int from a double.  */
112
113 #define GET_HIGH_WORD(i,d)                                      \
114 do {                                                            \
115   ieee_double_shape_type gh_u;                                  \
116   gh_u.value = (d);                                             \
117   (i) = gh_u.parts.msw;                                         \
118 } while (0)
119
120 /* Get the less significant 32 bit int from a double.  */
121
122 #define GET_LOW_WORD(i,d)                                       \
123 do {                                                            \
124   ieee_double_shape_type gl_u;                                  \
125   gl_u.value = (d);                                             \
126   (i) = gl_u.parts.lsw;                                         \
127 } while (0)
128
129 /* Set a double from two 32 bit ints.  */
130
131 #define INSERT_WORDS(d,ix0,ix1)                                 \
132 do {                                                            \
133   ieee_double_shape_type iw_u;                                  \
134   iw_u.parts.msw = (ix0);                                       \
135   iw_u.parts.lsw = (ix1);                                       \
136   (d) = iw_u.value;                                             \
137 } while (0)
138
139 /* Set a double from a 64-bit int. */
140 #define INSERT_WORD64(d,ix)                                     \
141 do {                                                            \
142   ieee_double_shape_type iw_u;                                  \
143   iw_u.xparts.w = (ix);                                         \
144   (d) = iw_u.value;                                             \
145 } while (0)
146
147 /* Set the more significant 32 bits of a double from an int.  */
148
149 #define SET_HIGH_WORD(d,v)                                      \
150 do {                                                            \
151   ieee_double_shape_type sh_u;                                  \
152   sh_u.value = (d);                                             \
153   sh_u.parts.msw = (v);                                         \
154   (d) = sh_u.value;                                             \
155 } while (0)
156
157 /* Set the less significant 32 bits of a double from an int.  */
158
159 #define SET_LOW_WORD(d,v)                                       \
160 do {                                                            \
161   ieee_double_shape_type sl_u;                                  \
162   sl_u.value = (d);                                             \
163   sl_u.parts.lsw = (v);                                         \
164   (d) = sl_u.value;                                             \
165 } while (0)
166
167 /*
168  * A union which permits us to convert between a float and a 32 bit
169  * int.
170  */
171
172 typedef union
173 {
174   float value;
175   /* FIXME: Assumes 32 bit int.  */
176   unsigned int word;
177 } ieee_float_shape_type;
178
179 /* Get a 32 bit int from a float.  */
180
181 #define GET_FLOAT_WORD(i,d)                                     \
182 do {                                                            \
183   ieee_float_shape_type gf_u;                                   \
184   gf_u.value = (d);                                             \
185   (i) = gf_u.word;                                              \
186 } while (0)
187
188 /* Set a float from a 32 bit int.  */
189
190 #define SET_FLOAT_WORD(d,i)                                     \
191 do {                                                            \
192   ieee_float_shape_type sf_u;                                   \
193   sf_u.word = (i);                                              \
194   (d) = sf_u.value;                                             \
195 } while (0)
196
197 /*
198  * Get expsign and mantissa as 16 bit and 64 bit ints from an 80 bit long
199  * double.
200  */
201
202 #define EXTRACT_LDBL80_WORDS(ix0,ix1,d)                         \
203 do {                                                            \
204   union IEEEl2bits ew_u;                                        \
205   ew_u.e = (d);                                                 \
206   (ix0) = ew_u.xbits.expsign;                                   \
207   (ix1) = ew_u.xbits.man;                                       \
208 } while (0)
209
210 /*
211  * Get expsign and mantissa as one 16 bit and two 64 bit ints from a 128 bit
212  * long double.
213  */
214
215 #define EXTRACT_LDBL128_WORDS(ix0,ix1,ix2,d)                    \
216 do {                                                            \
217   union IEEEl2bits ew_u;                                        \
218   ew_u.e = (d);                                                 \
219   (ix0) = ew_u.xbits.expsign;                                   \
220   (ix1) = ew_u.xbits.manh;                                      \
221   (ix2) = ew_u.xbits.manl;                                      \
222 } while (0)
223
224 /* Get expsign as a 16 bit int from a long double.  */
225
226 #define GET_LDBL_EXPSIGN(i,d)                                   \
227 do {                                                            \
228   union IEEEl2bits ge_u;                                        \
229   ge_u.e = (d);                                                 \
230   (i) = ge_u.xbits.expsign;                                     \
231 } while (0)
232
233 /*
234  * Set an 80 bit long double from a 16 bit int expsign and a 64 bit int
235  * mantissa.
236  */
237
238 #define INSERT_LDBL80_WORDS(d,ix0,ix1)                          \
239 do {                                                            \
240   union IEEEl2bits iw_u;                                        \
241   iw_u.xbits.expsign = (ix0);                                   \
242   iw_u.xbits.man = (ix1);                                       \
243   (d) = iw_u.e;                                                 \
244 } while (0)
245
246 /*
247  * Set a 128 bit long double from a 16 bit int expsign and two 64 bit ints
248  * comprising the mantissa.
249  */
250
251 #define INSERT_LDBL128_WORDS(d,ix0,ix1,ix2)                     \
252 do {                                                            \
253   union IEEEl2bits iw_u;                                        \
254   iw_u.xbits.expsign = (ix0);                                   \
255   iw_u.xbits.manh = (ix1);                                      \
256   iw_u.xbits.manl = (ix2);                                      \
257   (d) = iw_u.e;                                                 \
258 } while (0)
259
260 /* Set expsign of a long double from a 16 bit int.  */
261
262 #define SET_LDBL_EXPSIGN(d,v)                                   \
263 do {                                                            \
264   union IEEEl2bits se_u;                                        \
265   se_u.e = (d);                                                 \
266   se_u.xbits.expsign = (v);                                     \
267   (d) = se_u.e;                                                 \
268 } while (0)
269
270 #ifdef __i386__
271 /* Long double constants are broken on i386. */
272 #define LD80C(m, ex, v) {                                               \
273         .xbits.man = __CONCAT(m, ULL),                                  \
274         .xbits.expsign = (0x3fff + (ex)) | ((v) < 0 ? 0x8000 : 0),      \
275 }
276 #else
277 /* The above works on non-i386 too, but we use this to check v. */
278 #define LD80C(m, ex, v) { .e = (v), }
279 #endif
280
281 #ifdef FLT_EVAL_METHOD
282 /*
283  * Attempt to get strict C99 semantics for assignment with non-C99 compilers.
284  */
285 #if FLT_EVAL_METHOD == 0 || __GNUC__ == 0
286 #define STRICT_ASSIGN(type, lval, rval) ((lval) = (rval))
287 #else
288 #define STRICT_ASSIGN(type, lval, rval) do {    \
289         volatile type __lval;                   \
290                                                 \
291         if (sizeof(type) >= sizeof(long double))        \
292                 (lval) = (rval);                \
293         else {                                  \
294                 __lval = (rval);                \
295                 (lval) = __lval;                \
296         }                                       \
297 } while (0)
298 #endif
299 #endif /* FLT_EVAL_METHOD */
300
301 /* Support switching the mode to FP_PE if necessary. */
302 #if defined(__i386__) && !defined(NO_FPSETPREC)
303 #define ENTERI()                                \
304         long double __retval;                   \
305         fp_prec_t __oprec;                      \
306                                                 \
307         if ((__oprec = fpgetprec()) != FP_PE)   \
308                 fpsetprec(FP_PE)
309 #define RETURNI(x) do {                         \
310         __retval = (x);                         \
311         if (__oprec != FP_PE)                   \
312                 fpsetprec(__oprec);             \
313         RETURNF(__retval);                      \
314 } while (0)
315 #else
316 #define ENTERI(x)
317 #define RETURNI(x)      RETURNF(x)
318 #endif
319
320 /* Default return statement if hack*_t() is not used. */
321 #define      RETURNF(v)      return (v)
322
323 /*
324  * 2sum gives the same result as 2sumF without requiring |a| >= |b| or
325  * a == 0, but is slower.
326  */
327 #define _2sum(a, b) do {        \
328         __typeof(a) __s, __w;   \
329                                 \
330         __w = (a) + (b);        \
331         __s = __w - (a);        \
332         (b) = ((a) - (__w - __s)) + ((b) - __s); \
333         (a) = __w;              \
334 } while (0)
335
336 /*
337  * 2sumF algorithm.
338  *
339  * "Normalize" the terms in the infinite-precision expression a + b for
340  * the sum of 2 floating point values so that b is as small as possible
341  * relative to 'a'.  (The resulting 'a' is the value of the expression in
342  * the same precision as 'a' and the resulting b is the rounding error.)
343  * |a| must be >= |b| or 0, b's type must be no larger than 'a's type, and
344  * exponent overflow or underflow must not occur.  This uses a Theorem of
345  * Dekker (1971).  See Knuth (1981) 4.2.2 Theorem C.  The name "TwoSum"
346  * is apparently due to Skewchuk (1997).
347  *
348  * For this to always work, assignment of a + b to 'a' must not retain any
349  * extra precision in a + b.  This is required by C standards but broken
350  * in many compilers.  The brokenness cannot be worked around using
351  * STRICT_ASSIGN() like we do elsewhere, since the efficiency of this
352  * algorithm would be destroyed by non-null strict assignments.  (The
353  * compilers are correct to be broken -- the efficiency of all floating
354  * point code calculations would be destroyed similarly if they forced the
355  * conversions.)
356  *
357  * Fortunately, a case that works well can usually be arranged by building
358  * any extra precision into the type of 'a' -- 'a' should have type float_t,
359  * double_t or long double.  b's type should be no larger than 'a's type.
360  * Callers should use these types with scopes as large as possible, to
361  * reduce their own extra-precision and efficiciency problems.  In
362  * particular, they shouldn't convert back and forth just to call here.
363  */
364 #ifdef DEBUG
365 #define _2sumF(a, b) do {                               \
366         __typeof(a) __w;                                \
367         volatile __typeof(a) __ia, __ib, __r, __vw;     \
368                                                         \
369         __ia = (a);                                     \
370         __ib = (b);                                     \
371         assert(__ia == 0 || fabsl(__ia) >= fabsl(__ib));        \
372                                                         \
373         __w = (a) + (b);                                \
374         (b) = ((a) - __w) + (b);                        \
375         (a) = __w;                                      \
376                                                         \
377         /* The next 2 assertions are weak if (a) is already long double. */ \
378         assert((long double)__ia + __ib == (long double)(a) + (b));     \
379         __vw = __ia + __ib;                             \
380         __r = __ia - __vw;                              \
381         __r += __ib;                                    \
382         assert(__vw == (a) && __r == (b));              \
383 } while (0)
384 #else /* !DEBUG */
385 #define _2sumF(a, b) do {       \
386         __typeof(a) __w;        \
387                                 \
388         __w = (a) + (b);        \
389         (b) = ((a) - __w) + (b); \
390         (a) = __w;              \
391 } while (0)
392 #endif /* DEBUG */
393
394 /*
395  * Set x += c, where x is represented in extra precision as a + b.
396  * x must be sufficiently normalized and sufficiently larger than c,
397  * and the result is then sufficiently normalized.
398  *
399  * The details of ordering are that |a| must be >= |c| (so that (a, c)
400  * can be normalized without extra work to swap 'a' with c).  The details of
401  * the normalization are that b must be small relative to the normalized 'a'.
402  * Normalization of (a, c) makes the normalized c tiny relative to the
403  * normalized a, so b remains small relative to 'a' in the result.  However,
404  * b need not ever be tiny relative to 'a'.  For example, b might be about
405  * 2**20 times smaller than 'a' to give about 20 extra bits of precision.
406  * That is usually enough, and adding c (which by normalization is about
407  * 2**53 times smaller than a) cannot change b significantly.  However,
408  * cancellation of 'a' with c in normalization of (a, c) may reduce 'a'
409  * significantly relative to b.  The caller must ensure that significant
410  * cancellation doesn't occur, either by having c of the same sign as 'a',
411  * or by having |c| a few percent smaller than |a|.  Pre-normalization of
412  * (a, b) may help.
413  *
414  * This is is a variant of an algorithm of Kahan (see Knuth (1981) 4.2.2
415  * exercise 19).  We gain considerable efficiency by requiring the terms to
416  * be sufficiently normalized and sufficiently increasing.
417  */
418 #define _3sumF(a, b, c) do {    \
419         __typeof(a) __tmp;      \
420                                 \
421         __tmp = (c);            \
422         _2sumF(__tmp, (a));     \
423         (b) += (a);             \
424         (a) = __tmp;            \
425 } while (0)
426
427 /*
428  * Common routine to process the arguments to nan(), nanf(), and nanl().
429  */
430 void _scan_nan(uint32_t *__words, int __num_words, const char *__s);
431
432 #ifdef _COMPLEX_H
433
434 /*
435  * C99 specifies that complex numbers have the same representation as
436  * an array of two elements, where the first element is the real part
437  * and the second element is the imaginary part.
438  */
439 typedef union {
440         float complex f;
441         float a[2];
442 } float_complex;
443 typedef union {
444         double complex f;
445         double a[2];
446 } double_complex;
447 typedef union {
448         long double complex f;
449         long double a[2];
450 } long_double_complex;
451 #define REALPART(z)     ((z).a[0])
452 #define IMAGPART(z)     ((z).a[1])
453
454 /*
455  * Inline functions that can be used to construct complex values.
456  *
457  * The C99 standard intends x+I*y to be used for this, but x+I*y is
458  * currently unusable in general since gcc introduces many overflow,
459  * underflow, sign and efficiency bugs by rewriting I*y as
460  * (0.0+I)*(y+0.0*I) and laboriously computing the full complex product.
461  * In particular, I*Inf is corrupted to NaN+I*Inf, and I*-0 is corrupted
462  * to -0.0+I*0.0.
463  */
464 static __inline float complex
465 cpackf(float x, float y)
466 {
467         float_complex z;
468
469         REALPART(z) = x;
470         IMAGPART(z) = y;
471         return (z.f);
472 }
473
474 static __inline double complex
475 cpack(double x, double y)
476 {
477         double_complex z;
478
479         REALPART(z) = x;
480         IMAGPART(z) = y;
481         return (z.f);
482 }
483
484 static __inline long double complex
485 cpackl(long double x, long double y)
486 {
487         long_double_complex z;
488
489         REALPART(z) = x;
490         IMAGPART(z) = y;
491         return (z.f);
492 }
493 #endif /* _COMPLEX_H */
494  
495 #ifdef __GNUCLIKE_ASM
496
497 /* Asm versions of some functions. */
498
499 #ifdef __amd64__
500 static __inline int
501 irint(double x)
502 {
503         int n;
504
505         asm("cvtsd2si %1,%0" : "=r" (n) : "x" (x));
506         return (n);
507 }
508 #define HAVE_EFFICIENT_IRINT
509 #endif
510
511 #ifdef __i386__
512 static __inline int
513 irint(double x)
514 {
515         int n;
516
517         asm("fistl %0" : "=m" (n) : "t" (x));
518         return (n);
519 }
520 #define HAVE_EFFICIENT_IRINT
521 #endif
522
523 #if defined(__amd64__) || defined(__i386__)
524 static __inline int
525 irintl(long double x)
526 {
527         int n;
528
529         asm("fistl %0" : "=m" (n) : "t" (x));
530         return (n);
531 }
532 #define HAVE_EFFICIENT_IRINTL
533 #endif
534
535 #endif /* __GNUCLIKE_ASM */
536
537 #ifdef DEBUG
538 #if defined(__amd64__) || defined(__i386__)
539 #define breakpoint()    asm("int $3")
540 #else
541 #include <signal.h>
542
543 #define breakpoint()    raise(SIGTRAP)
544 #endif
545 #endif
546
547 /* Write a pari script to test things externally. */
548 #ifdef DOPRINT
549 #include <stdio.h>
550
551 #ifndef DOPRINT_SWIZZLE
552 #define DOPRINT_SWIZZLE         0
553 #endif
554
555 #ifdef DOPRINT_LD80
556
557 #define DOPRINT_START(xp) do {                                          \
558         uint64_t __lx;                                                  \
559         uint16_t __hx;                                                  \
560                                                                         \
561         /* Hack to give more-problematic args. */                       \
562         EXTRACT_LDBL80_WORDS(__hx, __lx, *xp);                          \
563         __lx ^= DOPRINT_SWIZZLE;                                        \
564         INSERT_LDBL80_WORDS(*xp, __hx, __lx);                           \
565         printf("x = %.21Lg; ", (long double)*xp);                       \
566 } while (0)
567 #define DOPRINT_END1(v)                                                 \
568         printf("y = %.21Lg; z = 0; show(x, y, z);\n", (long double)(v))
569 #define DOPRINT_END2(hi, lo)                                            \
570         printf("y = %.21Lg; z = %.21Lg; show(x, y, z);\n",              \
571             (long double)(hi), (long double)(lo))
572
573 #elif defined(DOPRINT_D64)
574
575 #define DOPRINT_START(xp) do {                                          \
576         uint32_t __hx, __lx;                                            \
577                                                                         \
578         EXTRACT_WORDS(__hx, __lx, *xp);                                 \
579         __lx ^= DOPRINT_SWIZZLE;                                        \
580         INSERT_WORDS(*xp, __hx, __lx);                                  \
581         printf("x = %.21Lg; ", (long double)*xp);                       \
582 } while (0)
583 #define DOPRINT_END1(v)                                                 \
584         printf("y = %.21Lg; z = 0; show(x, y, z);\n", (long double)(v))
585 #define DOPRINT_END2(hi, lo)                                            \
586         printf("y = %.21Lg; z = %.21Lg; show(x, y, z);\n",              \
587             (long double)(hi), (long double)(lo))
588
589 #elif defined(DOPRINT_F32)
590
591 #define DOPRINT_START(xp) do {                                          \
592         uint32_t __hx;                                                  \
593                                                                         \
594         GET_FLOAT_WORD(__hx, *xp);                                      \
595         __hx ^= DOPRINT_SWIZZLE;                                        \
596         SET_FLOAT_WORD(*xp, __hx);                                      \
597         printf("x = %.21Lg; ", (long double)*xp);                       \
598 } while (0)
599 #define DOPRINT_END1(v)                                                 \
600         printf("y = %.21Lg; z = 0; show(x, y, z);\n", (long double)(v))
601 #define DOPRINT_END2(hi, lo)                                            \
602         printf("y = %.21Lg; z = %.21Lg; show(x, y, z);\n",              \
603             (long double)(hi), (long double)(lo))
604
605 #else /* !DOPRINT_LD80 && !DOPRINT_D64 (LD128 only) */
606
607 #ifndef DOPRINT_SWIZZLE_HIGH
608 #define DOPRINT_SWIZZLE_HIGH    0
609 #endif
610
611 #define DOPRINT_START(xp) do {                                          \
612         uint64_t __lx, __llx;                                           \
613         uint16_t __hx;                                                  \
614                                                                         \
615         EXTRACT_LDBL128_WORDS(__hx, __lx, __llx, *xp);                  \
616         __llx ^= DOPRINT_SWIZZLE;                                       \
617         __lx ^= DOPRINT_SWIZZLE_HIGH;                                   \
618         INSERT_LDBL128_WORDS(*xp, __hx, __lx, __llx);                   \
619         printf("x = %.36Lg; ", (long double)*xp);                                       \
620 } while (0)
621 #define DOPRINT_END1(v)                                                 \
622         printf("y = %.36Lg; z = 0; show(x, y, z);\n", (long double)(v))
623 #define DOPRINT_END2(hi, lo)                                            \
624         printf("y = %.36Lg; z = %.36Lg; show(x, y, z);\n",              \
625             (long double)(hi), (long double)(lo))
626
627 #endif /* DOPRINT_LD80 */
628
629 #else /* !DOPRINT */
630 #define DOPRINT_START(xp)
631 #define DOPRINT_END1(v)
632 #define DOPRINT_END2(hi, lo)
633 #endif /* DOPRINT */
634
635 #define RETURNP(x) do {                 \
636         DOPRINT_END1(x);                \
637         RETURNF(x);                     \
638 } while (0)
639 #define RETURNPI(x) do {                \
640         DOPRINT_END1(x);                \
641         RETURNI(x);                     \
642 } while (0)
643 #define RETURN2P(x, y) do {             \
644         DOPRINT_END2((x), (y));         \
645         RETURNF((x) + (y));             \
646 } while (0)
647 #define RETURN2PI(x, y) do {            \
648         DOPRINT_END2((x), (y));         \
649         RETURNI((x) + (y));             \
650 } while (0)
651 #ifdef STRUCT_RETURN
652 #define RETURNSP(rp) do {               \
653         if (!(rp)->lo_set)              \
654                 RETURNP((rp)->hi);      \
655         RETURN2P((rp)->hi, (rp)->lo);   \
656 } while (0)
657 #define RETURNSPI(rp) do {              \
658         if (!(rp)->lo_set)              \
659                 RETURNPI((rp)->hi);     \
660         RETURN2PI((rp)->hi, (rp)->lo);  \
661 } while (0)
662 #endif
663 #define SUM2P(x, y) ({                  \
664         const __typeof (x) __x = (x);   \
665         const __typeof (y) __y = (y);   \
666                                         \
667         DOPRINT_END2(__x, __y);         \
668         __x + __y;                      \
669 })
670
671 /*
672  * ieee style elementary functions
673  *
674  * We rename functions here to improve other sources' diffability
675  * against fdlibm.
676  */
677 #define __ieee754_sqrt  sqrt
678 #define __ieee754_acos  acos
679 #define __ieee754_acosh acosh
680 #define __ieee754_log   log
681 #define __ieee754_log2  log2
682 #define __ieee754_atanh atanh
683 #define __ieee754_asin  asin
684 #define __ieee754_atan2 atan2
685 #define __ieee754_exp   exp
686 #define __ieee754_cosh  cosh
687 #define __ieee754_fmod  fmod
688 #define __ieee754_pow   pow
689 #define __ieee754_lgamma lgamma
690 #define __ieee754_gamma gamma
691 #define __ieee754_lgamma_r lgamma_r
692 #define __ieee754_gamma_r gamma_r
693 #define __ieee754_log10 log10
694 #define __ieee754_sinh  sinh
695 #define __ieee754_hypot hypot
696 #define __ieee754_j0    j0
697 #define __ieee754_j1    j1
698 #define __ieee754_y0    y0
699 #define __ieee754_y1    y1
700 #define __ieee754_jn    jn
701 #define __ieee754_yn    yn
702 #define __ieee754_remainder remainder
703 #define __ieee754_scalb scalb
704 #define __ieee754_sqrtf sqrtf
705 #define __ieee754_acosf acosf
706 #define __ieee754_acoshf acoshf
707 #define __ieee754_logf  logf
708 #define __ieee754_atanhf atanhf
709 #define __ieee754_asinf asinf
710 #define __ieee754_atan2f atan2f
711 #define __ieee754_expf  expf
712 #define __ieee754_coshf coshf
713 #define __ieee754_fmodf fmodf
714 #define __ieee754_powf  powf
715 #define __ieee754_lgammaf lgammaf
716 #define __ieee754_gammaf gammaf
717 #define __ieee754_lgammaf_r lgammaf_r
718 #define __ieee754_gammaf_r gammaf_r
719 #define __ieee754_log10f log10f
720 #define __ieee754_log2f log2f
721 #define __ieee754_sinhf sinhf
722 #define __ieee754_hypotf hypotf
723 #define __ieee754_j0f   j0f
724 #define __ieee754_j1f   j1f
725 #define __ieee754_y0f   y0f
726 #define __ieee754_y1f   y1f
727 #define __ieee754_jnf   jnf
728 #define __ieee754_ynf   ynf
729 #define __ieee754_remainderf remainderf
730 #define __ieee754_scalbf scalbf
731
732 /* fdlibm kernel function */
733 int     __kernel_rem_pio2(double*,double*,int,int,int);
734
735 /* double precision kernel functions */
736 #ifndef INLINE_REM_PIO2
737 int     __ieee754_rem_pio2(double,double*);
738 #endif
739 double  __kernel_sin(double,double,int);
740 double  __kernel_cos(double,double);
741 double  __kernel_tan(double,double,int);
742 double  __ldexp_exp(double,int);
743 #ifdef _COMPLEX_H
744 double complex __ldexp_cexp(double complex,int);
745 #endif
746
747 /* float precision kernel functions */
748 #ifndef INLINE_REM_PIO2F
749 int     __ieee754_rem_pio2f(float,double*);
750 #endif
751 #ifndef INLINE_KERNEL_SINDF
752 float   __kernel_sindf(double);
753 #endif
754 #ifndef INLINE_KERNEL_COSDF
755 float   __kernel_cosdf(double);
756 #endif
757 #ifndef INLINE_KERNEL_TANDF
758 float   __kernel_tandf(double,int);
759 #endif
760 float   __ldexp_expf(float,int);
761 #ifdef _COMPLEX_H
762 float complex __ldexp_cexpf(float complex,int);
763 #endif
764
765 /* long double precision kernel functions */
766 long double __kernel_sinl(long double, long double, int);
767 long double __kernel_cosl(long double, long double);
768 long double __kernel_tanl(long double, long double, int);
769
770 #endif /* !_MATH_PRIVATE_H_ */