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 * ====================================================
21 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
22 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
30 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
31 /* This is the m68k variant of 80-bit long double, and this definition only works
32 * on archs where the alignment requirement of uint64_t is <= 4. */
41 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
55 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
70 #error Unsupported long double representation
73 #define FORCE_EVAL(x) do { \
74 if (sizeof(x) == sizeof(float)) { \
77 } else if (sizeof(x) == sizeof(double)) { \
78 volatile double __x; \
81 volatile long double __x; \
86 #define asuint(f) ((union{float _f; uint32_t _i;}){f})._i
87 #define asfloat(i) ((union{uint32_t _i; float _f;}){i})._f
88 #define asuint64(f) ((union{double _f; uint64_t _i;}){f})._i
89 #define asdouble(i) ((union{uint64_t _i; double _f;}){i})._f
91 /* Get two 32 bit ints from a double. */
92 #define EXTRACT_WORDS(hi,lo,d) \
94 uint64_t __u = asuint64(d); \
96 (lo) = (uint32_t)__u; \
99 /* Get the more significant 32 bit int from a double. */
100 #define GET_HIGH_WORD(hi,d) \
102 (hi) = asuint64(d) >> 32; \
105 /* Get the less significant 32 bit int from a double. */
106 #define GET_LOW_WORD(lo,d) \
108 (lo) = (uint32_t)asuint64(d); \
111 /* Set a double from two 32 bit ints. */
112 #define INSERT_WORDS(d,hi,lo) \
114 (d) = asdouble(((uint64_t)(hi)<<32) | (uint32_t)(lo)); \
117 /* Set the more significant 32 bits of a double from an int. */
118 #define SET_HIGH_WORD(d,hi) \
119 INSERT_WORDS(d, hi, (uint32_t)asuint64(d))
121 /* Set the less significant 32 bits of a double from an int. */
122 #define SET_LOW_WORD(d,lo) \
123 INSERT_WORDS(d, asuint64(d)>>32, lo)
125 /* Get a 32 bit int from a float. */
126 #define GET_FLOAT_WORD(w,d) \
131 /* Set a float from a 32 bit int. */
132 #define SET_FLOAT_WORD(d,w) \
137 /* fdlibm kernel functions */
139 hidden int __rem_pio2_large(double*,double*,int,int,int);
141 hidden int __rem_pio2(double,double*);
142 hidden double __sin(double,double,int);
143 hidden double __cos(double,double);
144 hidden double __tan(double,double,int);
145 hidden double __expo2(double);
147 hidden int __rem_pio2f(float,double*);
148 hidden float __sindf(double);
149 hidden float __cosdf(double);
150 hidden float __tandf(double,int);
151 hidden float __expo2f(float);
153 hidden int __rem_pio2l(long double, long double *);
154 hidden long double __sinl(long double, long double, int);
155 hidden long double __cosl(long double, long double);
156 hidden long double __tanl(long double, long double, int);
158 /* polynomial evaluation */
159 hidden long double __polevll(long double, const long double *, int);
160 hidden long double __p1evll(long double, const long double *, int);
162 extern int __signgam;
163 hidden double __lgamma_r(double, int *);
164 hidden float __lgammaf_r(float, int *);