8#define M_PI 3.14159265358979323846
12#define M_2PI (2.0 * M_PI)
18constexpr double M_1G = 9.80665;
22#define XR_TO_STR(_arg) #_arg
23#define DEF2STR(_arg) XR_TO_STR(_arg)
29#define UNUSED(_x) ((void)(_x))
35#define OFFSET_OF(type, member) ((size_t)&((type *)0)->member)
41#define MEMBER_SIZE_OF(type, member) (sizeof(decltype(((type *)0)->member)))
47#define CONTAINER_OF(ptr, type, member) \
48 ((type *)((char *)(ptr) - OFFSET_OF(type, member)))
52static constexpr size_t LIBXR_CACHE_LINE_SIZE = (
sizeof(
void *) == 8) ? 64 : 32;
59enum class ErrorCode : int8_t
86enum class SizeLimitMode : uint8_t
98#ifdef LIBXR_DEBUG_BUILD
109 libxr_fatal_error(__FILE__, __LINE__, false); \
118#define ASSERT_ISR(arg) \
123 libxr_fatal_error(__FILE__, __LINE__, true); \
127#define ASSERT(arg) ((void)0)
128#define ASSERT_ISR(arg) ((void)0)
138extern void libxr_fatal_error(
const char *file, uint32_t line,
bool in_isr);
142using ErrorCode = ErrorCode;
143using SizeLimitMode = SizeLimitMode;
154template <
typename T1,
typename T2>
155constexpr auto max(T1 a, T2 b) ->
typename std::common_type<T1, T2>::type
157 return (a > b) ? a : b;
169template <
typename T1,
typename T2>
170constexpr auto min(T1 a, T2 b) ->
typename std::common_type<T1, T2>::type
172 return (a < b) ? a : b;
constexpr auto max(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最大值
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值