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 * ====================================================
33 /* Get two 32 bit ints from a double. */
34 #define EXTRACT_WORDS(hi,lo,d) \
38 (hi) = __u.bits >> 32; \
39 (lo) = (uint32_t)__u.bits; \
42 /* Get a 64 bit int from a double. */
43 #define EXTRACT_WORD64(i,d) \
50 /* Get the more significant 32 bit int from a double. */
51 #define GET_HIGH_WORD(i,d) \
55 (i) = __u.bits >> 32; \
58 /* Get the less significant 32 bit int from a double. */
59 #define GET_LOW_WORD(i,d) \
63 (i) = (uint32_t)__u.bits; \
66 /* Set a double from two 32 bit ints. */
67 #define INSERT_WORDS(d,hi,lo) \
70 __u.bits = ((uint64_t)(hi) << 32) | (uint32_t)(lo); \
74 /* Set a double from a 64 bit int. */
75 #define INSERT_WORD64(d,i) \
82 /* Set the more significant 32 bits of a double from an int. */
83 #define SET_HIGH_WORD(d,hi) \
87 __u.bits &= 0xffffffff; \
88 __u.bits |= (uint64_t)(hi) << 32; \
92 /* Set the less significant 32 bits of a double from an int. */
93 #define SET_LOW_WORD(d,lo) \
97 __u.bits &= 0xffffffff00000000ull; \
98 __u.bits |= (uint32_t)(lo); \
102 /* Get a 32 bit int from a float. */
103 #define GET_FLOAT_WORD(i,d) \
110 /* Set a float from a 32 bit int. */
111 #define SET_FLOAT_WORD(d,i) \
118 /* fdlibm kernel functions */
120 int __rem_pio2_large(double*,double*,int,int,int);
122 int __rem_pio2(double,double*);
123 double __sin(double,double,int);
124 double __cos(double,double);
125 double __tan(double,double,int);
126 double __expo2(double);
127 double complex __ldexp_cexp(double complex,int);
129 int __rem_pio2f(float,double*);
130 float __sindf(double);
131 float __cosdf(double);
132 float __tandf(double,int);
133 float __expo2f(float);
134 float complex __ldexp_cexpf(float complex,int);
136 long double __sinl(long double, long double, int);
137 long double __cosl(long double, long double);
138 long double __tanl(long double, long double, int);
140 /* polynomial evaluation */
141 long double __polevll(long double, long double *, int);
142 long double __p1evll(long double, long double *, int);
144 // FIXME: not needed when -fexcess-precision=standard is supported (>=gcc4.5)
146 * Attempt to get strict C99 semantics for assignment with non-C99 compilers.
149 #define STRICT_ASSIGN(type, lval, rval) do { \
150 volatile type __v = (rval); \
154 #define STRICT_ASSIGN(type, lval, rval) ((lval) = (type)(rval))
169 long double complex z;
173 // FIXME: move to complex.h ?
174 #define creal(z) ((double)(z))
175 #define crealf(z) ((float)(z))
176 #define creall(z) ((long double)(z))
177 #define cimag(z) ((union dcomplex){(z)}.a[1])
178 #define cimagf(z) ((union fcomplex){(z)}.a[1])
179 #define cimagl(z) ((union lcomplex){(z)}.a[1])
181 /* x + y*I is not supported properly by gcc */
182 #define cpack(x,y) ((union dcomplex){.a={(x),(y)}}.z)
183 #define cpackf(x,y) ((union fcomplex){.a={(x),(y)}}.z)
184 #define cpackl(x,y) ((union lcomplex){.a={(x),(y)}}.z)