1 /* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
10 * ====================================================
21 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
22 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
30 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
31 /* This is the m68k variant of 80-bit long double, and this definition only works
32 * on archs where the alignment requirement of uint64_t is <= 4. */
41 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
55 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
70 #error Unsupported long double representation
73 #define FORCE_EVAL(x) do { \
74 if (sizeof(x) == sizeof(float)) { \
77 } else if (sizeof(x) == sizeof(double)) { \
78 volatile double __x; \
81 volatile long double __x; \
86 /* Get two 32 bit ints from a double. */
87 #define EXTRACT_WORDS(hi,lo,d) \
89 union {double f; uint64_t i;} __u; \
92 (lo) = (uint32_t)__u.i; \
95 /* Get the more significant 32 bit int from a double. */
96 #define GET_HIGH_WORD(hi,d) \
98 union {double f; uint64_t i;} __u; \
100 (hi) = __u.i >> 32; \
103 /* Get the less significant 32 bit int from a double. */
104 #define GET_LOW_WORD(lo,d) \
106 union {double f; uint64_t i;} __u; \
108 (lo) = (uint32_t)__u.i; \
111 /* Set a double from two 32 bit ints. */
112 #define INSERT_WORDS(d,hi,lo) \
114 union {double f; uint64_t i;} __u; \
115 __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \
119 /* Set the more significant 32 bits of a double from an int. */
120 #define SET_HIGH_WORD(d,hi) \
122 union {double f; uint64_t i;} __u; \
124 __u.i &= 0xffffffff; \
125 __u.i |= (uint64_t)(hi) << 32; \
129 /* Set the less significant 32 bits of a double from an int. */
130 #define SET_LOW_WORD(d,lo) \
132 union {double f; uint64_t i;} __u; \
134 __u.i &= 0xffffffff00000000ull; \
135 __u.i |= (uint32_t)(lo); \
139 /* Get a 32 bit int from a float. */
140 #define GET_FLOAT_WORD(w,d) \
142 union {float f; uint32_t i;} __u; \
147 /* Set a float from a 32 bit int. */
148 #define SET_FLOAT_WORD(d,w) \
150 union {float f; uint32_t i;} __u; \
155 /* fdlibm kernel functions */
157 hidden int __rem_pio2_large(double*,double*,int,int,int);
159 hidden int __rem_pio2(double,double*);
160 hidden double __sin(double,double,int);
161 hidden double __cos(double,double);
162 hidden double __tan(double,double,int);
163 hidden double __expo2(double);
165 hidden int __rem_pio2f(float,double*);
166 hidden float __sindf(double);
167 hidden float __cosdf(double);
168 hidden float __tandf(double,int);
169 hidden float __expo2f(float);
171 hidden int __rem_pio2l(long double, long double *);
172 hidden long double __sinl(long double, long double, int);
173 hidden long double __cosl(long double, long double);
174 hidden long double __tanl(long double, long double, int);
176 /* polynomial evaluation */
177 hidden long double __polevll(long double, const long double *, int);
178 hidden long double __p1evll(long double, const long double *, int);
180 extern int __signgam;
181 hidden double __lgamma_r(double, int *);
182 hidden float __lgammaf_r(float, int *);