| 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 | #define __CRT__NO_INLINE |
| 7 | #include <math.h> |
| 8 | |
| 9 | int __fpclassifyf (float _x) |
| 10 | { |
| 11 | #if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) |
| 12 | __mingw_flt_type_t hlp; |
| 13 | |
| 14 | hlp.x = _x; |
| 15 | hlp.val &= 0x7fffffff; |
| 16 | if (hlp.val == 0) |
| 17 | return FP_ZERO; |
| 18 | if (hlp.val < 0x800000) |
| 19 | return FP_SUBNORMAL; |
| 20 | if (hlp.val >= 0x7f800000) |
| 21 | return (hlp.val > 0x7f800000 ? FP_NAN : FP_INFINITE); |
| 22 | return FP_NORMAL; |
| 23 | #elif defined(__i386__) || defined(_X86_) |
| 24 | unsigned short sw; |
| 25 | __asm__ __volatile__ ( |
| 26 | 	"fxam; fstsw %%ax;" |
| 27 | 	: "=a" (sw) |
| 28 | 	: "t" (_x) |
| 29 | 	); |
| 30 | return sw & (FP_NAN | FP_NORMAL | FP_ZERO); |
| 31 | #endif |
| 32 | } |