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 * ====================================================
34 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
35 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
43 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
58 #error Unsupported long double representation
61 #define FORCE_EVAL(x) do { \
62 if (sizeof(x) == sizeof(float)) { \
65 } else if (sizeof(x) == sizeof(double)) { \
66 volatile double __x; \
69 volatile long double __x; \
74 /* Get two 32 bit ints from a double. */
75 #define EXTRACT_WORDS(hi,lo,d) \
79 (hi) = __u.bits >> 32; \
80 (lo) = (uint32_t)__u.bits; \
83 /* Get the more significant 32 bit int from a double. */
84 #define GET_HIGH_WORD(i,d) \
88 (i) = __u.bits >> 32; \
91 /* Get the less significant 32 bit int from a double. */
92 #define GET_LOW_WORD(i,d) \
96 (i) = (uint32_t)__u.bits; \
99 /* Set a double from two 32 bit ints. */
100 #define INSERT_WORDS(d,hi,lo) \
103 __u.bits = ((uint64_t)(hi) << 32) | (uint32_t)(lo); \
107 /* Set the more significant 32 bits of a double from an int. */
108 #define SET_HIGH_WORD(d,hi) \
112 __u.bits &= 0xffffffff; \
113 __u.bits |= (uint64_t)(hi) << 32; \
117 /* Set the less significant 32 bits of a double from an int. */
118 #define SET_LOW_WORD(d,lo) \
122 __u.bits &= 0xffffffff00000000ull; \
123 __u.bits |= (uint32_t)(lo); \
127 /* Get a 32 bit int from a float. */
128 #define GET_FLOAT_WORD(i,d) \
135 /* Set a float from a 32 bit int. */
136 #define SET_FLOAT_WORD(d,i) \
143 /* fdlibm kernel functions */
145 int __rem_pio2_large(double*,double*,int,int,int);
147 int __rem_pio2(double,double*);
148 double __sin(double,double,int);
149 double __cos(double,double);
150 double __tan(double,double,int);
151 double __expo2(double);
152 double complex __ldexp_cexp(double complex,int);
154 int __rem_pio2f(float,double*);
155 float __sindf(double);
156 float __cosdf(double);
157 float __tandf(double,int);
158 float __expo2f(float);
159 float complex __ldexp_cexpf(float complex,int);
161 int __rem_pio2l(long double, long double *);
162 long double __sinl(long double, long double, int);
163 long double __cosl(long double, long double);
164 long double __tanl(long double, long double, int);
166 /* polynomial evaluation */
167 long double __polevll(long double, const long double *, int);
168 long double __p1evll(long double, const long double *, int);
171 /* Attempt to get strict C99 semantics for assignment with non-C99 compilers. */
172 #define STRICT_ASSIGN(type, lval, rval) do { \
173 volatile type __v = (rval); \
177 /* Should work with -fexcess-precision=standard (>=gcc-4.5) or -ffloat-store */
178 #define STRICT_ASSIGN(type, lval, rval) ((lval) = (type)(rval))