~steve-sk2/mingw-w64/oneiric

« back to all changes in this revision

Viewing changes to mingw-w64-headers/include/math.h

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Kitt
  • Date: 2010-11-18 00:04:46 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101118000446-xe24b423su55onyl
Tags: 1.0+20101003-1
* New maintainer. (Closes: #594371.)
* New upstream snapshot:
  - Includes getopt.h. (Closes: #569914.)
* Build g++ for Win64. (Closes: #600451.)
* Standards-Version 3.9.1 (new packaging).
* Include patch from
  http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64?view=revision&revision=3715
  as suggested by Rafaël Carré.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * This file has no copyright assigned and is placed in the Public Domain.
 
3
 * This file is part of the w64 mingw-runtime package.
 
4
 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 
5
 */
 
6
#ifndef _MATH_H_
 
7
#define _MATH_H_
 
8
 
 
9
#if __GNUC__ >= 3
 
10
#pragma GCC system_header
 
11
#endif
 
12
 
 
13
#include <_mingw.h>
 
14
 
 
15
struct _exception;
 
16
 
 
17
#pragma pack(push,_CRT_PACKING)
 
18
 
 
19
#define _DOMAIN         1       /* domain error in argument */
 
20
#define _SING           2       /* singularity */
 
21
#define _OVERFLOW       3       /* range overflow */
 
22
#define _UNDERFLOW      4       /* range underflow */
 
23
#define _TLOSS          5       /* total loss of precision */
 
24
#define _PLOSS          6       /* partial loss of precision */
 
25
 
 
26
#ifndef __STRICT_ANSI__
 
27
#ifndef NO_OLDNAMES
 
28
 
 
29
#define DOMAIN          _DOMAIN
 
30
#define SING            _SING
 
31
#define OVERFLOW        _OVERFLOW
 
32
#define UNDERFLOW       _UNDERFLOW
 
33
#define TLOSS           _TLOSS
 
34
#define PLOSS           _PLOSS
 
35
 
 
36
#endif
 
37
#endif
 
38
 
 
39
#ifndef __STRICT_ANSI__
 
40
#define M_E             2.7182818284590452354
 
41
#define M_LOG2E         1.4426950408889634074
 
42
#define M_LOG10E        0.43429448190325182765
 
43
#define M_LN2           0.69314718055994530942
 
44
#define M_LN10          2.30258509299404568402
 
45
#define M_PI            3.14159265358979323846
 
46
#define M_PI_2          1.57079632679489661923
 
47
#define M_PI_4          0.78539816339744830962
 
48
#define M_1_PI          0.31830988618379067154
 
49
#define M_2_PI          0.63661977236758134308
 
50
#define M_2_SQRTPI      1.12837916709551257390
 
51
#define M_SQRT2         1.41421356237309504880
 
52
#define M_SQRT1_2       0.70710678118654752440
 
53
#endif
 
54
 
 
55
#ifndef __STRICT_ANSI__
 
56
/* See also float.h  */
 
57
#ifndef __MINGW_FPCLASS_DEFINED
 
58
#define __MINGW_FPCLASS_DEFINED 1
 
59
/* IEEE 754 classication */
 
60
#define _FPCLASS_SNAN   0x0001  /* Signaling "Not a Number" */
 
61
#define _FPCLASS_QNAN   0x0002  /* Quiet "Not a Number" */
 
62
#define _FPCLASS_NINF   0x0004  /* Negative Infinity */
 
63
#define _FPCLASS_NN     0x0008  /* Negative Normal */
 
64
#define _FPCLASS_ND     0x0010  /* Negative Denormal */
 
65
#define _FPCLASS_NZ     0x0020  /* Negative Zero */
 
66
#define _FPCLASS_PZ     0x0040  /* Positive Zero */
 
67
#define _FPCLASS_PD     0x0080  /* Positive Denormal */
 
68
#define _FPCLASS_PN     0x0100  /* Positive Normal */
 
69
#define _FPCLASS_PINF   0x0200  /* Positive Infinity */
 
70
#endif
 
71
#endif
 
72
 
 
73
#ifndef RC_INVOKED
 
74
 
 
75
#ifdef __cplusplus
 
76
extern "C" {
 
77
#endif
 
78
 
 
79
#ifndef _HUGE
 
80
  extern double * __MINGW_IMP_SYMBOL(_HUGE);
 
81
#define _HUGE   (* __MINGW_IMP_SYMBOL(_HUGE))
 
82
#endif
 
83
 
 
84
#if __MINGW_GNUC_PREREQ(3, 3)
 
85
#define HUGE_VAL __builtin_huge_val()
 
86
#else
 
87
#define HUGE_VAL _HUGE
 
88
#endif
 
89
 
 
90
#ifndef _EXCEPTION_DEFINED
 
91
#define _EXCEPTION_DEFINED
 
92
  struct _exception {
 
93
    int type;
 
94
    char *name;
 
95
    double arg1;
 
96
    double arg2;
 
97
    double retval;
 
98
  };
 
99
#endif
 
100
 
 
101
  double __cdecl sin(double _X);
 
102
  double __cdecl cos(double _X);
 
103
  double __cdecl tan(double _X);
 
104
  double __cdecl sinh(double _X);
 
105
  double __cdecl cosh(double _X);
 
106
  double __cdecl tanh(double _X);
 
107
  double __cdecl asin(double _X);
 
108
  double __cdecl acos(double _X);
 
109
  double __cdecl atan(double _X);
 
110
  double __cdecl atan2(double _Y,double _X);
 
111
  double __cdecl exp(double _X);
 
112
  double __cdecl log(double _X);
 
113
  double __cdecl log10(double _X);
 
114
  double __cdecl pow(double _X,double _Y);
 
115
  double __cdecl sqrt(double _X);
 
116
  double __cdecl ceil(double _X);
 
117
  double __cdecl floor(double _X);
 
118
  double __cdecl fabs(double _X);
 
119
  double __cdecl ldexp(double _X,int _Y);
 
120
  double __cdecl frexp(double _X,int *_Y);
 
121
  double __cdecl modf(double _X,double *_Y);
 
122
  double __cdecl fmod(double _X,double _Y);
 
123
 
 
124
#ifndef _CRT_ABS_DEFINED
 
125
#define _CRT_ABS_DEFINED
 
126
  int __cdecl abs(int _X);
 
127
  long __cdecl labs(long _X);
 
128
#endif
 
129
#ifndef _CRT_ATOF_DEFINED
 
130
#define _CRT_ATOF_DEFINED
 
131
  double __cdecl atof(const char *_String);
 
132
  double __cdecl _atof_l(const char *_String,_locale_t _Locale);
 
133
#endif
 
134
 
 
135
#define EDOM 33
 
136
#define ERANGE 34
 
137
 
 
138
#ifndef __STRICT_ANSI__
 
139
 
 
140
#ifndef _COMPLEX_DEFINED
 
141
#define _COMPLEX_DEFINED
 
142
  struct _complex {
 
143
    double x;
 
144
    double y;
 
145
  };
 
146
#endif
 
147
 
 
148
  _CRTIMP double __cdecl _cabs(struct _complex _ComplexA);
 
149
  double __cdecl _hypot(double _X,double _Y);
 
150
  _CRTIMP double __cdecl _j0(double _X);
 
151
  _CRTIMP double __cdecl _j1(double _X);
 
152
  _CRTIMP double __cdecl _jn(int _X,double _Y);
 
153
  _CRTIMP double __cdecl _y0(double _X);
 
154
  _CRTIMP double __cdecl _y1(double _X);
 
155
  _CRTIMP double __cdecl _yn(int _X,double _Y);
 
156
#ifndef _CRT_MATHERR_DEFINED
 
157
#define _CRT_MATHERR_DEFINED
 
158
  _CRTIMP int __cdecl _matherr (struct _exception *);
 
159
#endif
 
160
 
 
161
/* These are also declared in Mingw float.h; needed here as well to work 
 
162
   around GCC build issues.  */
 
163
/* BEGIN FLOAT.H COPY */
 
164
/*
 
165
 * IEEE recommended functions
 
166
 */
 
167
#ifndef _SIGN_DEFINED
 
168
#define _SIGN_DEFINED
 
169
  _CRTIMP double __cdecl _chgsign (double _X);
 
170
  _CRTIMP double __cdecl _copysign (double _Number,double _Sign);
 
171
  _CRTIMP double __cdecl _logb (double);
 
172
  _CRTIMP double __cdecl _nextafter (double, double);
 
173
  _CRTIMP double __cdecl _scalb (double, long);
 
174
  _CRTIMP int __cdecl _finite (double);
 
175
  _CRTIMP int __cdecl _fpclass (double);
 
176
  _CRTIMP int __cdecl _isnan (double);
 
177
#endif
 
178
 
 
179
/* END FLOAT.H COPY */
 
180
 
 
181
#if !defined(NO_OLDNAMES)
 
182
 
 
183
_CRTIMP double __cdecl j0 (double);
 
184
_CRTIMP double __cdecl j1 (double);
 
185
_CRTIMP double __cdecl jn (int, double);
 
186
_CRTIMP double __cdecl y0 (double);
 
187
_CRTIMP double __cdecl y1 (double);
 
188
_CRTIMP double __cdecl yn (int, double);
 
189
 
 
190
_CRTIMP double __cdecl chgsign (double);
 
191
/*
 
192
 * scalb() is a GCC built-in.
 
193
 * Exclude this _scalb() stub; the semantics are incompatible
 
194
 * with the built-in implementation.
 
195
 *
 
196
_CRTIMP double __cdecl scalb (double, long);
 
197
 *
 
198
 */
 
199
  _CRTIMP int __cdecl finite (double);
 
200
  _CRTIMP int __cdecl fpclass (double);
 
201
 
 
202
#define FP_SNAN    _FPCLASS_SNAN
 
203
#define FP_QNAN    _FPCLASS_QNAN
 
204
#define FP_NINF    _FPCLASS_NINF
 
205
#define FP_PINF    _FPCLASS_PINF
 
206
#define FP_NDENORM _FPCLASS_ND
 
207
#define FP_PDENORM _FPCLASS_PD
 
208
#define FP_NZERO   _FPCLASS_NZ
 
209
#define FP_PZERO   _FPCLASS_PZ
 
210
#define FP_NNORM   _FPCLASS_NN
 
211
#define FP_PNORM   _FPCLASS_PN
 
212
 
 
213
#endif /* !defined (_NO_OLDNAMES) && !define (NO_OLDNAMES) */
 
214
 
 
215
#if(defined(_X86_) && !defined(__x86_64))
 
216
  _CRTIMP int __cdecl _set_SSE2_enable(int _Flag);
 
217
#endif
 
218
 
 
219
#endif
 
220
 
 
221
#ifndef __NO_ISOCEXT
 
222
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
 
223
        || !defined __STRICT_ANSI__ || defined __cplusplus
 
224
 
 
225
#if __MINGW_GNUC_PREREQ(3, 3)
 
226
#define HUGE_VALF       __builtin_huge_valf()
 
227
#define HUGE_VALL       __builtin_huge_vall()
 
228
#define INFINITY        __builtin_inf()
 
229
#define NAN             __builtin_nan("")
 
230
#else
 
231
extern const float __INFF;
 
232
#define HUGE_VALF __INFF
 
233
extern const long double  __INFL;
 
234
#define HUGE_VALL __INFL
 
235
#define INFINITY HUGE_VALF
 
236
extern const double __QNAN;
 
237
#define NAN __QNAN
 
238
#endif /* __MINGW_GNUC_PREREQ(3, 3) */
 
239
 
 
240
/* Use the compiler's builtin define for FLT_EVAL_METHOD to
 
241
   set float_t and double_t.  */
 
242
#if defined(__FLT_EVAL_METHOD__)  
 
243
# if ( __FLT_EVAL_METHOD__== 0)
 
244
typedef float float_t;
 
245
typedef double double_t;
 
246
# elif (__FLT_EVAL_METHOD__ == 1)
 
247
typedef double float_t;
 
248
typedef double double_t;
 
249
# elif (__FLT_EVAL_METHOD__ == 2)
 
250
typedef long double float_t;
 
251
typedef long double double_t;
 
252
#endif
 
253
#else /* ix87 FPU default */
 
254
typedef long double float_t;
 
255
typedef long double double_t;
 
256
#endif
 
257
 
 
258
/* 7.12.3.1 */
 
259
/*
 
260
   Return values for fpclassify.
 
261
   These are based on Intel x87 fpu condition codes
 
262
   in the high byte of status word and differ from
 
263
   the return values for MS IEEE 754 extension _fpclass()
 
264
*/
 
265
#define FP_NAN          0x0100
 
266
#define FP_NORMAL       0x0400
 
267
#define FP_INFINITE     (FP_NAN | FP_NORMAL)
 
268
#define FP_ZERO         0x4000
 
269
#define FP_SUBNORMAL    (FP_NORMAL | FP_ZERO)
 
270
/* 0x0200 is signbit mask */
 
271
 
 
272
/*
 
273
  We can't inline float or double, because we want to ensure truncation
 
274
  to semantic type before classification. 
 
275
  (A normal long double value might become subnormal when 
 
276
  converted to double, and zero when converted to float.)
 
277
*/
 
278
 
 
279
  extern int __cdecl __fpclassifyl (long double);
 
280
  extern int __cdecl __fpclassifyf (float);
 
281
  extern int __cdecl __fpclassify (double);
 
282
 
 
283
#ifndef __CRT__NO_INLINE
 
284
  __CRT_INLINE int __cdecl __fpclassifyl (long double x) {
 
285
    unsigned short sw;
 
286
    __asm__ __volatile__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x));
 
287
    return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
 
288
  }
 
289
  __CRT_INLINE int __cdecl __fpclassify (double x) {
 
290
    unsigned short sw;
 
291
    __asm__ __volatile__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x));
 
292
    return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
 
293
  }
 
