1570af302Sopenharmony_ci#include "libm.h" 2570af302Sopenharmony_ci 3570af302Sopenharmony_ci#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 4570af302Sopenharmony_ciint __fpclassifyl(long double x) 5570af302Sopenharmony_ci{ 6570af302Sopenharmony_ci return __fpclassify(x); 7570af302Sopenharmony_ci} 8570af302Sopenharmony_ci#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 9570af302Sopenharmony_ciint __fpclassifyl(long double x) 10570af302Sopenharmony_ci{ 11570af302Sopenharmony_ci union ldshape u = {x}; 12570af302Sopenharmony_ci int e = u.i.se & 0x7fff; 13570af302Sopenharmony_ci int msb = u.i.m>>63; 14570af302Sopenharmony_ci if (!e && !msb) 15570af302Sopenharmony_ci return u.i.m ? FP_SUBNORMAL : FP_ZERO; 16570af302Sopenharmony_ci if (e == 0x7fff) { 17570af302Sopenharmony_ci /* The x86 variant of 80-bit extended precision only admits 18570af302Sopenharmony_ci * one representation of each infinity, with the mantissa msb 19570af302Sopenharmony_ci * necessarily set. The version with it clear is invalid/nan. 20570af302Sopenharmony_ci * The m68k variant, however, allows either, and tooling uses 21570af302Sopenharmony_ci * the version with it clear. */ 22570af302Sopenharmony_ci if (__BYTE_ORDER == __LITTLE_ENDIAN && !msb) 23570af302Sopenharmony_ci return FP_NAN; 24570af302Sopenharmony_ci return u.i.m << 1 ? FP_NAN : FP_INFINITE; 25570af302Sopenharmony_ci } 26570af302Sopenharmony_ci if (!msb) 27570af302Sopenharmony_ci return FP_NAN; 28570af302Sopenharmony_ci return FP_NORMAL; 29570af302Sopenharmony_ci} 30570af302Sopenharmony_ci#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 31570af302Sopenharmony_ciint __fpclassifyl(long double x) 32570af302Sopenharmony_ci{ 33570af302Sopenharmony_ci union ldshape u = {x}; 34570af302Sopenharmony_ci int e = u.i.se & 0x7fff; 35570af302Sopenharmony_ci u.i.se = 0; 36570af302Sopenharmony_ci if (!e) 37570af302Sopenharmony_ci return u.i2.lo | u.i2.hi ? FP_SUBNORMAL : FP_ZERO; 38570af302Sopenharmony_ci if (e == 0x7fff) 39570af302Sopenharmony_ci return u.i2.lo | u.i2.hi ? FP_NAN : FP_INFINITE; 40570af302Sopenharmony_ci return FP_NORMAL; 41570af302Sopenharmony_ci} 42570af302Sopenharmony_ci#endif 43