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
46 #error Unsupported long double representation
49 #define FORCE_EVAL(x) do { \
50 if (sizeof(x) == sizeof(float)) { \
53 } else if (sizeof(x) == sizeof(double)) { \
54 volatile double __x; \
57 volatile long double __x; \
62 /* Get two 32 bit ints from a double. */
63 #define EXTRACT_WORDS(hi,lo,d) \
65 union {double f; uint64_t i;} __u; \
68 (lo) = (uint32_t)__u.i; \
71 /* Get the more significant 32 bit int from a double. */
72 #define GET_HIGH_WORD(hi,d) \
74 union {double f; uint64_t i;} __u; \
79 /* Get the less significant 32 bit int from a double. */
80 #define GET_LOW_WORD(lo,d) \
82 union {double f; uint64_t i;} __u; \
84 (lo) = (uint32_t)__u.i; \
87 /* Set a double from two 32 bit ints. */
88 #define INSERT_WORDS(d,hi,lo) \
90 union {double f; uint64_t i;} __u; \
91 __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \
95 /* Set the more significant 32 bits of a double from an int. */
96 #define SET_HIGH_WORD(d,hi) \
98 union {double f; uint64_t i;} __u; \
100 __u.i &= 0xffffffff; \
101 __u.i |= (uint64_t)(hi) << 32; \
105 /* Set the less significant 32 bits of a double from an int. */
106 #define SET_LOW_WORD(d,lo) \
108 union {double f; uint64_t i;} __u; \
110 __u.i &= 0xffffffff00000000ull; \
111 __u.i |= (uint32_t)(lo); \
115 /* Get a 32 bit int from a float. */
116 #define GET_FLOAT_WORD(w,d) \
118 union {float f; uint32_t i;} __u; \
123 /* Set a float from a 32 bit int. */
124 #define SET_FLOAT_WORD(d,w) \
126 union {float f; uint32_t i;} __u; \
131 /* fdlibm kernel functions */
133 int __rem_pio2_large(double*,double*,int,int,int);
135 int __rem_pio2(double,double*);
136 double __sin(double,double,int);
137 double __cos(double,double);
138 double __tan(double,double,int);
139 double __expo2(double);
140 double complex __ldexp_cexp(double complex,int);
142 int __rem_pio2f(float,double*);
143 float __sindf(double);
144 float __cosdf(double);
145 float __tandf(double,int);
146 float __expo2f(float);
147 float complex __ldexp_cexpf(float complex,int);
149 int __rem_pio2l(long double, long double *);
150 long double __sinl(long double, long double, int);
151 long double __cosl(long double, long double);
152 long double __tanl(long double, long double, int);
154 /* polynomial evaluation */
155 long double __polevll(long double, const long double *, int);
156 long double __p1evll(long double, const long double *, int);
159 /* Attempt to get strict C99 semantics for assignment with non-C99 compilers. */
160 #define STRICT_ASSIGN(type, lval, rval) do { \
161 volatile type __v = (rval); \
165 /* Should work with -fexcess-precision=standard (>=gcc-4.5) or -ffloat-store */
166 #define STRICT_ASSIGN(type, lval, rval) ((lval) = (type)(rval))