~ubuntu-branches/ubuntu/quantal/uclibc/quantal

« back to all changes in this revision

Viewing changes to libm/math_private.h

  • Committer: Bazaar Package Importer
  • Author(s): Hector Oron
  • Date: 2011-06-11 03:06:20 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110611030620-ywjfvyuqvrpsm282
Tags: 0.9.32-1
* New upstream release
* Add myself as maintainer
* Bump standards version 
* Add Vcs-Git, Vcs-Browser and Homepage fields
* Add watch file 

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 * ====================================================
10
10
 */
11
11
 
12
 
/*
13
 
 * from: @(#)fdlibm.h 5.1 93/09/24
14
 
 * $Id: math_private.h,v 1.3 2004/02/09 07:10:38 andersen Exp $
15
 
 */
16
 
 
17
12
#ifndef _MATH_PRIVATE_H_
18
13
#define _MATH_PRIVATE_H_
19
14
 
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;
186
 
#else
187
179
extern double __ieee754_scalb (double,double) attribute_hidden;
188
 
#endif
189
180
 
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;
198
189
 
 
190
/*
 
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:
 
195
 * float x;
 
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
 
199
 *
 
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); }"
 
205
 *
 
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.
 
209
 */
 
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)); \
 
215
        __x; \
 
216
})
 
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)); \
 
225
} while (0)
 
226
#endif
 
227
 
 
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)); \
 
237
        __x; \
 
238
})
 
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)); \
 
247
} while (0)
 
248
#endif
 
249
 
 
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; })
 
253
#endif
 
254
#ifndef math_force_eval
 
255
#define math_force_eval(x)  do { __typeof(x) __x = (x); __asm__ __volatile__ ("" : : "m" (__x)); } while (0)
 
256
#endif
 
257
 
 
258
 
199
259
#endif /* _MATH_PRIVATE_H_ */