30#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
32#if defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_ARCH_PPC64) || defined(__s390x__) || \
33 (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8)
43#define XRT_PRINTF_FORMAT(fmt, list) __attribute__((format(printf, fmt, list)))
45#define XRT_PRINTF_FORMAT(fmt, list)
53#define XRT_MAYBE_UNUSED __attribute__((unused))
54#elif defined(_MSC_VER) && defined(__cplusplus)
55#define XRT_MAYBE_UNUSED [[maybe_unused]]
57#define XRT_MAYBE_UNUSED
64#if defined(__GNUC__) && (__GNUC__ >= 4)
65#define XRT_CHECK_RESULT __attribute__((warn_unused_result))
66#elif defined(_MSC_VER) && (_MSC_VER >= 1700)
67#define XRT_CHECK_RESULT _Check_return_
69#define XRT_CHECK_RESULT
77#define XRT_NO_INLINE __attribute__((noinline))
78#elif defined(_MSC_VER)
79#define XRT_NO_INLINE __declspec(noinline)
91#define XRT_DEBUGBREAK()
92#elif defined(__clang__) || defined(__GNUC__)
93#define XRT_DEBUGBREAK() __builtin_trap()
94#elif defined(_MSC_VER)
95#define XRT_DEBUGBREAK() __debugbreak()
97#error "compiler not supported"
102typedef volatile int32_t xrt_atomic_s32_t;
105xrt_atomic_s32_inc_return(xrt_atomic_s32_t *p)
108 return __sync_add_and_fetch(p, 1);
109#elif defined(_MSC_VER)
110 return InterlockedIncrement((
volatile LONG *)p);
112#error "compiler not supported"
116xrt_atomic_s32_dec_return(xrt_atomic_s32_t *p)
119 return __sync_sub_and_fetch(p, 1);
120#elif defined(_MSC_VER)
121 return InterlockedDecrement((
volatile LONG *)p);
123#error "compiler not supported"
127xrt_atomic_s32_cmpxchg(xrt_atomic_s32_t *p, int32_t old_, int32_t new_)
130 return __sync_val_compare_and_swap(p, old_, new_);
131#elif defined(_MSC_VER)
132 return InterlockedCompareExchange((
volatile LONG *)p, old_, new_);
134#error "compiler not supported"
139typedef intptr_t ssize_t;
141#define _SSIZE_T_DEFINED
149#define container_of(ptr, type, field) (type *)((char *)ptr - offsetof(type, field))
162#define XRT_STRUCT_INIT {}
165#elif defined(__cplusplus)
168#define XRT_STRUCT_INIT {}
174#define XRT_STRUCT_INIT {0}
A minimal way to include Windows.h.