10 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
11 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
19 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
20 /* This is the m68k variant of 80-bit long double, and this definition only works
21 * on archs where the alignment requirement of uint64_t is <= 4. */
30 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
44 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
59 #error Unsupported long double representation
62 /* Support non-nearest rounding mode. */
63 #define WANT_ROUNDING 1
64 /* Support signaling NaNs. */
68 #error SNaN is unsupported
70 #define issignalingf_inline(x) 0
71 #define issignaling_inline(x) 0
74 #ifndef TOINT_INTRINSICS
75 #define TOINT_INTRINSICS 0
79 /* Round x to nearest int in all rounding modes, ties have to be rounded
80 consistently with converttoint so the results match. If the result
81 would be outside of [-2^31, 2^31-1] then the semantics is unspecified. */
82 static double_t
roundtoint(double_t
);
84 /* Convert x to nearest int in all rounding modes, ties have to be rounded
85 consistently with roundtoint. If the result is not representible in an
86 int32_t then the semantics is unspecified. */
87 static int32_t converttoint(double_t
);
90 /* Helps static branch prediction so hot path can be better optimized. */
92 #define predict_true(x) __builtin_expect(!!(x), 1)
93 #define predict_false(x) __builtin_expect(x, 0)
95 #define predict_true(x) (x)
96 #define predict_false(x) (x)
99 /* Evaluate an expression as the specified type. With standard excess
100 precision handling a type cast or assignment is enough (with
101 -ffloat-store an assignment is required, in old compilers argument
102 passing and return statement may not drop excess precision). */
104 static inline float eval_as_float(float x
)
110 static inline double eval_as_double(double x
)
116 /* fp_barrier returns its input, but limits code transformations
117 as if it had a side-effect (e.g. observable io) and returned
118 an arbitrary value. */
121 #define fp_barrierf fp_barrierf
122 static inline float fp_barrierf(float x
)
124 volatile float y
= x
;
130 #define fp_barrier fp_barrier
131 static inline double fp_barrier(double x
)
133 volatile double y
= x
;
139 #define fp_barrierl fp_barrierl
140 static inline long double fp_barrierl(long double x
)
142 volatile long double y
= x
;
147 /* fp_force_eval ensures that the input value is computed when that's
148 otherwise unused. To prevent the constant folding of the input
149 expression, an additional fp_barrier may be needed or a compilation
150 mode that does so (e.g. -frounding-math in gcc). Then it can be
151 used to evaluate an expression for its fenv side-effects only. */
153 #ifndef fp_force_evalf
154 #define fp_force_evalf fp_force_evalf
155 static inline void fp_force_evalf(float x
)
162 #ifndef fp_force_eval
163 #define fp_force_eval fp_force_eval
164 static inline void fp_force_eval(double x
)
171 #ifndef fp_force_evall
172 #define fp_force_evall fp_force_evall
173 static inline void fp_force_evall(long double x
)
175 volatile long double y
;
180 #define FORCE_EVAL(x) do { \
181 if (sizeof(x) == sizeof(float)) { \
183 } else if (sizeof(x) == sizeof(double)) { \
190 #define asuint(f) ((union{float _f; uint32_t _i;}){f})._i
191 #define asfloat(i) ((union{uint32_t _i; float _f;}){i})._f
192 #define asuint64(f) ((union{double _f; uint64_t _i;}){f})._i
193 #define asdouble(i) ((union{uint64_t _i; double _f;}){i})._f
195 #define EXTRACT_WORDS(hi,lo,d) \
197 uint64_t __u = asuint64(d); \
199 (lo) = (uint32_t)__u; \
202 #define GET_HIGH_WORD(hi,d) \
204 (hi) = asuint64(d) >> 32; \
207 #define GET_LOW_WORD(lo,d) \
209 (lo) = (uint32_t)asuint64(d); \
212 #define INSERT_WORDS(d,hi,lo) \
214 (d) = asdouble(((uint64_t)(hi)<<32) | (uint32_t)(lo)); \
217 #define SET_HIGH_WORD(d,hi) \
218 INSERT_WORDS(d, hi, (uint32_t)asuint64(d))
220 #define SET_LOW_WORD(d,lo) \
221 INSERT_WORDS(d, asuint64(d)>>32, lo)
223 #define GET_FLOAT_WORD(w,d) \
228 #define SET_FLOAT_WORD(d,w) \
233 hidden
int __rem_pio2_large(double*,double*,int,int,int);
235 hidden
int __rem_pio2(double,double*);
236 hidden
double __sin(double,double,int);
237 hidden
double __cos(double,double);
238 hidden
double __tan(double,double,int);
239 hidden
double __expo2(double,double);
241 hidden
int __rem_pio2f(float,double*);
242 hidden
float __sindf(double);
243 hidden
float __cosdf(double);
244 hidden
float __tandf(double,int);
245 hidden
float __expo2f(float,float);
247 hidden
int __rem_pio2l(long double, long double *);
248 hidden
long double __sinl(long double, long double, int);
249 hidden
long double __cosl(long double, long double);
250 hidden
long double __tanl(long double, long double, int);
252 hidden
long double __polevll(long double, const long double *, int);
253 hidden
long double __p1evll(long double, const long double *, int);
255 extern int __signgam
;
256 hidden
double __lgamma_r(double, int *);
257 hidden
float __lgammaf_r(float, int *);
259 /* error handling functions */
260 hidden
float __math_xflowf(uint32_t, float);
261 hidden
float __math_uflowf(uint32_t);
262 hidden
float __math_oflowf(uint32_t);
263 hidden
float __math_divzerof(uint32_t);
264 hidden
float __math_invalidf(float);
265 hidden
double __math_xflow(uint32_t, double);
266 hidden
double __math_uflow(uint32_t);
267 hidden
double __math_oflow(uint32_t);
268 hidden
double __math_divzero(uint32_t);
269 hidden
double __math_invalid(double);