master
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 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#ifdef __GNUC__
10#pragma GCC system_header
11#endif /* __GNUC__ */
12
13#include <crtdefs.h>
14
15struct _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#if !defined(__STRICT_ANSI__) || defined(_POSIX_C_SOURCE) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_USE_MATH_DEFINES)
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/* See also float.h */
56#ifndef __MINGW_FPCLASS_DEFINED
57#define __MINGW_FPCLASS_DEFINED 1
58/* IEEE 754 classication */
59#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
60#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
61#define _FPCLASS_NINF 0x0004 /* Negative Infinity */
62#define _FPCLASS_NN 0x0008 /* Negative Normal */
63#define _FPCLASS_ND 0x0010 /* Negative Denormal */
64#define _FPCLASS_NZ 0x0020 /* Negative Zero */
65#define _FPCLASS_PZ 0x0040 /* Positive Zero */
66#define _FPCLASS_PD 0x0080 /* Positive Denormal */
67#define _FPCLASS_PN 0x0100 /* Positive Normal */
68#define _FPCLASS_PINF 0x0200 /* Positive Infinity */
69#endif
70
71#ifndef RC_INVOKED
72
73#ifndef __mingw_types_compatible_p
74#ifdef __cplusplus
75extern "C++" {
76template <typename type1, typename type2> struct __mingw_types_compatible_p {
77 static const bool result = false;
78};
79
80template <typename type1> struct __mingw_types_compatible_p<type1, type1> {
81 static const bool result = true;
82};
83
84template <typename type1> struct __mingw_types_compatible_p<const type1, type1> {
85 static const bool result = true;
86};
87
88template <typename type1> struct __mingw_types_compatible_p<type1, const type1> {
89 static const bool result = true;
90};
91}
92
93#define __mingw_types_compatible_p(type1, type2) __mingw_types_compatible_p <type1, type2>::result
94#else
95#define __mingw_types_compatible_p(type1, type2) __builtin_types_compatible_p (type1, type2)
96#endif
97#endif
98
99#ifndef __mingw_choose_expr
100#ifdef __cplusplus
101#define __mingw_choose_expr(C, E1, E2) ((C) ? E1 : E2)
102#else
103#define __mingw_choose_expr __builtin_choose_expr
104#endif
105#endif
106
107
108#ifdef __cplusplus
109extern "C" {
110#endif
111
112#ifndef __MINGW_SOFTMATH
113#define __MINGW_SOFTMATH
114
115/* IEEE float/double type shapes. */
116
117 typedef union __mingw_dbl_type_t {
118 double x;
119 unsigned long long val;
120 __C89_NAMELESS struct {
121 unsigned int low, high;
122 } lh;
123 } __mingw_dbl_type_t;
124
125 typedef union __mingw_flt_type_t {
126 float x;
127 unsigned int val;
128 } __mingw_flt_type_t;
129
130 typedef union __mingw_ldbl_type_t
131 {
132 long double x;
133 __C89_NAMELESS struct {
134 unsigned int low, high;
135 int sign_exponent : 16;
136 int res1 : 16;
137 int res0 : 32;
138 } lh;
139 } __mingw_ldbl_type_t;
140
141#endif
142
143#ifndef _HUGE
144 extern double * __MINGW_IMP_SYMBOL(_HUGE);
145#define _HUGE (* __MINGW_IMP_SYMBOL(_HUGE))
146#endif
147
148#ifdef __GNUC__
149#define HUGE_VAL __builtin_huge_val()
150#else
151#define HUGE_VAL _HUGE
152#endif /* __GNUC__ */
153
154#ifndef _EXCEPTION_DEFINED
155#define _EXCEPTION_DEFINED
156 struct _exception {
157 int type;
158 const char *name;
159 double arg1;
160 double arg2;
161 double retval;
162 };
163
164 void __mingw_raise_matherr (int typ, const char *name, double a1, double a2,
165 double rslt);
166 void __mingw_setusermatherr (int (__cdecl *)(struct _exception *));
167 _CRTIMP void __setusermatherr(int (__cdecl *)(struct _exception *));
168 #define __setusermatherr __mingw_setusermatherr
169#endif
170
171 double __cdecl sin(double _X);
172 double __cdecl cos(double _X);
173 double __cdecl tan(double _X);
174 double __cdecl sinh(double _X);
175 double __cdecl cosh(double _X);
176 double __cdecl tanh(double _X);
177 double __cdecl asin(double _X);
178 double __cdecl acos(double _X);
179 double __cdecl atan(double _X);
180 double __cdecl atan2(double _Y,double _X);
181 double __cdecl exp(double _X);
182 double __cdecl log(double _X);
183 double __cdecl log10(double _X);
184 double __cdecl pow(double _X,double _Y);
185 double __cdecl sqrt(double _X);
186 double __cdecl ceil(double _X);
187 double __cdecl floor(double _X);
188
189/* 7.12.7.2 The fabs functions: Double in C89 */
190 extern float __cdecl fabsf (float x);
191 extern long double __cdecl fabsl (long double);
192 extern double __cdecl fabs (double _X);
193
194#ifndef __CRT__NO_INLINE
195#if !defined (__ia64__)
196 __CRT_INLINE float __cdecl fabsf (float x)
197 {
198#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
199 return __builtin_fabsf (x);
200#else
201 float res = 0.0F;
202 __asm__ __volatile__ ("fabs;" : "=t" (res) : "0" (x));
203 return res;
204#endif
205 }
206
207 __CRT_INLINE long double __cdecl fabsl (long double x)
208 {
209#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
210 return __builtin_fabsl (x);
211#else
212 long double res = 0.0l;
213 __asm__ __volatile__ ("fabs;" : "=t" (res) : "0" (x));
214 return res;
215#endif
216 }
217
218 __CRT_INLINE double __cdecl fabs (double x)
219 {
220#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
221 return __builtin_fabs (x);
222#else
223 double res = 0.0;
224 __asm__ __volatile__ ("fabs;" : "=t" (res) : "0" (x));
225 return res;
226#endif
227 }
228#endif
229#endif
230
231 double __cdecl ldexp(double _X,int _Y);
232 double __cdecl frexp(double _X,int *_Y);
233 double __cdecl modf(double _X,double *_Y);
234 double __cdecl fmod(double _X,double _Y);
235
236 void __cdecl sincos (double __x, double *p_sin, double *p_cos);
237 void __cdecl sincosl (long double __x, long double *p_sin, long double *p_cos);
238 void __cdecl sincosf (float __x, float *p_sin, float *p_cos);
239
240#ifndef _CRT_ABS_DEFINED
241#define _CRT_ABS_DEFINED
242 int __cdecl abs(int _X);
243 long __cdecl labs(long _X);
244#endif
245#ifndef _CRT_ATOF_DEFINED
246#define _CRT_ATOF_DEFINED
247 double __cdecl atof(const char *_String);
248 double __cdecl _atof_l(const char *_String,_locale_t _Locale);
249#endif
250
251#define EDOM 33
252#define ERANGE 34
253
254#ifndef _COMPLEX_DEFINED
255#define _COMPLEX_DEFINED
256 struct _complex {
257 double x;
258 double y;
259 };
260#endif
261
262 double __cdecl _cabs(struct _complex _ComplexA); /* Overridden to use our cabs. */
263 double __cdecl _hypot(double _X,double _Y);
264 _CRTIMP double __cdecl _j0(double _X);
265 _CRTIMP double __cdecl _j1(double _X);
266 _CRTIMP double __cdecl _jn(int _X,double _Y);
267 _CRTIMP double __cdecl _y0(double _X);
268 _CRTIMP double __cdecl _y1(double _X);
269 _CRTIMP double __cdecl _yn(int _X,double _Y);
270#ifndef _CRT_MATHERR_DEFINED
271#define _CRT_MATHERR_DEFINED
272 _CRTIMP int __cdecl _matherr (struct _exception *);
273#endif
274
275/* These are also declared in Mingw float.h; needed here as well to work
276 around GCC build issues. */
277/* BEGIN FLOAT.H COPY */
278/*
279 * IEEE recommended functions
280 */
281#ifndef _SIGN_DEFINED
282#define _SIGN_DEFINED
283 _CRTIMP double __cdecl _chgsign (double _X);
284 _CRTIMP double __cdecl _copysign (double _Number,double _Sign);
285 _CRTIMP double __cdecl _logb (double);
286 _CRTIMP double __cdecl _nextafter (double, double);
287 _CRTIMP double __cdecl _scalb (double, long);
288 _CRTIMP int __cdecl _finite (double);
289 _CRTIMP int __cdecl _fpclass (double);
290 _CRTIMP int __cdecl _isnan (double);
291#endif
292
293/* END FLOAT.H COPY */
294
295#if !defined(__STRICT_ANSI__) || defined(_POSIX_C_SOURCE) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
296
297_CRTIMP double __cdecl j0 (double) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
298_CRTIMP double __cdecl j1 (double) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
299_CRTIMP double __cdecl jn (int, double) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
300_CRTIMP double __cdecl y0 (double) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
301_CRTIMP double __cdecl y1 (double) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
302_CRTIMP double __cdecl yn (int, double) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
303
304#if !defined(NO_OLDNAMES)
305
306_CRTIMP double __cdecl chgsign (double);
307/*
308 * scalb() is a GCC built-in.
309 * Exclude this _scalb() stub; the semantics are incompatible
310 * with the built-in implementation.
311 *
312_CRTIMP double __cdecl scalb (double, long);
313 *
314 */
315 _CRTIMP int __cdecl finite (double);
316 _CRTIMP int __cdecl fpclass (double);
317
318#define FP_SNAN _FPCLASS_SNAN
319#define FP_QNAN _FPCLASS_QNAN
320#define FP_NINF _FPCLASS_NINF
321#define FP_PINF _FPCLASS_PINF
322#define FP_NDENORM _FPCLASS_ND
323#define FP_PDENORM _FPCLASS_PD
324#define FP_NZERO _FPCLASS_NZ
325#define FP_PZERO _FPCLASS_PZ
326#define FP_NNORM _FPCLASS_NN
327#define FP_PNORM _FPCLASS_PN
328
329#endif /* !define (NO_OLDNAMES) */
330#endif
331
332#if(defined(_X86_) && !defined(__x86_64))
333 _CRTIMP int __cdecl _set_SSE2_enable(int _Flag);
334#endif
335
336#ifndef __NO_ISOCEXT
337#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
338 || !defined __STRICT_ANSI__ || defined __cplusplus
339
340#ifdef __GNUC__
341#define HUGE_VALF __builtin_huge_valf()
342#define HUGE_VALL __builtin_huge_vall()
343#define INFINITY __builtin_inff()
344#define NAN __builtin_nanf("")
345#else
346extern const float __INFF;
347#define HUGE_VALF __INFF
348extern const long double __INFL;
349#define HUGE_VALL __INFL
350#define INFINITY HUGE_VALF
351extern const double __QNANF;
352#define NAN __QNANF
353#endif /* __GNUC__ */
354
355/* Use the compiler's builtin define for FLT_EVAL_METHOD to
356 set float_t and double_t. */
357#if defined (__x86_64__) || defined(__FLT_EVAL_METHOD__)
358# if defined (__x86_64__) || ( __FLT_EVAL_METHOD__== 0)
359typedef float float_t;
360typedef double double_t;
361# elif (__FLT_EVAL_METHOD__ == 1)
362typedef double float_t;
363typedef double double_t;
364# else /* (__FLT_EVAL_METHOD__ == 2) default ix87 FPU */
365typedef long double float_t;
366typedef long double double_t;
367#endif
368#else /* ix87 FPU default */
369typedef long double float_t;
370typedef long double double_t;
371#endif
372
373/* 7.12.3.1 */
374/*
375 Return values for fpclassify.
376 These are based on Intel x87 fpu condition codes
377 in the high byte of status word and differ from
378 the return values for MS IEEE 754 extension _fpclass()
379*/
380#define FP_NAN 0x0100
381#define FP_NORMAL 0x0400
382#define FP_INFINITE (FP_NAN | FP_NORMAL)
383#define FP_ZERO 0x4000
384#define FP_SUBNORMAL (FP_NORMAL | FP_ZERO)
385/* 0x0200 is signbit mask */
386
387/*
388 We can't inline float or double, because we want to ensure truncation
389 to semantic type before classification.
390 (A normal long double value might become subnormal when
391 converted to double, and zero when converted to float.)
392*/
393
394 extern int __cdecl __fpclassifyl (long double);
395 extern int __cdecl __fpclassifyf (float);
396 extern int __cdecl __fpclassify (double);
397
398#ifndef __CRT__NO_INLINE
399 __CRT_INLINE int __cdecl __fpclassifyl (long double x) {
400#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
401 return __fpclassify(x);
402#elif defined(__x86_64__) || defined(_AMD64_)
403 __mingw_ldbl_type_t hlp;
404 unsigned int e;
405 hlp.x = x;
406 e = hlp.lh.sign_exponent & 0x7fff;
407 if (!e)
408 {
409 unsigned int h = hlp.lh.high;
410 if (!(hlp.lh.low | h))
411 return FP_ZERO;
412 else if (!(h & 0x80000000))
413 return FP_SUBNORMAL;
414 }
415 else if (e == 0x7fff)
416 return (((hlp.lh.high & 0x7fffffff) | hlp.lh.low) == 0 ?
417 FP_INFINITE : FP_NAN);
418 return FP_NORMAL;
419#elif defined(__i386__) || defined(_X86_)
420 unsigned short sw;
421 __asm__ __volatile__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x));
422 return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
423#endif
424 }
425 __CRT_INLINE int __cdecl __fpclassify (double x) {
426#if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
427 __mingw_dbl_type_t hlp;
428 unsigned int l, h;
429
430 hlp.x = x;
431 h = hlp.lh.high;
432 l = hlp.lh.low | (h & 0xfffff);
433 h &= 0x7ff00000;
434 if ((h | l) == 0)
435 return FP_ZERO;
436 if (!h)
437 return FP_SUBNORMAL;
438 if (h == 0x7ff00000)
439 return (l ? FP_NAN : FP_INFINITE);
440 return FP_NORMAL;
441#elif defined(__i386__) || defined(_X86_)
442 unsigned short sw;
443 __asm__ __volatile__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x));
444 return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
445#endif
446 }
447 __CRT_INLINE int __cdecl __fpclassifyf (float x) {
448#if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
449 __mingw_flt_type_t hlp;
450
451 hlp.x = x;
452 hlp.val &= 0x7fffffff;
453 if (hlp.val == 0)
454 return FP_ZERO;
455 if (hlp.val < 0x800000)
456 return FP_SUBNORMAL;
457 if (hlp.val >= 0x7f800000)
458 return (hlp.val > 0x7f800000 ? FP_NAN : FP_INFINITE);
459 return FP_NORMAL;
460#elif defined(__i386__) || defined(_X86_)
461 unsigned short sw;
462 __asm__ __volatile__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x));
463 return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
464#endif
465 }
466#endif
467
468#ifdef __STDC_WANT_DEC_FP__
469#define __dfp_expansion(__call,__fin,x) \
470__mingw_choose_expr ( \
471 __mingw_types_compatible_p (__typeof__ (x), _Decimal32), \
472 __call##d32(x), \
473 __mingw_choose_expr ( \
474 __mingw_types_compatible_p (__typeof__ (x), _Decimal64), \
475 __call##d64(x), \
476 __mingw_choose_expr ( \
477 __mingw_types_compatible_p (__typeof__ (x), _Decimal128), \
478 __call##d128(x), \
479__fin)))
480#else
481#define __dfp_expansion(__call,__fin,x) __fin
482#endif
483
484#define fpclassify(x) \
485__mingw_choose_expr ( \
486 __mingw_types_compatible_p (__typeof__ (x), double), \
487 __fpclassify(x), \
488 __mingw_choose_expr ( \
489 __mingw_types_compatible_p (__typeof__ (x), float), \
490 __fpclassifyf(x), \
491 __mingw_choose_expr ( \
492 __mingw_types_compatible_p (__typeof__ (x), long double), \
493 __fpclassifyl(x), \
494 __dfp_expansion(__fpclassify,(__builtin_trap(),0),x))))
495
496
497/* 7.12.3.2 */
498#define isfinite(x) ((fpclassify(x) & FP_NAN) == 0)
499
500/* 7.12.3.3 */
501#define isinf(x) (fpclassify(x) == FP_INFINITE)
502
503/* 7.12.3.4 */
504/* We don't need to worry about truncation here:
505 A NaN stays a NaN. */
506
507 extern int __cdecl __isnan (double);
508 extern int __cdecl __isnanf (float);
509 extern int __cdecl __isnanl (long double);
510
511#ifndef __CRT__NO_INLINE
512 __CRT_INLINE int __cdecl __isnan (double _x)
513 {
514#if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
515 __mingw_dbl_type_t hlp;
516 unsigned int l, h;
517
518 hlp.x = _x;
519 l = hlp.lh.low;
520 h = hlp.lh.high & 0x7fffffff;
521 h |= (l | -l) >> 31;
522 h = 0x7ff00000 - h;
523 return (int) h >> 31;
524#elif defined(__i386__) || defined(_X86_)
525 unsigned short sw;
526 __asm__ __volatile__ ("fxam;"
527 "fstsw %%ax": "=a" (sw) : "t" (_x));
528 return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
529 == FP_NAN;
530#endif
531 }
532
533 __CRT_INLINE int __cdecl __isnanf (float _x)
534 {
535#if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
536 __mingw_flt_type_t hlp;
537 unsigned int i;
538
539 hlp.x = _x;
540 i = hlp.val & 0x7fffffff;
541 i = 0x7f800000 - i;
542 return (int) (i >> 31);
543#elif defined(__i386__) || defined(_X86_)
544 unsigned short sw;
545 __asm__ __volatile__ ("fxam;"
546 "fstsw %%ax": "=a" (sw) : "t" (_x));
547 return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
548 == FP_NAN;
549#endif
550 }
551
552 __CRT_INLINE int __cdecl __isnanl (long double _x)
553 {
554#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
555 return __isnan(_x);
556#elif defined(__x86_64__) || defined(_AMD64_)
557 __mingw_ldbl_type_t ld;
558 unsigned int xx, signexp;
559
560 ld.x = _x;
561 signexp = (ld.lh.sign_exponent & 0x7fff) << 1;
562 xx = ld.lh.low | (ld.lh.high & 0x7fffffffu);
563 signexp |= (xx | (-xx)) >> 31;
564 signexp = 0xfffe - signexp;
565 return (int) signexp >> 16;
566#elif defined(__i386__) || defined(_X86_)
567 unsigned short sw;
568 __asm__ __volatile__ ("fxam;"
569 "fstsw %%ax": "=a" (sw) : "t" (_x));
570 return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
571 == FP_NAN;
572#endif
573 }
574#endif
575
576
577
578#define isnan(x) \
579__mingw_choose_expr ( \
580 __mingw_types_compatible_p (__typeof__ (x), double), \
581 __isnan((double)(x)), \
582 __mingw_choose_expr ( \
583 __mingw_types_compatible_p (__typeof__ (x), float), \
584 __isnanf((float)(x)), \
585 __mingw_choose_expr ( \
586 __mingw_types_compatible_p (__typeof__ (x), long double), \
587 __isnanl((long double)(x)), \
588 __dfp_expansion(__isnan,(__builtin_trap(),(int)0),x))))
589
590/* 7.12.3.5 */
591#define isnormal(x) (fpclassify(x) == FP_NORMAL)
592
593/* 7.12.3.6 The signbit macro */
594 extern int __cdecl __signbit (double);
595 extern int __cdecl __signbitf (float);
596 extern int __cdecl __signbitl (long double);
597#ifndef __CRT__NO_INLINE
598 __CRT_INLINE int __cdecl __signbit (double x) {
599#if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
600 __mingw_dbl_type_t hlp;
601
602 hlp.x = x;
603 return ((hlp.lh.high & 0x80000000) != 0);
604#elif defined(__i386__) || defined(_X86_)
605 unsigned short stw;
606 __asm__ __volatile__ ( "fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
607 return stw & 0x0200;
608#endif
609 }
610
611 __CRT_INLINE int __cdecl __signbitf (float x) {
612#if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
613 __mingw_flt_type_t hlp;
614 hlp.x = x;
615 return ((hlp.val & 0x80000000) != 0);
616#elif defined(__i386__) || defined(_X86_)
617 unsigned short stw;
618 __asm__ __volatile__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
619 return stw & 0x0200;
620#endif
621 }
622
623 __CRT_INLINE int __cdecl __signbitl (long double x) {
624#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
625 return __signbit(x);
626#elif defined(__x86_64__) || defined(_AMD64_)
627 __mingw_ldbl_type_t ld;
628 ld.x = x;
629 return ((ld.lh.sign_exponent & 0x8000) != 0);
630#elif defined(__i386__) || defined(_X86_)
631 unsigned short stw;
632 __asm__ __volatile__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
633 return stw & 0x0200;
634#endif
635 }
636#endif
637
638#define signbit(x) \
639__mingw_choose_expr ( \
640 __mingw_types_compatible_p (__typeof__ (x), double), \
641 __signbit(x), \
642 __mingw_choose_expr ( \
643 __mingw_types_compatible_p (__typeof__ (x), float), \
644 __signbitf(x), \
645 __mingw_choose_expr ( \
646 __mingw_types_compatible_p (__typeof__ (x), long double), \
647 __signbitl(x), \
648 __dfp_expansion(__signbit,(__builtin_trap(),x),x))))
649
650/* 7.12.4 Trigonometric functions: Double in C89 */
651 extern float __cdecl sinf(float _X);
652 extern long double __cdecl sinl(long double);
653
654 extern float __cdecl cosf(float _X);
655 extern long double __cdecl cosl(long double);
656
657 extern float __cdecl tanf(float _X);
658 extern long double __cdecl tanl(long double);
659 extern float __cdecl asinf(float _X);
660 extern long double __cdecl asinl(long double);
661
662 extern float __cdecl acosf (float);
663 extern long double __cdecl acosl (long double);
664
665 extern float __cdecl atanf (float);
666 extern long double __cdecl atanl (long double);
667
668 extern float __cdecl atan2f (float, float);
669 extern long double __cdecl atan2l (long double, long double);
670
671/* 7.12.5 Hyperbolic functions: Double in C89 */
672 extern float __cdecl sinhf(float _X);
673#if !defined(__CRT__NO_INLINE) && !defined(_UCRT)
674 __CRT_INLINE float sinhf(float _X) { return ((float)sinh((double)_X)); }
675#endif
676 extern long double __cdecl sinhl(long double);
677
678 extern float __cdecl coshf(float _X);
679#if !defined(__CRT__NO_INLINE) && !defined(_UCRT)
680 __CRT_INLINE float coshf(float _X) { return ((float)cosh((double)_X)); }
681#endif
682 extern long double __cdecl coshl(long double);
683
684 extern float __cdecl tanhf(float _X);
685#if !defined(__CRT__NO_INLINE) && !defined(_UCRT)
686 __CRT_INLINE float tanhf(float _X) { return ((float)tanh((double)_X)); }
687#endif
688 extern long double __cdecl tanhl(long double);
689
690/* Inverse hyperbolic trig functions */
691/* 7.12.5.1 */
692 extern double __cdecl acosh (double);
693 extern float __cdecl acoshf (float);
694 extern long double __cdecl acoshl (long double);
695
696/* 7.12.5.2 */
697 extern double __cdecl asinh (double);
698 extern float __cdecl asinhf (float);
699 extern long double __cdecl asinhl (long double);
700
701/* 7.12.5.3 */
702 extern double __cdecl atanh (double);
703 extern float __cdecl atanhf (float);
704 extern long double __cdecl atanhl (long double);
705
706/* Exponentials and logarithms */
707/* 7.12.6.1 Double in C89 */
708 extern float __cdecl expf(float _X);
709#if !defined(__CRT__NO_INLINE) && !defined(_UCRT)
710 __CRT_INLINE float expf(float _X) { return ((float)exp((double)_X)); }
711#endif
712 extern long double __cdecl expl(long double);
713
714/* 7.12.6.2 */
715 extern double __cdecl exp2(double);
716 extern float __cdecl exp2f(float);
717 extern long double __cdecl exp2l(long double);
718
719/* 7.12.6.3 The expm1 functions */
720/* TODO: These could be inlined */
721 extern double __cdecl expm1(double);
722 extern float __cdecl expm1f(float);
723 extern long double __cdecl expm1l(long double);
724
725/* 7.12.6.4 Double in C89 */
726 extern float frexpf(float _X,int *_Y);
727#if !defined(__CRT__NO_INLINE) && !defined(_UCRT)
728 __CRT_INLINE float frexpf(float _X,int *_Y) { return ((float)frexp((double)_X,_Y)); }
729#endif
730 extern long double __cdecl frexpl(long double,int *);
731
732/* 7.12.6.5 */
733#define FP_ILOGB0 ((int)0x80000000)
734#define FP_ILOGBNAN ((int)0x7fffffff)
735 extern int __cdecl ilogb (double);
736 extern int __cdecl ilogbf (float);
737 extern int __cdecl ilogbl (long double);
738
739/* 7.12.6.6 Double in C89 */
740 extern float __cdecl ldexpf(float _X,int _Y);
741#if !defined(__CRT__NO_INLINE) && !defined(_UCRT)
742 __CRT_INLINE float __cdecl ldexpf (float x, int expn) { return (float) ldexp ((double)x, expn); }
743#endif
744 extern long double __cdecl ldexpl (long double, int);
745
746/* 7.12.6.7 Double in C89 */
747 extern float __cdecl logf (float);
748 extern long double __cdecl logl(long double);
749
750/* 7.12.6.8 Double in C89 */
751 extern float __cdecl log10f (float);
752 extern long double __cdecl log10l(long double);
753
754/* 7.12.6.9 */
755 extern double __cdecl log1p(double);
756 extern float __cdecl log1pf(float);
757 extern long double __cdecl log1pl(long double);
758
759/* 7.12.6.10 */
760 extern double __cdecl log2 (double);
761 extern float __cdecl log2f (float);
762 extern long double __cdecl log2l (long double);
763
764/* 7.12.6.11 */
765 extern double __cdecl logb (double);
766 extern float __cdecl logbf (float);
767 extern long double __cdecl logbl (long double);
768
769/* 7.12.6.12 Double in C89 */
770 extern float __cdecl modff (float, float*);
771 extern long double __cdecl modfl (long double, long double*);
772
773/* 7.12.6.13 */
774 extern double __cdecl scalbn (double, int);
775 extern float __cdecl scalbnf (float, int);
776 extern long double __cdecl scalbnl (long double, int);
777
778 extern double __cdecl scalbln (double, long);
779 extern float __cdecl scalblnf (float, long);
780 extern long double __cdecl scalblnl (long double, long);
781
782/* 7.12.7.1 */
783/* Implementations adapted from Cephes versions */
784 extern double __cdecl cbrt (double);
785 extern float __cdecl cbrtf (float);
786 extern long double __cdecl cbrtl (long double);
787
788/* 7.12.7.3 */
789 extern double __cdecl hypot (double, double) __MINGW_ATTRIB_DEPRECATED_MSVC2005; /* in libmoldname.a */
790 extern float __cdecl hypotf (float x, float y);
791#if !defined(__CRT__NO_INLINE) && !defined(_UCRT)
792 __CRT_INLINE float __cdecl hypotf (float x, float y) { return (float) hypot ((double)x, (double)y);}
793#endif
794 extern long double __cdecl hypotl (long double, long double);
795
796/* 7.12.7.4 The pow functions. Double in C89 */
797 extern float __cdecl powf(float _X,float _Y);
798#if !defined(__CRT__NO_INLINE) && !defined(_UCRT)
799 __CRT_INLINE float powf(float _X,float _Y) { return ((float)pow((double)_X,(double)_Y)); }
800#endif
801 extern long double __cdecl powl (long double, long double);
802
803/* 7.12.7.5 The sqrt functions. Double in C89. */
804 extern float __cdecl sqrtf (float);
805 extern long double sqrtl(long double);
806
807/* 7.12.8.1 The erf functions */
808 extern double __cdecl erf (double);
809 extern float __cdecl erff (float);
810 extern long double __cdecl erfl (long double);
811
812/* 7.12.8.2 The erfc functions */
813 extern double __cdecl erfc (double);
814 extern float __cdecl erfcf (float);
815 extern long double __cdecl erfcl (long double);
816
817/* 7.12.8.3 The lgamma functions */
818 extern double __cdecl lgamma (double);
819 extern float __cdecl lgammaf (float);
820 extern long double __cdecl lgammal (long double);
821
822 extern int signgam;
823
824/* 7.12.8.4 The tgamma functions */
825 extern double __cdecl tgamma (double);
826 extern float __cdecl tgammaf (float);
827 extern long double __cdecl tgammal (long double);
828
829/* 7.12.9.1 Double in C89 */
830 extern float __cdecl ceilf (float);
831 extern long double __cdecl ceill (long double);
832
833/* 7.12.9.2 Double in C89 */
834 extern float __cdecl floorf (float);
835 extern long double __cdecl floorl (long double);
836
837/* 7.12.9.3 */
838 extern double __cdecl nearbyint ( double);
839 extern float __cdecl nearbyintf (float);
840 extern long double __cdecl nearbyintl (long double);
841
842/* 7.12.9.4 */
843/* round, using fpu control word settings */
844extern double __cdecl rint (double);
845extern float __cdecl rintf (float);
846extern long double __cdecl rintl (long double);
847
848/* 7.12.9.5 */
849extern long __cdecl lrint (double);
850extern long __cdecl lrintf (float);
851extern long __cdecl lrintl (long double);
852
853__MINGW_EXTENSION long long __cdecl llrint (double);
854__MINGW_EXTENSION long long __cdecl llrintf (float);
855__MINGW_EXTENSION long long __cdecl llrintl (long double);
856
857/* 7.12.9.6 */
858/* round away from zero, regardless of fpu control word settings */
859 extern double __cdecl round (double);
860 extern float __cdecl roundf (float);
861 extern long double __cdecl roundl (long double);
862
863/* 7.12.9.7 */
864 extern long __cdecl lround (double);
865 extern long __cdecl lroundf (float);
866 extern long __cdecl lroundl (long double);
867 __MINGW_EXTENSION long long __cdecl llround (double);
868 __MINGW_EXTENSION long long __cdecl llroundf (float);
869 __MINGW_EXTENSION long long __cdecl llroundl (long double);
870
871/* 7.12.9.8 */
872/* round towards zero, regardless of fpu control word settings */
873 extern double __cdecl trunc (double);
874 extern float __cdecl truncf (float);
875 extern long double __cdecl truncl (long double);
876
877/* 7.12.10.1 Double in C89 */
878 extern float __cdecl fmodf (float, float);
879 extern long double __cdecl fmodl (long double, long double);
880
881/* 7.12.10.2 */
882 extern double __cdecl remainder (double, double);
883 extern float __cdecl remainderf (float, float);
884 extern long double __cdecl remainderl (long double, long double);
885
886/* 7.12.10.3 */
887 extern double __cdecl remquo(double, double, int *);
888 extern float __cdecl remquof(float, float, int *);
889 extern long double __cdecl remquol(long double, long double, int *);
890
891/* 7.12.11.1 */
892 extern double __cdecl copysign (double, double); /* in libmoldname.a */
893 extern float __cdecl copysignf (float, float);
894 extern long double __cdecl copysignl (long double, long double);
895
896#ifndef __CRT__NO_INLINE
897#if !defined (__ia64__)
898 __CRT_INLINE double __cdecl copysign (double x, double y)
899 {
900 __mingw_dbl_type_t hx, hy;
901 hx.x = x; hy.x = y;
902 hx.lh.high = (hx.lh.high & 0x7fffffff) | (hy.lh.high & 0x80000000);
903 return hx.x;
904 }
905 __CRT_INLINE float __cdecl copysignf (float x, float y)
906 {
907 __mingw_flt_type_t hx, hy;
908 hx.x = x; hy.x = y;
909 hx.val = (hx.val & 0x7fffffff) | (hy.val & 0x80000000);
910 return hx.x;
911 }
912#endif
913#endif
914
915/* 7.12.11.2 Return a NaN */
916 extern double __cdecl nan(const char *tagp);
917 extern float __cdecl nanf(const char *tagp);
918 extern long double __cdecl nanl(const char *tagp);
919
920#ifndef __STRICT_ANSI__
921#define _nan() nan("")
922#define _nanf() nanf("")
923#define _nanl() nanl("")
924#endif
925
926/* 7.12.11.3 */
927 extern double __cdecl nextafter (double, double); /* in libmoldname.a */
928 extern float __cdecl nextafterf (float, float);
929 extern long double __cdecl nextafterl (long double, long double);
930
931/* 7.12.11.4 The nexttoward functions */
932 extern double __cdecl nexttoward (double, long double);
933 extern float __cdecl nexttowardf (float, long double);
934 extern long double __cdecl nexttowardl (long double, long double);
935
936/* 7.12.12.1 */
937/* x > y ? (x - y) : 0.0 */
938 extern double __cdecl fdim (double x, double y);
939 extern float __cdecl fdimf (float x, float y);
940 extern long double __cdecl fdiml (long double x, long double y);
941
942/* fmax and fmin.
943 NaN arguments are treated as missing data: if one argument is a NaN
944 and the other numeric, then these functions choose the numeric
945 value. */
946
947/* 7.12.12.2 */
948 extern double __cdecl fmax (double, double);
949 extern float __cdecl fmaxf (float, float);
950 extern long double __cdecl fmaxl (long double, long double);
951
952/* 7.12.12.3 */
953 extern double __cdecl fmin (double, double);
954 extern float __cdecl fminf (float, float);
955 extern long double __cdecl fminl (long double, long double);
956
957/* 7.12.13.1 */
958/* return x * y + z as a ternary op */
959 extern double __cdecl fma (double, double, double);
960 extern float __cdecl fmaf (float, float, float);
961 extern long double __cdecl fmal (long double, long double, long double);
962
963/* 7.12.14 */
964/*
965 * With these functions, comparisons involving quiet NaNs set the FP
966 * condition code to "unordered". The IEEE floating-point spec
967 * dictates that the result of floating-point comparisons should be
968 * false whenever a NaN is involved, with the exception of the != op,
969 * which always returns true: yes, (NaN != NaN) is true).
970 */
971
972#ifdef __GNUC__
973
974#define isgreater(x, y) __builtin_isgreater(x, y)
975#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
976#define isless(x, y) __builtin_isless(x, y)
977#define islessequal(x, y) __builtin_islessequal(x, y)
978#define islessgreater(x, y) __builtin_islessgreater(x, y)
979#define isunordered(x, y) __builtin_isunordered(x, y)
980
981#else
982/* helper */
983#ifndef __CRT__NO_INLINE
984 __CRT_INLINE int __cdecl
985 __fp_unordered_compare (long double x, long double y){
986 unsigned short retval;
987 __asm__ __volatile__ ("fucom %%st(1);"
988 "fnstsw;": "=a" (retval) : "t" (x), "u" (y));
989 return retval;
990 }
991#endif /* __GNUC__ */
992
993#define isgreater(x, y) ((__fp_unordered_compare(x, y) & 0x4500) == 0)
994#define isless(x, y) ((__fp_unordered_compare (y, x) & 0x4500) == 0)
995#define isgreaterequal(x, y) ((__fp_unordered_compare (x, y) & FP_INFINITE) == 0)
996#define islessequal(x, y) ((__fp_unordered_compare(y, x) & FP_INFINITE) == 0)
997#define islessgreater(x, y) ((__fp_unordered_compare(x, y) & FP_SUBNORMAL) == 0)
998#define isunordered(x, y) ((__fp_unordered_compare(x, y) & 0x4500) == 0x4500)
999
1000#endif
1001
1002#endif /* __STDC_VERSION__ >= 199901L */
1003#endif /* __NO_ISOCEXT */
1004
1005#if defined(_X86_) && !defined(__x86_64)
1006 _CRTIMP float __cdecl _hypotf(float _X,float _Y);
1007#endif
1008
1009#if !defined(__ia64__)
1010 _CRTIMP float __cdecl _copysignf (float _Number,float _Sign);
1011 _CRTIMP float __cdecl _chgsignf (float _X);
1012 _CRTIMP float __cdecl _logbf(float _X);
1013 _CRTIMP float __cdecl _nextafterf(float _X,float _Y);
1014 _CRTIMP int __cdecl _finitef(float _X);
1015 _CRTIMP int __cdecl _isnanf(float _X);
1016 _CRTIMP int __cdecl _fpclassf(float _X);
1017#endif
1018
1019#ifdef _SIGN_DEFINED
1020 extern long double __cdecl _chgsignl (long double);
1021#define _copysignl copysignl
1022#endif /* _SIGN_DEFINED */
1023
1024#define _hypotl hypotl
1025
1026#ifndef NO_OLDNAMES
1027#define matherr _matherr
1028#define HUGE _HUGE
1029#endif
1030
1031/* Documentation on decimal float math
1032 http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801?ciid=8cf166fedd1aa110VgnVCM100000a360ea10RCRD
1033 */
1034#ifdef __STDC_WANT_DEC_FP__
1035
1036#define DEC_INFINITY __builtin_infd32()
1037#define DEC_NAN __builtin_nand32("")
1038
1039 extern int __cdecl __isnand32(_Decimal32 x);
1040 extern int __cdecl __isnand64(_Decimal64 x);
1041 extern int __cdecl __isnand128(_Decimal128 x);
1042 extern int __cdecl __fpclassifyd32 (_Decimal32);
1043 extern int __cdecl __fpclassifyd64 (_Decimal64);
1044 extern int __cdecl __fpclassifyd128 (_Decimal128);
1045 extern int __cdecl __signbitd32 (_Decimal32);
1046 extern int __cdecl __signbitd64 (_Decimal64);
1047 extern int __cdecl __signbitd128 (_Decimal128);
1048
1049#ifndef __CRT__NO_INLINE
1050 __CRT_INLINE int __cdecl __isnand32(_Decimal32 x){
1051 return __builtin_isnand32(x);
1052 }
1053
1054 __CRT_INLINE int __cdecl __isnand64(_Decimal64 x){
1055 return __builtin_isnand64(x);
1056 }
1057
1058 __CRT_INLINE int __cdecl __isnand128(_Decimal128 x){
1059 return __builtin_isnand128(x);
1060 }
1061
1062 __CRT_INLINE int __cdecl __signbitd32 (_Decimal32 x){
1063 return __builtin_signbitd32(x);
1064 }
1065
1066 __CRT_INLINE int __cdecl __signbitd64 (_Decimal64 x){
1067 return __builtin_signbitd64(x);
1068 }
1069
1070 __CRT_INLINE int __cdecl __signbitd128 (_Decimal128 x){
1071 return __builtin_signbitd128(x);
1072 }
1073
1074#endif
1075
1076/* Still missing
1077#define HUGE_VAL_D32
1078#define HUGE_VAL_D64
1079#define HUGE_VAL_D128
1080*/
1081
1082/*** exponentials ***/
1083/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/expd64.3m.htm */
1084_Decimal64 __cdecl expd64(_Decimal64 _X);
1085_Decimal128 __cdecl expd128(_Decimal128 _X);
1086_Decimal32 __cdecl expd32(_Decimal32 _X);
1087
1088/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/exp2d64.3m.htm */
1089_Decimal64 __cdecl exp2d64(_Decimal64 _X);
1090_Decimal128 __cdecl exp2d128(_Decimal128 _X);
1091_Decimal32 __cdecl exp2d32(_Decimal32 _X);
1092
1093/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/exp10d64.3m.htm */
1094_Decimal64 __cdecl exp10d64(_Decimal64 _X);
1095_Decimal128 __cdecl exp10d128(_Decimal128 _X);
1096_Decimal32 __cdecl exp10d32(_Decimal32 _X);
1097
1098/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/expm1d64.3m.htm */
1099_Decimal64 __cdecl expm1d64(_Decimal64 _X);
1100_Decimal128 __cdecl expm1d128(_Decimal128 _X);
1101_Decimal32 __cdecl expm1d32(_Decimal32 _X);
1102
1103/*** logarithms ***/
1104/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/logd64.3m.htm */
1105_Decimal64 __cdecl logd64(_Decimal64 _X);
1106_Decimal128 __cdecl logd128(_Decimal128 _X);
1107_Decimal32 __cdecl logd32(_Decimal32 _X);
1108
1109/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/log2d64.3m.htm */
1110_Decimal64 __cdecl log2d64(_Decimal64 _X);
1111_Decimal128 __cdecl log2d128(_Decimal128 _X);
1112_Decimal32 __cdecl log2d32(_Decimal32 _X);
1113
1114/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/log10d64.3m.htm */
1115_Decimal64 __cdecl log10d64(_Decimal64 _X);
1116_Decimal128 __cdecl log10d128(_Decimal128 _X);
1117_Decimal32 __cdecl log10d32(_Decimal32 _X);
1118
1119/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/log1pd64.3m.htm */
1120_Decimal64 __cdecl log1pd64(_Decimal64 _X);
1121_Decimal128 __cdecl log1pd128(_Decimal128 _X);
1122_Decimal32 __cdecl log1pd32(_Decimal32 _X);
1123
1124/*** trigonometrics ***/
1125/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/cosd64.3m.htm */
1126_Decimal64 __cdecl cosd64(_Decimal64 _X);
1127_Decimal128 __cdecl cosd128(_Decimal128 _X);
1128_Decimal32 __cdecl cosd32(_Decimal32 _X);
1129
1130/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/sind64.3m.htm */
1131_Decimal64 __cdecl sind64(_Decimal64 _X);
1132_Decimal128 __cdecl sind128(_Decimal128 _X);
1133_Decimal32 __cdecl sind32(_Decimal32 _X);
1134
1135/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/tand64.3m.htm */
1136_Decimal64 __cdecl tand64(_Decimal64 _X);
1137_Decimal128 __cdecl tand128(_Decimal128 _X);
1138_Decimal32 __cdecl tand32(_Decimal32 _X);
1139
1140/*** inverse trigonometrics ***/
1141/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/acosd64.3m.htm */
1142_Decimal64 __cdecl acosd64(_Decimal64 _X);
1143_Decimal128 __cdecl acosd128(_Decimal128 _X);
1144_Decimal32 __cdecl acosd32(_Decimal32 _X);
1145
1146/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/asind64.3m.htm */
1147_Decimal64 __cdecl asind64(_Decimal64 _X);
1148_Decimal128 __cdecl asind128(_Decimal128 _X);
1149_Decimal32 __cdecl asind32(_Decimal32 _X);
1150
1151/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/atand64.3m.htm */
1152_Decimal64 __cdecl atand64(_Decimal64 _X);
1153_Decimal128 __cdecl atand128(_Decimal128 _X);
1154_Decimal32 __cdecl atand32(_Decimal32 _X);
1155
1156/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/atan2d64.3m.htm */
1157_Decimal64 __cdecl atan2d64(_Decimal64 _X, _Decimal64 _Y);
1158_Decimal128 __cdecl atan2d128(_Decimal128 _X, _Decimal128 _Y);
1159_Decimal32 __cdecl atan2d32(_Decimal32 _X, _Decimal32 _Y);
1160
1161/*** hyperbolics ***/
1162/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/coshd64.3m.htm */
1163_Decimal64 __cdecl coshd64(_Decimal64 _X);
1164_Decimal128 __cdecl coshd128(_Decimal128 _X);
1165_Decimal32 __cdecl coshd32(_Decimal32 _X);
1166
1167/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/sinhd64.3m.htm */
1168_Decimal64 __cdecl sinhd64(_Decimal64 _X);
1169_Decimal128 __cdecl sinhd128(_Decimal128 _X);
1170_Decimal32 __cdecl sinhd32(_Decimal32 _X);
1171
1172/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/tanhd64.3m.htm */
1173_Decimal64 __cdecl tanhd64(_Decimal64 _X);
1174_Decimal128 __cdecl tanhd128(_Decimal128 _X);
1175_Decimal32 __cdecl tanhd32(_Decimal32 _X);
1176
1177/*** inverse hyperbolics ***/
1178/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/acoshd64.3m.htm */
1179_Decimal64 __cdecl acoshd64(_Decimal64 _X);
1180_Decimal128 __cdecl acoshd128(_Decimal128 _X);
1181_Decimal32 __cdecl acoshd32(_Decimal32 _X);
1182
1183/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/asinhd64.3m.htm */
1184_Decimal64 __cdecl asinhd64(_Decimal64 _X);
1185_Decimal128 __cdecl asinhd128(_Decimal128 _X);
1186_Decimal32 __cdecl asinhd32(_Decimal32 _X);
1187
1188/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/atanhd64.3m.htm */
1189_Decimal64 __cdecl atanhd64(_Decimal64 _X);
1190_Decimal128 __cdecl atanhd128(_Decimal128 _X);
1191_Decimal32 __cdecl atanhd32(_Decimal32 _X);
1192
1193/*** square & cube roots, hypotenuse ***/
1194/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/sqrtd64.3m.htm */
1195_Decimal64 __cdecl sqrtd64(_Decimal64 _X);
1196_Decimal128 __cdecl sqrtd128(_Decimal128 _X);
1197_Decimal32 __cdecl sqrtd32(_Decimal32 _X);
1198
1199/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/cbrtd64.3m.htm */
1200_Decimal64 __cdecl cbrtd64(_Decimal64 _X);
1201_Decimal128 __cdecl cbrtd128(_Decimal128 _X);
1202_Decimal32 __cdecl cbrtd32(_Decimal32 _X);
1203
1204/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/hypotd64.3m.htm */
1205_Decimal64 __cdecl hypotd64(_Decimal64 _X, _Decimal64 _Y);
1206_Decimal128 __cdecl hypotd128(_Decimal128 _X, _Decimal128 _Y);
1207_Decimal32 __cdecl hypotd32(_Decimal32 _X, _Decimal32 _Y);
1208
1209/*** floating multiply-add ***/
1210/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/fmad64.3m.htm */
1211_Decimal64 __cdecl fmad64(_Decimal64 _X, _Decimal64 y, _Decimal64 _Z);
1212_Decimal128 __cdecl fmad128(_Decimal128 _X, _Decimal128 y, _Decimal128 _Z);
1213_Decimal32 __cdecl fmad32(_Decimal32 _X, _Decimal32 y, _Decimal32 _Z);
1214
1215/*** exponent/significand ***/
1216/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/logbd64.3m.htm */
1217_Decimal64 __cdecl logbd64(_Decimal64 _X);
1218_Decimal128 __cdecl logbd128(_Decimal128 _X);
1219_Decimal32 __cdecl logbd32(_Decimal32 _X);
1220
1221/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/ilogbd64.3m.htm */
1222int __cdecl ilogbd64(_Decimal64 _X);
1223int __cdecl ilogbd128(_Decimal128 _X);
1224int __cdecl ilogbd32(_Decimal32 _X);
1225
1226/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/frexpd64.3m.htm */
1227_Decimal64 __cdecl frexpd64(_Decimal64 _X, int *_Y);
1228_Decimal128 __cdecl frexpd128(_Decimal128 _X, int *_Y);
1229_Decimal32 __cdecl frexpd32(_Decimal32 _X, int *_Y);
1230
1231/*** quantum ***/
1232/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/quantized64.3m.htm */
1233_Decimal64 __cdecl quantized64(_Decimal64 _X, _Decimal64 _Y);
1234_Decimal128 __cdecl quantized128(_Decimal128 _X, _Decimal128 _Y);
1235_Decimal32 __cdecl quantized32(_Decimal32 _X, _Decimal32 _Y);
1236
1237/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/samequantumd64.3m.htm */
1238_Bool __cdecl samequantumd64(_Decimal64 _X, _Decimal64 _Y);
1239_Bool __cdecl samequantumd128(_Decimal128 _X, _Decimal128 _Y);
1240_Bool __cdecl samequantumd32(_Decimal32 _X, _Decimal32 _Y);
1241
1242/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/quantexpd64.3m.htm */
1243int __cdecl quantexpd64(_Decimal64 _X);
1244int __cdecl quantexpd128(_Decimal128 _X);
1245int __cdecl quantexpd32(_Decimal32 _X);
1246
1247/*** scaling ***/
1248/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/scalbnd64.3m.htm */
1249_Decimal64 __cdecl scalbnd64(_Decimal64 _X, int _Y);
1250_Decimal128 __cdecl scalbnd128(_Decimal128 _X, int _Y);
1251_Decimal32 __cdecl scalbnd32(_Decimal32 _X, int _Y);
1252
1253/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/scalblnd64.3m.htm */
1254_Decimal64 __cdecl scalblnd64(_Decimal64 _X, long int _Y);
1255_Decimal128 __cdecl scalblnd128(_Decimal128 _X, long int _Y);
1256_Decimal32 __cdecl scalblnd32(_Decimal32 _X, long int _Y);
1257
1258/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/ldexpd64.3m.htm */
1259_Decimal64 __cdecl ldexpd64(_Decimal64 _X, int _Y);
1260_Decimal128 __cdecl ldexpd128(_Decimal128 _X, int _Y);
1261_Decimal32 __cdecl ldexpd32(_Decimal32 _X, int _Y);
1262
1263/*** rounding to integral floating ***/
1264/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/ceild64.3m.htm */
1265_Decimal64 __cdecl ceild64(_Decimal64 _X);
1266_Decimal128 __cdecl ceild128(_Decimal128 _X);
1267_Decimal32 __cdecl ceild32(_Decimal32 _X);
1268
1269/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/floord64.3m.htm */
1270_Decimal64 __cdecl floord64(_Decimal64 _X);
1271_Decimal128 __cdecl floord128(_Decimal128 _X);
1272_Decimal32 __cdecl floord32(_Decimal32 _X);
1273
1274/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/truncd64.3m.htm */
1275_Decimal64 __cdecl truncd64(_Decimal64 _X);
1276_Decimal128 __cdecl truncd128(_Decimal128 _X);
1277_Decimal32 __cdecl truncd32(_Decimal32 _X);
1278
1279/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/roundd64.3m.htm */
1280_Decimal64 __cdecl roundd64(_Decimal64 _X);
1281_Decimal128 __cdecl roundd128(_Decimal128 _X);
1282_Decimal32 __cdecl roundd32(_Decimal32 _X);
1283
1284/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/rintd64.3m.htm */
1285_Decimal64 __cdecl rintd64(_Decimal64 _X);
1286_Decimal128 __cdecl rintd128(_Decimal128 _X);
1287_Decimal32 __cdecl rintd32(_Decimal32 _X);
1288
1289/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/nearbyintd64.3m.htm */
1290_Decimal64 __cdecl nearbyintd64(_Decimal64 _X);
1291_Decimal128 __cdecl nearbyintd128(_Decimal128 _X);
1292_Decimal32 __cdecl nearbyintd32(_Decimal32 _X);
1293
1294/*** rounding to integer ***/
1295/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/lroundd64.3m.htm */
1296long int __cdecl lroundd64(_Decimal64 _X);
1297long int __cdecl lroundd128(_Decimal128 _X);
1298long int __cdecl lroundd32(_Decimal32 _X);
1299
1300/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/llroundd64.3m.htm */
1301long long int __cdecl llroundd64(_Decimal64 _X);
1302long long int __cdecl llroundd128(_Decimal128 _X);
1303long long int __cdecl llroundd32(_Decimal32 _X);
1304
1305/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/lrintd64.3m.htm */
1306long int __cdecl lrintd64(_Decimal64 _X);
1307long int __cdecl lrintd128(_Decimal128 _X);
1308long int __cdecl lrintd32(_Decimal32 _X);
1309
1310/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/llrintd64.3m.htm */
1311long long int __cdecl llrintd64(_Decimal64 _X);
1312long long int __cdecl llrintd128(_Decimal128 _X);
1313long long int __cdecl llrintd32(_Decimal32 _X);
1314
1315/*** integral and fractional parts ***/
1316/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/modfd64.3m.htm */
1317_Decimal64 __cdecl modfd64(_Decimal64 _X, _Decimal64 *_Y);
1318_Decimal128 __cdecl modfd128(_Decimal128 _X, _Decimal128 *_Y);
1319_Decimal32 __cdecl modfd32(_Decimal32 _X, _Decimal32 *_Y);
1320
1321/** remainder/mod ***/
1322/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/remainderd64.3m.htm */
1323_Decimal64 __cdecl remainderd64(_Decimal64 _X, _Decimal64 _Y);
1324_Decimal128 __cdecl remainderd128(_Decimal128 _X, _Decimal128 _Y);
1325_Decimal32 __cdecl remainderd32(_Decimal32 _X, _Decimal32 _Y);
1326
1327/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/fmodd64.3m.htm */
1328_Decimal64 __cdecl fmodd64(_Decimal64 _X, _Decimal64 _Y);
1329_Decimal128 __cdecl fmodd128(_Decimal128 _X, _Decimal128 _Y);
1330_Decimal32 __cdecl fmodd32(_Decimal32 _X, _Decimal32 _Y);
1331
1332/*** error functions ***/
1333/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/erfd64.3m.htm */
1334_Decimal64 __cdecl erfd64(_Decimal64 _X);
1335_Decimal128 __cdecl erfd128(_Decimal128 _X);
1336_Decimal32 __cdecl erfd32(_Decimal32 _X);
1337_Decimal64 __cdecl erfcd64(_Decimal64 _X);
1338_Decimal128 __cdecl erfcd128(_Decimal128 _X);
1339_Decimal32 __cdecl erfcd32(_Decimal32 _X);
1340
1341/*** gamma functions ***/
1342/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/lgammad64.3m.htm */
1343_Decimal64 __cdecl lgammad64(_Decimal64 _X);
1344_Decimal128 __cdecl lgammad128(_Decimal128 _X);
1345_Decimal32 __cdecl lgammad32(_Decimal32 _X);
1346
1347/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/tgammad64.3m.htm */
1348_Decimal64 __cdecl tgammad64(_Decimal64 _X);
1349_Decimal128 __cdecl tgammad128(_Decimal128 _X);
1350_Decimal32 __cdecl tgammad32(_Decimal32 _X);
1351
1352/*** next value ***/
1353/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/nextafterd64.3m.htm */
1354_Decimal64 __cdecl nextafterd64(_Decimal64 _X, _Decimal64 _Y);
1355_Decimal128 __cdecl nextafterd128(_Decimal128 _X, _Decimal128 _Y);
1356_Decimal32 __cdecl nextafterd32(_Decimal32 _X, _Decimal32 _Y);
1357_Decimal64 __cdecl nexttowardd64(_Decimal64 _X, _Decimal128 _Y);
1358_Decimal128 __cdecl nexttowardd128(_Decimal128 _X, _Decimal128 _Y);
1359_Decimal32 __cdecl nexttowardd32(_Decimal32 _X, _Decimal128 _Y);
1360
1361/*** absolute value, copy sign ***/
1362/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/fabsd64.3m.htm */
1363_Decimal64 __cdecl fabsd64(_Decimal64 _X);
1364_Decimal128 __cdecl fabsd128(_Decimal128 _X);
1365_Decimal32 __cdecl fabsd32(_Decimal32 _X);
1366
1367/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/copysignd64.3m.htm */
1368_Decimal64 __cdecl copysignd64(_Decimal64 _X, _Decimal64 _Y);
1369_Decimal128 __cdecl copysignd128(_Decimal128 _X, _Decimal128 _Y);
1370_Decimal32 __cdecl copysignd32(_Decimal32 _X, _Decimal32 _Y);
1371
1372/*** max, min, positive difference ***/
1373/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/fmaxd64.3m.htm */
1374_Decimal64 __cdecl fmaxd64(_Decimal64 _X, _Decimal64 y_Y);
1375_Decimal128 __cdecl fmaxd128(_Decimal128 _X, _Decimal128 _Y);
1376_Decimal32 __cdecl fmaxd32(_Decimal32 _X, _Decimal32 _Y);
1377
1378/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/fmind64.3m.htm */
1379_Decimal64 __cdecl fmind64(_Decimal64 _X, _Decimal64 _Y);
1380_Decimal128 __cdecl fmind128(_Decimal128 _X, _Decimal128 _Y);
1381_Decimal32 __cdecl fmind32(_Decimal32 _X, _Decimal32 _Y);
1382
1383/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/fdimd64.3m.htm */
1384_Decimal64 __cdecl fdimd64(_Decimal64 _X, _Decimal64 _Y);
1385_Decimal128 __cdecl fdimd128(_Decimal128 _X, _Decimal128 _Y);
1386_Decimal32 __cdecl fdimd32(_Decimal32 _X, _Decimal32 _Y);
1387
1388/*** not-a-number ***/
1389/* http://h21007.www2.hp.com/portal/download/files/unprot/fp/manpages/nand64.3m.htm */
1390_Decimal64 __cdecl nand64(__UNUSED_PARAM(const char *_X));
1391_Decimal128 __cdecl nand128(__UNUSED_PARAM(const char *_X));
1392_Decimal32 __cdecl nand32(__UNUSED_PARAM(const char *_X));
1393
1394/*** classifiers ***/
1395int __cdecl isinfd64(_Decimal64 _X);
1396int __cdecl isinfd128(_Decimal128 _X);
1397int __cdecl isinfd32(_Decimal32 _X);
1398int __cdecl isnand64(_Decimal64 _X);
1399int __cdecl isnand128(_Decimal128 _X);
1400int __cdecl isnand32(_Decimal32 _X);
1401
1402#endif /* __STDC_WANT_DEC_FP__ */
1403
1404#ifdef __cplusplus
1405}
1406#endif
1407
1408#endif /* Not RC_INVOKED */
1409
1410#pragma pack(pop)
1411
1412#endif /* End _MATH_H_ */
1413