294
  __CRT_INLINE int __cdecl __fpclassifyf (float x) {
 
295
    unsigned short sw;
 
296
    __asm__ __volatile__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x));
 
297
    return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
 
298
  }
 
299
#endif
 
300
 
 
301
#define fpclassify(x) (sizeof (x) == sizeof (float) ? __fpclassifyf (x)   \
 
302
  : sizeof (x) == sizeof (double) ? __fpclassify (x) \
 
303
  : __fpclassifyl (x))
 
304
 
 
305
/* 7.12.3.2 */
 
306
#define isfinite(x) ((fpclassify(x) & FP_NAN) == 0)
 
307
 
 
308
/* 7.12.3.3 */
 
309
#define isinf(x) (fpclassify(x) == FP_INFINITE)
 
310
 
 
311
/* 7.12.3.4 */
 
312
/* We don't need to worry about truncation here:
 
313
   A NaN stays a NaN. */
 
314
 
 
315
  extern int __cdecl __isnan (double);
 
316
  extern int __cdecl __isnanf (float);
 
317
  extern int __cdecl __isnanl (long double);
 
318
 
 
319
#ifndef __CRT__NO_INLINE
 
320
  __CRT_INLINE int __cdecl __isnan (double _x)
 
321
  {
 
322
    unsigned short sw;
 
323
    __asm__ __volatile__ ("fxam;"
 
324
      "fstsw %%ax": "=a" (sw) : "t" (_x));
 
325
    return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
 
326
      == FP_NAN;
 
327
  }
 
