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 * ====================================================
24 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
25 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
33 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
48 #error Unsupported long double representation
51 #define FORCE_EVAL(x) do { \
52 if (sizeof(x) == sizeof(float)) { \
55 } else if (sizeof(x) == sizeof(double)) { \
56 volatile double __x; \
59 volatile long double __x; \
64 /* Get two 32 bit ints from a double. */
65 #define EXTRACT_WORDS(hi,lo,d) \
67 union {double f; uint64_t i;} __u; \
70 (lo) = (uint32_t)__u.i; \
73 /* Get the more significant 32 bit int from a double. */
74 #define GET_HIGH_WORD(hi,d) \
76 union {double f; uint64_t i;} __u; \
81 /* Get the less significant 32 bit int from a double. */
82 #define GET_LOW_WORD(lo,d) \
84 union {double f; uint64_t i;} __u; \
86 (lo) = (uint32_t)__u.i; \
89 /* Set a double from two 32 bit ints. */
90 #define INSERT_WORDS(d,hi,lo) \
92 union {double f; uint64_t i;} __u; \
93 __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \
97 /* Set the more significant 32 bits of a double from an int. */
98 #define SET_HIGH_WORD(d,hi) \
100 union {double f; uint64_t i;} __u; \
102 __u.i &= 0xffffffff; \
103 __u.i |= (uint64_t)(hi) << 32; \
107 /* Set the less significant 32 bits of a double from an int. */
108 #define SET_LOW_WORD(d,lo) \
110 union {double f; uint64_t i;} __u; \
112 __u.i &= 0xffffffff00000000ull; \
113 __u.i |= (uint32_t)(lo); \
117 /* Get a 32 bit int from a float. */
118 #define GET_FLOAT_WORD(w,d) \
120 union {float f; uint32_t i;} __u; \
125 /* Set a float from a 32 bit int. */
126 #define SET_FLOAT_WORD(d,w) \
128 union {float f; uint32_t i;} __u; \
133 /* fdlibm kernel functions */
135 int __rem_pio2_large(double*,double*,int,int,int);
137 int __rem_pio2(double,double*);
138 double __sin(double,double,int);
139 double __cos(double,double);
140 double __tan(double,double,int);
141 double __expo2(double);
142 double complex __ldexp_cexp(double complex,int);
144 int __rem_pio2f(float,double*);
145 float __sindf(double);
146 float __cosdf(double);
147 float __tandf(double,int);
148 float __expo2f(float);
149 float complex __ldexp_cexpf(float complex,int);
151 int __rem_pio2l(long double, long double *);
152 long double __sinl(long double, long double, int);
153 long double __cosl(long double, long double);
154 long double __tanl(long double, long double, int);
156 /* polynomial evaluation */
157 long double __polevll(long double, const long double *, int);
158 long double __p1evll(long double, const long double *, int);
161 /* Attempt to get strict C99 semantics for assignment with non-C99 compilers. */
162 #define STRICT_ASSIGN(type, lval, rval) do { \
163 volatile type __v = (rval); \
167 /* Should work with -fexcess-precision=standard (>=gcc-4.5) or -ffloat-store */
168 #define STRICT_ASSIGN(type, lval, rval) ((lval) = (type)(rval))