Skip to content

Commit f4813a0

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 f4813a0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

include/cmath

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,48 @@ _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
614629
#if __cplusplus >= 201103L
615630

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

0 commit comments

Comments
 (0)