167
162
extern double __ieee754_fmod (double,double) attribute_hidden;
168
163
extern double __ieee754_pow (double,double) attribute_hidden;
169
164
extern double __ieee754_lgamma_r (double,int *) attribute_hidden;
170
extern double __ieee754_gamma_r (double,int *) attribute_hidden;
165
/*extern double __ieee754_gamma_r (double,int *) attribute_hidden;*/
171
166
extern double __ieee754_lgamma (double) attribute_hidden;
172
extern double __ieee754_gamma (double) attribute_hidden;
167
/*extern double __ieee754_gamma (double) attribute_hidden;*/
173
168
extern double __ieee754_log10 (double) attribute_hidden;
174
169
extern double __ieee754_sinh (double) attribute_hidden;
175
170
extern double __ieee754_hypot (double,double) attribute_hidden;
181
176
extern double __ieee754_yn (int,double) attribute_hidden;
182
177
extern double __ieee754_remainder (double,double) attribute_hidden;
183
178
extern int __ieee754_rem_pio2 (double,double*) attribute_hidden;
184
#if defined(_SCALB_INT)
185
extern double __ieee754_scalb (double,int) attribute_hidden;
187
179
extern double __ieee754_scalb (double,double) attribute_hidden;
190
181
/* fdlibm kernel function */
191
182
#ifndef _IEEE_LIBM
196
187
extern double __kernel_tan (double,double,int) attribute_hidden;
197
188
extern int __kernel_rem_pio2 (double*,double*,int,int,int,const int*) attribute_hidden;
191
* math_opt_barrier(x): safely load x, even if it was manipulated
192
* by non-floationg point operations. This macro returns the value of x.
193
* This ensures compiler does not (ab)use its knowledge about x value
194
* and don't optimize future operations. Example:
196
* SET_FLOAT_WORD(x, 0x80000001); // sets a bit pattern
197
* y = math_opt_barrier(x); // "compiler, do not cheat!"
198
* y = y * y; // compiler can't optimize, must use real multiply insn
200
* math_force_eval(x): force expression x to be evaluated.
201
* Useful if otherwise compiler may eliminate the expression
202
* as unused. This macro returns no value.
203
* Example: "void fn(float f) { f = f * f; }"
204
* versus "void fn(float f) { f = f * f; math_force_eval(f); }"
206
* Currently, math_force_eval(x) stores x into
207
* a floating point register or memory *of the appropriate size*.
208
* There is no guarantee this will not change.
210
#if defined(__i386__)
211
#define math_opt_barrier(x) ({ \
212
__typeof(x) __x = (x); \
213
/* "t": load x into top-of-stack fpreg */ \
214
__asm__ ("" : "=t" (__x) : "0" (__x)); \
217
#define math_force_eval(x) do { \
218
__typeof(x) __x = (x); \
219
if (sizeof(__x) <= sizeof(double)) \
220
/* "m": store x into a memory location */ \
221
__asm__ __volatile__ ("" : : "m" (__x)); \
222
else /* long double */ \
223
/* "f": load x into (any) fpreg */ \
224
__asm__ __volatile__ ("" : : "f" (__x)); \
228
#if defined(__x86_64__)
229
#define math_opt_barrier(x) ({ \
230
__typeof(x) __x = (x); \
231
if (sizeof(__x) <= sizeof(double)) \
232
/* "x": load into XMM SSE register */ \
233
__asm__ ("" : "=x" (__x) : "0" (__x)); \
234
else /* long double */ \
235
/* "t": load x into top-of-stack fpreg */ \
236
__asm__ ("" : "=t" (__x) : "0" (__x)); \
239
#define math_force_eval(x) do { \
240
__typeof(x) __x = (x); \
241
if (sizeof(__x) <= sizeof(double)) \
242
/* "x": load into XMM SSE register */ \
243
__asm__ __volatile__ ("" : : "x" (__x)); \
244
else /* long double */ \
245
/* "f": load x into (any) fpreg */ \
246
__asm__ __volatile__ ("" : : "f" (__x)); \
250
/* Default implementations force store to a memory location */
251
#ifndef math_opt_barrier
252
#define math_opt_barrier(x) ({ __typeof(x) __x = (x); __asm__ ("" : "+m" (__x)); __x; })
254
#ifndef math_force_eval
255
#define math_force_eval(x) do { __typeof(x) __x = (x); __asm__ __volatile__ ("" : : "m" (__x)); } while (0)
199
259
#endif /* _MATH_PRIVATE_H_ */