328
 
 
329
  __CRT_INLINE int __cdecl __isnanf (float _x)
 
330
  {
 
331
    unsigned short sw;
 
332
    __asm__ __volatile__ ("fxam;"
 
333
      "fstsw %%ax": "=a" (sw) : "t" (_x));
 
334
    return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
 
335
      == FP_NAN;
 
336
  }
 
337
 
 
338
  __CRT_INLINE int __cdecl __isnanl (long double _x)
 
339
  {
 
340
    unsigned short sw;
 
341
    __asm__ __volatile__ ("fxam;"
 
342
      "fstsw %%ax": "=a" (sw) : "t" (_x));
 
343
    return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
 
344
      == FP_NAN;
 
345
  }
 
346
#endif
 
347
 
 
348
#define isnan(x) (sizeof (x) == sizeof (float) ? __isnanf (x)   \
 
349
  : sizeof (x) == sizeof (double) ? __isnan (x) \
 
350
  : __isnanl (x))
 
351
 
 
352
/* 7.12.3.5 */
 
353
#define isnormal(x) (fpclassify(x) == FP_NORMAL)
 
354
 
 
355
/* 7.12.3.6 The signbit macro */
 
356
  extern int __cdecl __signbit (double);
 
357
  extern int __cdecl __signbitf (float);
 
