Skip to content

Commit f835ff9

Browse files
committed
cmath: Restore definitions of std::fpclassify
This partially reverts 5a4c53d and adds the constants needed for it to work. Fixes: modm-io#40
1 parent 123a0d7 commit f835ff9

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

include/cmath

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,49 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
611611
#undef islessgreater
612612
#undef isunordered
613613

614+
#if !defined(FP_NAN)
615+
#define FP_NAN 0
616+
#endif
617+
#if !defined(FP_INFINITE)
618+
#define FP_INFINITE 1
619+
#endif
620+
#if !defined(FP_ZERO)
621+
#define FP_ZERO 2
622+
#endif
623+
#if !defined(FP_SUBNORMAL)
624+
#define FP_SUBNORMAL 3
625+
#endif
626+
#if !defined(FP_NORMAL)
627+
#define FP_NORMAL 4
628+
#endif
629+
614630
#if __cplusplus >= 201103L
615631

632+
#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
633+
constexpr int
634+
fpclassify(float __x)
635+
{ return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
636+
FP_SUBNORMAL, FP_ZERO, __x); }
637+
638+
constexpr int
639+
fpclassify(double __x)
640+
{ return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
641+
FP_SUBNORMAL, FP_ZERO, __x); }
642+
643+
constexpr int
644+
fpclassify(long double __x)
645+
{ return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
646+
FP_SUBNORMAL, FP_ZERO, __x); }
647+
#endif
648+
649+
#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
650+
template<typename _Tp>
651+
constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
652+
int>::__type
653+
fpclassify(_Tp __x)
654+
{ return __x != 0 ? FP_NORMAL : FP_ZERO; }
655+
#endif
656+
616657
#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
617658
constexpr bool
618659
isfinite(float __x)

0 commit comments

Comments
 (0)