mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 07:53:34 +08:00
PX4_ISFINITE use builtin everywhere
This commit is contained in:
@@ -48,6 +48,8 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <uORB/topics/actuator_outputs.h>
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/actuator_armed.h>
|
||||
|
||||
@@ -65,12 +65,11 @@
|
||||
/* Wrapper for rotation matrices stored in arrays */
|
||||
#define PX4_R(_array, _x, _y) PX4_ARRAY2D(_array, 3, _x, _y)
|
||||
|
||||
/* Define a usable PX4_ISFINITE. Note that PX4_ISFINITE is ONLY used in C++ files,
|
||||
* therefore, by default, we want to use std::isfinite. */
|
||||
/* Define PX4_ISFINITE */
|
||||
#ifdef __cplusplus
|
||||
#include <cmath>
|
||||
#define PX4_ISFINITE(x) std::isfinite(x)
|
||||
#endif
|
||||
constexpr bool PX4_ISFINITE(float x) { return __builtin_isfinite(x); }
|
||||
constexpr bool PX4_ISFINITE(double x) { return __builtin_isfinite(x); }
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if defined(__PX4_NUTTX) || defined(__PX4_POSIX)
|
||||
/****************************************************************************
|
||||
@@ -117,22 +116,6 @@ typedef param_t px4_param_t;
|
||||
# define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
|
||||
#endif
|
||||
|
||||
// Workaround for broken NuttX math.h.
|
||||
#ifdef __cplusplus
|
||||
#include <cmath>
|
||||
#undef isfinite
|
||||
template<typename T>
|
||||
inline bool isfinite(T __y)
|
||||
{
|
||||
int __cy = fpclassify(__y);
|
||||
return __cy != FP_INFINITE && __cy != FP_NAN;
|
||||
}
|
||||
namespace std
|
||||
{
|
||||
using ::isfinite;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#elif defined(__PX4_POSIX)
|
||||
/****************************************************************************
|
||||
* POSIX Specific defines
|
||||
@@ -165,12 +148,6 @@ using ::isfinite;
|
||||
# define PX4_TICKS_PER_SEC 1000L
|
||||
# define SIOCDEVPRIVATE 999999
|
||||
|
||||
// HEXAGON's isfinite() is erroneously defined as a macro even for C++,
|
||||
// using std::isfinite (using ::isfinite) which is a function, but which
|
||||
// appears to be broken because of undefined symbols (ie, _Dtest (C linkage)).
|
||||
# undef PX4_ISFINITE
|
||||
# define PX4_ISFINITE(x) __builtin_isfinite(x)
|
||||
|
||||
#else // __PX4_QURT
|
||||
|
||||
// All POSIX except QURT.
|
||||
|
||||
Reference in New Issue
Block a user