358
  extern int __cdecl __signbitl (long double);
 
359
#ifndef __CRT__NO_INLINE
 
360
  __CRT_INLINE int __cdecl __signbit (double x) {
 
361
    unsigned short stw;
 
362
    __asm__ __volatile__ ( "fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
 
363
    return stw & 0x0200;
 
364
  }
 
365
 
 
366
  __CRT_INLINE int __cdecl __signbitf (float x) {
 
367
    unsigned short stw;
 
368
    __asm__ __volatile__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
 
369
    return stw & 0x0200;
 
370
  }
 
371
 
 
372
  __CRT_INLINE int __cdecl __signbitl (long double x) {
 
373
    unsigned short stw;
 
374
    __asm__ __volatile__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
 
375
    return stw & 0x0200;
 
376
  }
 
377
#endif
 
378
 
 
379
#define signbit(x) (sizeof (x) == sizeof (float) ? __signbitf (x)       \
 
380
  : sizeof (x) == sizeof (double) ? __signbit (x)       \
 
381
  : __signbitl (x))
 
382
 
 
383
/* 7.12.4 Trigonometric functions: Double in C89 */
 
384
  extern float __cdecl sinf(float _X);
 
385
  extern long double __cdecl sinl(long double);
 
386
 
 
387
  extern float __cdecl cosf(float _X);
 
388
  extern long double __cdecl cosl(long double);
 
389
 
 
390
  extern float __cdecl tanf(float _X);
 
391
  extern long double __cdecl tanl(long double);
 
392
  extern float __cdecl asinf(float _X);
 
393
  extern long double __cdecl asinl(long double);
 
394
 
 
395
  extern float __cdecl acosf (float);
 
396
  extern long double __cdecl acosl (long double);
 
397
 
 
398
  extern float __cdecl atanf (float);
 
399
  extern long double __cdecl atanl (long double);
 
400
 
 
401
  extern float __cdecl atan2f (float, float);
 
402
  extern long double __cdecl atan2l (long double, long double);
 
403
 
 
404
/* 7.12.5 Hyperbolic functions: Double in C89  */
 
405
  extern float __cdecl sinhf(float _X);
 
406
#ifndef __CRT__NO_INLINE
 
407
  __CRT_INLINE float sinhf(float _X) { return ((float)sinh((double)_X)); }
 
408
#endif
 
409
  extern long double __cdecl sinhl(long double);
 
410
 
 
411
  extern float __cdecl coshf(float _X);
 
412
#ifndef __CRT__NO_INLINE
 
413
  __CRT_INLINE float coshf(float _X) { return ((float)cosh((double)_X)); }
 
414
#endif
 
415
  extern long double __cdecl coshl(long double);
 
416
 
 
417
  extern float __cdecl tanhf(float _X);
 
418
#ifndef __CRT__NO_INLINE
 
419
  __CRT_INLINE float tanhf(float _X) { return ((float)tanh((double)_X)); }
 
420
#endif
 
421
  extern long double __cdecl tanhl(long double);
 
422
 
 
423
/* Inverse hyperbolic trig functions  */ 
 
424
/* 7.12.5.1 */
 
425
  extern double __cdecl acosh (double);
 
426
  extern float __cdecl acoshf (float);
 
427
  extern long double __cdecl acoshl (long double);
 
428
 
 
429
/* 7.12.5.2 */
 
430
  extern double __cdecl asinh (double);
 
431
  extern float __cdecl asinhf (float);
 
432
  extern long double __cdecl asinhl (long double);
 
433
 
 
434
/* 7.12.5.3 */
 
435
  extern double __cdecl atanh (double);
 
436
  extern float __cdecl atanhf  (float);
 
437
  extern long double __cdecl atanhl (long double);
 
438
 
 
439
/* Exponentials and logarithms  */
 
440
/* 7.12.6.1 Double in C89 */
 
441
  extern float __cdecl expf(float _X);
 
442
#ifndef __CRT__NO_INLINE
 
