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 * ====================================================
22 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
23 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
31 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
32 /* This is the m68k variant of 80-bit long double, and this definition only works
33 * on archs where the alignment requirement of uint64_t is <= 4. */
42 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
56 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
71 #error Unsupported long double representation
74 #define FORCE_EVAL(x) do { \
75 if (sizeof(x) == sizeof(float)) { \
78 } else if (sizeof(x) == sizeof(double)) { \
79 volatile double __x; \
82 volatile long double __x; \
87 /* Get two 32 bit ints from a double. */
88 #define EXTRACT_WORDS(hi,lo,d) \
90 union {double f; uint64_t i;} __u; \
93 (lo) = (uint32_t)__u.i; \
96 /* Get the more significant 32 bit int from a double. */
97 #define GET_HIGH_WORD(hi,d) \
99 union {double f; uint64_t i;} __u; \
101 (hi) = __u.i >> 32; \
104 /* Get the less significant 32 bit int from a double. */
105 #define GET_LOW_WORD(lo,d) \
107 union {double f; uint64_t i;} __u; \
109 (lo) = (uint32_t)__u.i; \
112 /* Set a double from two 32 bit ints. */
113 #define INSERT_WORDS(d,hi,lo) \
115 union {double f; uint64_t i;} __u; \
116 __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \
120 /* Set the more significant 32 bits of a double from an int. */
121 #define SET_HIGH_WORD(d,hi) \
123 union {double f; uint64_t i;} __u; \
125 __u.i &= 0xffffffff; \
126 __u.i |= (uint64_t)(hi) << 32; \
130 /* Set the less significant 32 bits of a double from an int. */
131 #define SET_LOW_WORD(d,lo) \
133 union {double f; uint64_t i;} __u; \
135 __u.i &= 0xffffffff00000000ull; \
136 __u.i |= (uint32_t)(lo); \
140 /* Get a 32 bit int from a float. */
141 #define GET_FLOAT_WORD(w,d) \
143 union {float f; uint32_t i;} __u; \
148 /* Set a float from a 32 bit int. */
149 #define SET_FLOAT_WORD(d,w) \
151 union {float f; uint32_t i;} __u; \
161 #define __CMPLX(x, y, t) \
162 ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
164 #define CMPLX(x, y) __CMPLX(x, y, double)
165 #define CMPLXF(x, y) __CMPLX(x, y, float)
166 #define CMPLXL(x, y) __CMPLX(x, y, long double)
168 /* fdlibm kernel functions */
170 hidden int __rem_pio2_large(double*,double*,int,int,int);
172 hidden int __rem_pio2(double,double*);
173 hidden double __sin(double,double,int);
174 hidden double __cos(double,double);
175 hidden double __tan(double,double,int);
176 hidden double __expo2(double);
177 hidden double complex __ldexp_cexp(double complex,int);
179 hidden int __rem_pio2f(float,double*);
180 hidden float __sindf(double);
181 hidden float __cosdf(double);
182 hidden float __tandf(double,int);
183 hidden float __expo2f(float);
184 hidden float complex __ldexp_cexpf(float complex,int);
186 hidden int __rem_pio2l(long double, long double *);
187 hidden long double __sinl(long double, long double, int);
188 hidden long double __cosl(long double, long double);
189 hidden long double __tanl(long double, long double, int);
191 /* polynomial evaluation */
192 hidden long double __polevll(long double, const long double *, int);
193 hidden long double __p1evll(long double, const long double *, int);
195 extern int __signgam;
196 hidden double __lgamma_r(double, int *);
197 hidden float __lgammaf_r(float, int *);