rework langinfo code for ABI compat and for use by time code
[musl] / src / math / __fpclassifyl.c
1 #include "libm.h"
2
3 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4
5 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
6 int __fpclassifyl(long double x)
7 {
8         union ldshape u = { x };
9         int e = u.bits.exp;
10         if (!e) {
11                 if (u.bits.m >> 63) return FP_NAN;
12                 else if (u.bits.m) return FP_SUBNORMAL;
13                 else return FP_ZERO;
14         }
15         if (e == 0x7fff)
16                 return u.bits.m & (uint64_t)-1>>1 ? FP_NAN : FP_INFINITE;
17         return u.bits.m & (uint64_t)1<<63 ? FP_NORMAL : FP_NAN;
18 }
19 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
20 int __fpclassifyl(long double x)
21 {
22         union ldshape u = { x };
23         int e = u.bits.exp;
24         if (!e)
25                 return u.bits.mlo | u.bits.mhi ? FP_SUBNORMAL : FP_ZERO;
26         if (e == 0x7fff)
27                 return u.bits.mlo | u.bits.mhi ? FP_NAN : FP_INFINITE;
28         return FP_NORMAL;
29 }
30 #endif