443
  __CRT_INLINE float expf(float _X) { return ((float)exp((double)_X)); }
 
444
#endif
 
445
  extern long double __cdecl expl(long double);
 
446
 
 
447
/* 7.12.6.2 */
 
448
  extern double __cdecl exp2(double);
 
449
  extern float __cdecl exp2f(float);
 
450
  extern long double __cdecl exp2l(long double);
 
451
 
 
452
/* 7.12.6.3 The expm1 functions */
 
453
/* TODO: These could be inlined */
 
454
  extern double __cdecl expm1(double);
 
455
  extern float __cdecl expm1f(float);
 
456
  extern long double __cdecl expm1l(long double);
 
457
 
 
458
/* 7.12.6.4 Double in C89 */
 
459
  extern float frexpf(float _X,int *_Y);
 
460
#ifndef __CRT__NO_INLINE
 
461
  __CRT_INLINE float frexpf(float _X,int *_Y) { return ((float)frexp((double)_X,_Y)); }
 
462
#endif
 
463
  extern long double __cdecl frexpl(long double,int *);
 
464
 
 
465
/* 7.12.6.5 */
 
466
#define FP_ILOGB0 ((int)0x80000000)
 
467
#define FP_ILOGBNAN ((int)0x80000000)
 
468
  extern int __cdecl ilogb (double);
 
469
  extern int __cdecl ilogbf (float);
 
470
  extern int __cdecl ilogbl (long double);
 
471
 
 
472
/* 7.12.6.6  Double in C89 */
 
473
  extern float __cdecl ldexpf(float _X,int _Y);
 
474
#ifndef __CRT__NO_INLINE
 
475
  __CRT_INLINE float __cdecl ldexpf (float x, int expn) { return (float) ldexp ((double)x, expn); }
 
476
#endif
 
477
  extern long double __cdecl ldexpl (long double, int);
 
478
 
 
479
/* 7.12.6.7 Double in C89 */
 
480
  extern float __cdecl logf (float);
 
481
  extern long double __cdecl logl(long double);
 
482
 
 
483
/* 7.12.6.8 Double in C89 */
 
484
  extern float __cdecl log10f (float);
 
485
  extern long double __cdecl log10l(long double);
 
486
 
 
487
/* 7.12.6.9 */
 
488
  extern double __cdecl log1p(double);
 
489
  extern float __cdecl log1pf(float);
 
490
  extern long double __cdecl log1pl(long double);
 
491
 
 
492
/* 7.12.6.10 */
 
493
  extern double __cdecl log2 (double);
 
494
  extern float __cdecl log2f (float);
 
495
  extern long double __cdecl log2l (long double);
 
496
 
 
497
/* 7.12.6.11 */
 
498
  extern double __cdecl logb (double);
 
499
  extern float __cdecl logbf (float);
 
500
  extern long double __cdecl logbl (long double);
 
501
 
 
502
/* Inline versions.  GCC-4.0+ can do a better fast-math optimization
 
503
   with __builtins. */
 
504
#ifndef __CRT__NO_INLINE
 
505
#if !(__MINGW_GNUC_PREREQ (4, 0) && defined (__FAST_MATH__))
 
506
  __CRT_INLINE double __cdecl logb (double x)
 
507
  {
 
508
    double res = 0.0;
 
509
    __asm__ __volatile__ ("fxtract\n\t"
 
510
      "fstp     %%st" : "=t" (res) : "0" (x));
 
511
    return res;
 
512
  }
 
513
 
 
514
  __CRT_INLINE float __cdecl logbf (float x)
 
515
  {
 
516
    float res = 0.0F;
 
517
    __asm__ __volatile__ ("fxtract\n\t"
 
518
      "fstp     %%st" : "=t" (res) : "0" (x));
 
519
    return res;
 
520
  }
 
521
 
 
522
  __CRT_INLINE long double __cdecl logbl (long double x)
 
523
  {
 
524
    long double res = 0.0l;
 
525
    __asm__ __volatile__ ("fxtract\n\t"
 
526
      "fstp     %%st" : "=t" (res) : "0" (x));
 
527
    return res;
 
528
  }
 
529
#endif /* !defined __FAST_MATH__ || !__MINGW_GNUC_PREREQ (4, 0) */
 
530
#endif /* __CRT__NO_INLINE */
 
531
 
 
532
/* 7.12.6.12  Double in C89 */
 
533
  extern float __cdecl modff (float, float*);
 
534
  extern long double __cdecl modfl (long double, long double*);
 
535
 
 
536
/* 7.12.6.13 */
 
537
  extern double __cdecl scalbn (double, int);
 
538
  extern float __cdecl scalbnf (float, int);
 
539
  extern long double __cdecl scalbnl (long double, int);
 
540
 
 
541
  extern double __cdecl scalbln (double, long);
 
542
  extern float __cdecl scalblnf (float, long);
 
543
  extern long double __cdecl scalblnl (long double, long);
 
544
 
 
545
/* 7.12.7.1 */
 
546
/* Implementations adapted from Cephes versions */ 
 
547
  extern double __cdecl cbrt (double);
 
548
  extern float __cdecl cbrtf (float);
 
549
  extern long double __cdecl cbrtl (long double);
 
550
 
 
551
/* 7.12.7.2 The fabs functions: Double in C89 */
 
