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 * ====================================================
35 #define FORCE_EVAL(x) do { \
36 if (sizeof(x) == sizeof(float)) { \
39 } else if (sizeof(x) == sizeof(double)) { \
40 volatile double __x; \
43 volatile long double __x; \
48 /* Get two 32 bit ints from a double. */
49 #define EXTRACT_WORDS(hi,lo,d) \
53 (hi) = __u.bits >> 32; \
54 (lo) = (uint32_t)__u.bits; \
57 /* Get a 64 bit int from a double. */
58 #define EXTRACT_WORD64(i,d) \
65 /* Get the more significant 32 bit int from a double. */
66 #define GET_HIGH_WORD(i,d) \
70 (i) = __u.bits >> 32; \
73 /* Get the less significant 32 bit int from a double. */
74 #define GET_LOW_WORD(i,d) \
78 (i) = (uint32_t)__u.bits; \
81 /* Set a double from two 32 bit ints. */
82 #define INSERT_WORDS(d,hi,lo) \
85 __u.bits = ((uint64_t)(hi) << 32) | (uint32_t)(lo); \
89 /* Set a double from a 64 bit int. */
90 #define INSERT_WORD64(d,i) \
97 /* Set the more significant 32 bits of a double from an int. */
98 #define SET_HIGH_WORD(d,hi) \
102 __u.bits &= 0xffffffff; \
103 __u.bits |= (uint64_t)(hi) << 32; \
107 /* Set the less significant 32 bits of a double from an int. */
108 #define SET_LOW_WORD(d,lo) \
112 __u.bits &= 0xffffffff00000000ull; \
113 __u.bits |= (uint32_t)(lo); \
117 /* Get a 32 bit int from a float. */
118 #define GET_FLOAT_WORD(i,d) \
125 /* Set a float from a 32 bit int. */
126 #define SET_FLOAT_WORD(d,i) \
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);
160 // FIXME: not needed when -fexcess-precision=standard is supported (>=gcc4.5)
162 * Attempt to get strict C99 semantics for assignment with non-C99 compilers.
165 #define STRICT_ASSIGN(type, lval, rval) do { \
166 volatile type __v = (rval); \
170 #define STRICT_ASSIGN(type, lval, rval) ((lval) = (type)(rval))
185 long double complex z;
189 /* x + y*I is not supported properly by gcc */
190 #define cpack(x,y) ((union dcomplex){.a={(x),(y)}}.z)
191 #define cpackf(x,y) ((union fcomplex){.a={(x),(y)}}.z)
192 #define cpackl(x,y) ((union lcomplex){.a={(x),(y)}}.z)