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