552
  extern  float __cdecl fabsf (float x);
 
553
#ifndef __CRT__NO_INLINE
 
554
#if !defined (__ia64__)
 
555
  __CRT_INLINE float __cdecl fabsf (float x)
 
556
  {
 
557
    float res = 0.0F;
 
558
    __asm__ __volatile__ ("fabs;" : "=t" (res) : "0" (x));
 
559
    return res;
 
560
  }
 
561
#endif
 
562
#endif
 
563
  extern long double __cdecl fabsl (long double);
 
564
#ifndef __CRT__NO_INLINE
 
565
#if !defined (__ia64__)
 
566
  __CRT_INLINE long double __cdecl fabsl (long double x)
 
567
  {
 
568
    long double res = 0.0l;
 
569
    __asm__ __volatile__ ("fabs;" : "=t" (res) : "0" (x));
 
570
    return res;
 
571
  }
 
572
#endif
 
573
#endif
 
574
/* 7.12.7.3  */
 
575
  extern double __cdecl hypot (double, double); /* in libmoldname.a */
 
576
  extern float __cdecl hypotf (float x, float y);
 
577
#ifndef __CRT__NO_INLINE
 
578
  __CRT_INLINE float __cdecl hypotf (float x, float y) { return (float) hypot ((double)x, (double)y);}
 
579
#endif
 
580
  extern long double __cdecl hypotl (long double, long double);
 
581
 
 
582
/* 7.12.7.4 The pow functions. Double in C89 */
 
583
  extern float __cdecl powf(float _X,float _Y);
 
584
#ifndef __CRT__NO_INLINE
 
585
  __CRT_INLINE float powf(float _X,float _Y) { return ((float)pow((double)_X,(double)_Y)); }
 
586
#endif
 
587
  extern long double __cdecl powl (long double, long double);
 
588
 
 
589
/* 7.12.7.5 The sqrt functions. Double in C89. */
 
590
  extern float __cdecl sqrtf (float);
 
591
  extern long double sqrtl(long double);
 
592
 
 
593
/* 7.12.8.1 The erf functions  */
 
594
  extern double __cdecl erf (double);
 
595
  extern float __cdecl erff (float);
 
596
  extern long double __cdecl erfl (long double);
 
597
 
 
598
/* 7.12.8.2 The erfc functions  */
 
599
  extern double __cdecl erfc (double);
 
600
  extern float __cdecl erfcf (float);
 
601
  extern long double __cdecl erfcl (long double);
 
602
 
 
603
/* 7.12.8.3 The lgamma functions */
 
604
  extern double __cdecl lgamma (double);
 
605
  extern float __cdecl lgammaf (float);
 
606
  extern long double __cdecl lgammal (long double);
 
607
 
 
608
/* 7.12.8.4 The tgamma functions */
 
609
  extern double __cdecl tgamma (double);
 
610
  extern float __cdecl tgammaf (float);
 
611
  extern long double __cdecl tgammal (long double);
 
612
 
 
613
/* 7.12.9.1 Double in C89 */
 
614
  extern float __cdecl ceilf (float);
 
615
  extern long double __cdecl ceill (long double);
 
616
 
 
617
/* 7.12.9.2 Double in C89 */
 
618
  extern float __cdecl floorf (float);
 
619
  extern long double __cdecl floorl (long double);
 
620
 
 
621
/* 7.12.9.3 */
 
622
  extern double __cdecl nearbyint ( double);
 
623
  extern float __cdecl nearbyintf (float);
 
624
  extern long double __cdecl nearbyintl (long double);
 
625
 
 
626
/* 7.12.9.4 */
 
627
/* round, using fpu control word settings */
 
628
extern double __cdecl rint (double);
 
629
extern float __cdecl rintf (float);
 
630
extern long double __cdecl rintl (long double);
 
631
 
 
632
/* 7.12.9.5 */
 
633
extern long __cdecl lrint (double);
 
634
extern long __cdecl lrintf (float);
 
635
extern long __cdecl lrintl (long double);
 
636
 
 
637
__MINGW_EXTENSION long long __cdecl llrint (double);
 
638
__MINGW_EXTENSION long long __cdecl llrintf (float);
 
639
__MINGW_EXTENSION long long __cdecl llrintl (long double);
 
640
 
 
641
/* Inline versions of above. 
 
642
   GCC 4.0+ can do a better fast-math job with __builtins. */
 
643
 
 
644
#ifndef __CRT__NO_INLINE
 
645
#if !(__MINGW_GNUC_PREREQ (4, 0) && defined __FAST_MATH__ )
 
646
  __CRT_INLINE double __cdecl rint (double x)
 
647
  {
 
648
    double retval = 0.0;
 
649
    __asm__ __volatile__ ("frndint;": "=t" (retval) : "0" (x));
 
650
    return retval;
 
651
  }
 
652
 
 
653
  __CRT_INLINE float __cdecl rintf (float x)
 
654
  {
 
655
    float retval = 0.0;
 
656
    __asm__ __volatile__ ("frndint;" : "=t" (retval) : "0" (x) );
 
657
    return retval;
 
658
  }
 
659
 
 
660
  __CRT_INLINE long double __cdecl rintl (long double x)
 
