5#include <libxr_mem.hpp>
9#define M_PI 3.14159265358979323846
13#define M_2PI (2.0 * M_PI)
19constexpr double M_1G = 9.80665;
23#define XR_TO_STR(_arg) #_arg
24#define DEF2STR(_arg) XR_TO_STR(_arg)
30#define UNUSED(_x) ((void)(_x))
36#define OFFSET_OF(type, member) ((size_t)&((type*)0)->member)
42#define MEMBER_SIZE_OF(type, member) (sizeof(decltype(((type*)0)->member)))
48#define CONTAINER_OF(ptr, type, member) \
49 ((type*)((char*)(ptr) - OFFSET_OF(type, member)))
53static constexpr size_t LIBXR_CACHE_LINE_SIZE = (
sizeof(
void*) == 8) ? 64 : 32;
54static constexpr size_t LIBXR_ALIGN_SIZE = (
sizeof(
void*));
61enum class ErrorCode : int8_t
89enum class SizeLimitMode : uint8_t
101#ifdef LIBXR_DEBUG_BUILD
112 libxr_fatal_error(__FILE__, __LINE__, false); \
123#define ASSERT_FROM_CALLBACK(arg, in_isr) \
128 libxr_fatal_error(__FILE__, __LINE__, (in_isr)); \
132#define ASSERT(arg) (void(arg), (void)0)
133#define ASSERT_FROM_CALLBACK(arg, in_isr) \
148extern "C" void libxr_fatal_error(
const char* file, uint32_t line,
bool in_isr);
152using ErrorCode = ErrorCode;
153using SizeLimitMode = SizeLimitMode;
164template <
typename T1,
typename T2>
165constexpr auto max(T1 a, T2 b) ->
typename std::common_type<T1, T2>::type
167 return (a > b) ? a : b;
179template <
typename T1,
typename T2>
180constexpr auto min(T1 a, T2 b) ->
typename std::common_type<T1, T2>::type
182 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
计算两个数的最小值