Rich Felker | b69f695 | 2012-03-13 01:17:53 -0400 | [diff] [blame] | 1 | #include "libm.h" |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 2 | |
Rich Felker | b69f695 | 2012-03-13 01:17:53 -0400 | [diff] [blame] | 3 | #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 |
Rich Felker | 0539e6d | 2014-10-08 10:17:19 -0400 | [diff] [blame] | 4 | int __fpclassifyl(long double x) |
| 5 | { |
| 6 | return __fpclassify(x); |
| 7 | } |
Rich Felker | b69f695 | 2012-03-13 01:17:53 -0400 | [diff] [blame] | 8 | #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 |
| 9 | int __fpclassifyl(long double x) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 10 | { |
Szabolcs Nagy | af5f6d9 | 2013-09-02 00:38:51 +0000 | [diff] [blame] | 11 | union ldshape u = {x}; |
| 12 | int e = u.i.se & 0x7fff; |
Szabolcs Nagy | f657fe4 | 2013-09-05 18:05:07 +0000 | [diff] [blame] | 13 | int msb = u.i.m>>63; |
| 14 | if (!e && !msb) |
Szabolcs Nagy | af5f6d9 | 2013-09-02 00:38:51 +0000 | [diff] [blame] | 15 | return u.i.m ? FP_SUBNORMAL : FP_ZERO; |
Szabolcs Nagy | f657fe4 | 2013-09-05 18:05:07 +0000 | [diff] [blame] | 16 | if (!msb) |
| 17 | return FP_NAN; |
Rich Felker | b69f695 | 2012-03-13 01:17:53 -0400 | [diff] [blame] | 18 | if (e == 0x7fff) |
Szabolcs Nagy | af5f6d9 | 2013-09-02 00:38:51 +0000 | [diff] [blame] | 19 | return u.i.m << 1 ? FP_NAN : FP_INFINITE; |
| 20 | return FP_NORMAL; |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 21 | } |
Rich Felker | b69f695 | 2012-03-13 01:17:53 -0400 | [diff] [blame] | 22 | #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 |
| 23 | int __fpclassifyl(long double x) |
| 24 | { |
Szabolcs Nagy | af5f6d9 | 2013-09-02 00:38:51 +0000 | [diff] [blame] | 25 | union ldshape u = {x}; |
| 26 | int e = u.i.se & 0x7fff; |
Szabolcs Nagy | 3f92f92 | 2015-02-08 17:41:56 +0100 | [diff] [blame] | 27 | u.i.se = 0; |
Rich Felker | b69f695 | 2012-03-13 01:17:53 -0400 | [diff] [blame] | 28 | if (!e) |
Szabolcs Nagy | af5f6d9 | 2013-09-02 00:38:51 +0000 | [diff] [blame] | 29 | return u.i2.lo | u.i2.hi ? FP_SUBNORMAL : FP_ZERO; |
Szabolcs Nagy | 3f92f92 | 2015-02-08 17:41:56 +0100 | [diff] [blame] | 30 | if (e == 0x7fff) |
Szabolcs Nagy | af5f6d9 | 2013-09-02 00:38:51 +0000 | [diff] [blame] | 31 | return u.i2.lo | u.i2.hi ? FP_NAN : FP_INFINITE; |
Rich Felker | b69f695 | 2012-03-13 01:17:53 -0400 | [diff] [blame] | 32 | return FP_NORMAL; |
| 33 | } |
| 34 | #endif |