661
  {
 
662
    long double retval = 0.0l;
 
663
    __asm__ __volatile__ ("frndint;" : "=t" (retval) : "0" (x) );
 
664
    return retval;
 
665
  }
 
666
 
 
667
  __CRT_INLINE long __cdecl lrint (double x) 
 
668
  {
 
669
    long retval = 0;
 
670
    __asm__ __volatile__                                                              \
 
671
      ("fistpl %0"  : "=m" (retval) : "t" (x) : "st");                                \
 
672
      return retval;
 
673
  }
 
674
 
 
675
  __CRT_INLINE long __cdecl lrintf (float x) 
 
676
  {
 
677
    long retval = 0;
 
678
    __asm__ __volatile__                                                              \
 
679
      ("fistpl %0"  : "=m" (retval) : "t" (x) : "st");                                \
 
680
      return retval;
 
681
  }
 
682
 
 
683
  __CRT_INLINE long __cdecl lrintl (long double x) 
 
684
  {
 
685
    long retval = 0;
 
686
    __asm__ __volatile__                                                              \
 
687
      ("fistpl %0"  : "=m" (retval) : "t" (x) : "st");                                \
 
688
      return retval;
 
689
  }
 
690
 
 
691
  __MINGW_EXTENSION __CRT_INLINE long long __cdecl llrint (double x) 
 
692
  {
 
693
    __MINGW_EXTENSION long long retval = 0ll;
 
694
    __asm__ __volatile__                                                              \
 
695
      ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");                               \
 
696
      return retval;
 
697
  }
 
698
 
 
699
  __MINGW_EXTENSION __CRT_INLINE long long __cdecl llrintf (float x) 
 
700
  {
 
701
    __MINGW_EXTENSION long long retval = 0ll;
 
702
    __asm__ __volatile__                                                              \
 
703
      ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");                               \
 
704
      return retval;
 
705
  }
 
706
 
 
707
  __MINGW_EXTENSION __CRT_INLINE long long __cdecl llrintl (long double x) 
 
708
  {
 
709
    __MINGW_EXTENSION long long retval = 0ll;
 
710
    __asm__ __volatile__                                                              \
 
711
      ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");                               \
 
712
      return retval;
 
713
  }
 
714
#endif /* !__FAST_MATH__ || !__MINGW_GNUC_PREREQ (4,0)  */
 
715
#endif /* !__CRT__NO_INLINE */
 
716
 
 
717
/* 7.12.9.6 */
 
718
/* round away from zero, regardless of fpu control word settings */
 
719
  extern double __cdecl round (double);
 
720
  extern float __cdecl roundf (float);
 
721
  extern long double __cdecl roundl (long double);
 
722
 
 
723
/* 7.12.9.7  */
 
724
  extern long __cdecl lround (double);
 
725
  extern long __cdecl lroundf (float);
 
726
  extern long __cdecl lroundl (long double);
 
727
  __MINGW_EXTENSION long long __cdecl llround (double);
 
728
  __MINGW_EXTENSION long long __cdecl llroundf (float);
 
729
  __MINGW_EXTENSION long long __cdecl llroundl (long double);
 
730
  
 
731
/* 7.12.9.8 */
 
732
/* round towards zero, regardless of fpu control word settings */
 
733
  extern double __cdecl trunc (double);
 
734
  extern float __cdecl truncf (float);
 
735
  extern long double __cdecl truncl (long double);
 
736
 
 
737
/* 7.12.10.1 Double in C89 */
 
738
  extern float __cdecl fmodf (float, float);
 
739
  extern long double __cdecl fmodl (long double, long double);
 
740
 
 
741
/* 7.12.10.2 */ 
 
742
  extern double __cdecl remainder (double, double);
 
743
  extern float __cdecl remainderf (float, float);
 
744
  extern long double __cdecl remainderl (long double, long double);
 
745
 
 
746
/* 7.12.10.3 */
 
747
  extern double __cdecl remquo(double, double, int *);
 
748
  extern float __cdecl remquof(float, float, int *);
 
749
  extern long double __cdecl remquol(long double, long double, int *);
 
750
 
 
751
/* 7.12.11.1 */
 
752
  extern double __cdecl copysign (double, double); /* in libmoldname.a */
 
753
  extern float __cdecl copysignf (float, float);
 
754
  extern long double __cdecl copysignl (long double, long double);
 
755
 
 
756
/* 7.12.11.2 Return a NaN */
 
757
  extern double __cdecl nan(const char *tagp);
 
758
  extern float __cdecl nanf(const char *tagp);
 
759
  extern long double __cdecl nanl(const char *tagp);
 
760
 
 
761
#ifndef __STRICT_ANSI__
 
762
#define _nan() nan("")
 
763
#define _nanf() nanf("")
 
764
#define _nanl() nanl("")
 
765
#endif
 
766
 
 
767
/* 7.12.11.3 */
 
768
  extern double __cdecl nextafter (double, double); /* in libmoldname.a */
 
769
  extern float __cdecl nextafterf (float, float);
 
770
  extern long double __cdecl nextafterl (long double, long double);
 
771
 
 
772
/* 7.12.11.4 The nexttoward functions */
 
773
  extern double __cdecl nexttoward (double,  long double);
 
774
  extern float __cdecl nexttowardf (float,  long double);
 
