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 == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
45 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
60 #error Unsupported long double representation
63 #define FORCE_EVAL(x) do { \
64 if (sizeof(x) == sizeof(float)) { \
67 } else if (sizeof(x) == sizeof(double)) { \
68 volatile double __x; \
71 volatile long double __x; \
76 /* Get two 32 bit ints from a double. */
77 #define EXTRACT_WORDS(hi,lo,d) \
79 union {double f; uint64_t i;} __u; \
82 (lo) = (uint32_t)__u.i; \
85 /* Get the more significant 32 bit int from a double. */
86 #define GET_HIGH_WORD(hi,d) \
88 union {double f; uint64_t i;} __u; \
93 /* Get the less significant 32 bit int from a double. */
94 #define GET_LOW_WORD(lo,d) \
96 union {double f; uint64_t i;} __u; \
98 (lo) = (uint32_t)__u.i; \
101 /* Set a double from two 32 bit ints. */
102 #define INSERT_WORDS(d,hi,lo) \
104 union {double f; uint64_t i;} __u; \
105 __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \
109 /* Set the more significant 32 bits of a double from an int. */
110 #define SET_HIGH_WORD(d,hi) \
112 union {double f; uint64_t i;} __u; \
114 __u.i &= 0xffffffff; \
115 __u.i |= (uint64_t)(hi) << 32; \
119 /* Set the less significant 32 bits of a double from an int. */
120 #define SET_LOW_WORD(d,lo) \
122 union {double f; uint64_t i;} __u; \
124 __u.i &= 0xffffffff00000000ull; \
125 __u.i |= (uint32_t)(lo); \
129 /* Get a 32 bit int from a float. */
130 #define GET_FLOAT_WORD(w,d) \
132 union {float f; uint32_t i;} __u; \
137 /* Set a float from a 32 bit int. */
138 #define SET_FLOAT_WORD(d,w) \
140 union {float f; uint32_t i;} __u; \
150 #define __CMPLX(x, y, t) \
151 ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
153 #define CMPLX(x, y) __CMPLX(x, y, double)
154 #define CMPLXF(x, y) __CMPLX(x, y, float)
155 #define CMPLXL(x, y) __CMPLX(x, y, long double)
157 /* fdlibm kernel functions */
159 int __rem_pio2_large(double*,double*,int,int,int);
161 int __rem_pio2(double,double*);
162 double __sin(double,double,int);
163 double __cos(double,double);
164 double __tan(double,double,int);
165 double __expo2(double);
166 double complex __ldexp_cexp(double complex,int);
168 int __rem_pio2f(float,double*);
169 float __sindf(double);
170 float __cosdf(double);
171 float __tandf(double,int);
172 float __expo2f(float);
173 float complex __ldexp_cexpf(float complex,int);
175 int __rem_pio2l(long double, long double *);
176 long double __sinl(long double, long double, int);
177 long double __cosl(long double, long double);
178 long double __tanl(long double, long double, int);
180 /* polynomial evaluation */
181 long double __polevll(long double, const long double *, int);
182 long double __p1evll(long double, const long double *, int);