775
  extern long double __cdecl nexttowardl (long double, long double);
 
776
 
 
777
/* 7.12.12.1 */
 
778
/*  x > y ? (x - y) : 0.0  */
 
779
  extern double __cdecl fdim (double x, double y);
 
780
  extern float __cdecl fdimf (float x, float y);
 
781
  extern long double __cdecl fdiml (long double x, long double y);
 
782
 
 
783
/* fmax and fmin.
 
784
   NaN arguments are treated as missing data: if one argument is a NaN
 
785
   and the other numeric, then these functions choose the numeric
 
786
   value. */
 
787
 
 
788
/* 7.12.12.2 */
 
789
  extern double __cdecl fmax  (double, double);
 
790
  extern float __cdecl fmaxf (float, float);
 
791
  extern long double __cdecl fmaxl (long double, long double);
 
792
 
 
793
/* 7.12.12.3 */
 
794
  extern double __cdecl fmin (double, double);
 
795
  extern float __cdecl fminf (float, float);
 
796
  extern long double __cdecl fminl (long double, long double);
 
797
 
 
798
/* 7.12.13.1 */
 
799
/* return x * y + z as a ternary op */ 
 
800
  extern double __cdecl fma (double, double, double);
 
801
  extern float __cdecl fmaf (float, float, float);
 
802
  extern long double __cdecl fmal (long double, long double, long double);
 
803
 
 
804
/* 7.12.14 */
 
805
/* 
 
806
 *  With these functions, comparisons involving quiet NaNs set the FP
 
807
 *  condition code to "unordered".  The IEEE floating-point spec
 
808
 *  dictates that the result of floating-point comparisons should be
 
809
 *  false whenever a NaN is involved, with the exception of the != op, 
 
810
 *  which always returns true: yes, (NaN != NaN) is true).
 
811
 */
 
812
 
 
813
#if __GNUC__ >= 3
 
814
 
 
815
#define isgreater(x, y) __builtin_isgreater(x, y)
 
816
#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
 
817
#define isless(x, y) __builtin_isless(x, y)
 
818
#define islessequal(x, y) __builtin_islessequal(x, y)
 
819
#define islessgreater(x, y) __builtin_islessgreater(x, y)
 
820
#define isunordered(x, y) __builtin_isunordered(x, y)
 
821
 
 
822
#else
 
823
/*  helper  */
 
824
#ifndef __CRT__NO_INLINE
 
825
  __CRT_INLINE int  __cdecl
 
826
    __fp_unordered_compare (long double x, long double y){
 
827
      unsigned short retval;
 
828
      __asm__ __volatile__ ("fucom %%st(1);"
 
829
        "fnstsw;": "=a" (retval) : "t" (x), "u" (y));
 
830
      return retval;
 
831
  }
 
832
#endif
 
833
 
 
834
#define isgreater(x, y) ((__fp_unordered_compare(x, y)  & 0x4500) == 0)
 
835
#define isless(x, y) ((__fp_unordered_compare (y, x)  & 0x4500) == 0)
 
836
#define isgreaterequal(x, y) ((__fp_unordered_compare (x, y)  & FP_INFINITE) == 0)
 
837
#define islessequal(x, y) ((__fp_unordered_compare(y, x)  & FP_INFINITE) == 0)
 
838
#define islessgreater(x, y) ((__fp_unordered_compare(x, y)  & FP_SUBNORMAL) == 0)
 
839
#define isunordered(x, y) ((__fp_unordered_compare(x, y)  & 0x4500) == 0x4500)
 
840
 
 
841
#endif
 
842
 
 
843
#endif /* __STDC_VERSION__ >= 199901L */
 
844
#endif /* __NO_ISOCEXT */
 
845
 
 
846
#if defined(_X86_) && !defined(__x86_64)
 
847
  _CRTIMP float __cdecl _hypotf(float _X,float _Y);
 
848
#endif
 
849
 
 
850
#if !defined(__ia64__)
 
851
   _CRTIMP float __cdecl _copysignf (float _Number,float _Sign);
 
852
   _CRTIMP float __cdecl _chgsignf (float _X);
 
853
   _CRTIMP float __cdecl _logbf(float _X);
 
854
   _CRTIMP float __cdecl _nextafterf(float _X,float _Y);
 
855
   _CRTIMP int __cdecl _finitef(float _X);
 
856
   _CRTIMP int __cdecl _isnanf(float _X);
 
857
   _CRTIMP int __cdecl _fpclassf(float _X);
 
858
#endif
 
859
 
 
860
#ifdef _SIGN_DEFINED
 
861
   extern long double __cdecl _chgsignl (long double);
 
862
#define _copysignl copysignl
 
863
#endif /* _SIGN_DEFINED */
 
864
 
 
865
#define _hypotl hypotl
 
866
 
 
867
#ifndef NO_OLDNAMES
 
868
#define matherr _matherr
 
869
#define HUGE    _HUGE
 
870
#endif
 
871
 
 
872
#ifdef __cplusplus
 
873
}
 
874
#endif
 
875
 
 
876
#endif  /* Not RC_INVOKED */
 
877
 
 
878
#pragma pack(pop)
 
879
 
 
880
#endif /* End _MATH_H_ */
 
881