27#define XRT_ALIGNAS(n) __declspec(align(n))
28#elif defined(XRT_DOXYGEN)
29#define XRT_ALIGNAS(align)
32#define XRT_ALIGNAS(align) alignas(align)
35#if (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN) || \
36 (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \
37 (defined(__STDC_ENDIAN_NATIVE__) && __STDC_ENDIAN_NATIVE__ == __STDC_ENDIAN_BIG__) || defined(__BIG_ENDIAN__) || \
38 defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || \
43#elif (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \
44 (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
45 (defined(__STDC_ENDIAN_NATIVE__) && __STDC_ENDIAN_NATIVE__ == __STDC_ENDIAN_LITTLE__) || \
46 defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || \
47 defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || defined(__x86_64__) || defined(_M_X64) || \
48 defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86)
53#error "@todo: Unable to determine current architecture."
59#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
61#if defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_ARCH_PPC64) || defined(__s390x__) || \
62 (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8)
72#define XRT_PRINTF_FORMAT(fmt, list) __attribute__((format(printf, fmt, list)))
74#define XRT_PRINTF_FORMAT(fmt, list)
82#define XRT_MAYBE_UNUSED __attribute__((unused))
83#elif defined(_MSC_VER) && defined(__cplusplus)
84#define XRT_MAYBE_UNUSED [[maybe_unused]]
86#define XRT_MAYBE_UNUSED
97#define XRT_NONNULL_ALL __attribute__((nonnull))
99#define XRT_NONNULL_ALL
110#define XRT_NONNULL_FIRST __attribute__((nonnull(1)))
112#define XRT_NONNULL_FIRST
119#if defined(__GNUC__) && (__GNUC__ >= 4)
120#define XRT_CHECK_RESULT __attribute__((warn_unused_result))
121#elif defined(_MSC_VER) && (_MSC_VER >= 1700)
122#define XRT_CHECK_RESULT _Check_return_
124#define XRT_CHECK_RESULT
132#define XRT_NO_INLINE __attribute__((noinline))
133#elif defined(_MSC_VER)
134#define XRT_NO_INLINE __declspec(noinline)
146#define XRT_DEBUGBREAK()
147#elif defined(__clang__) || defined(__GNUC__)
148#define XRT_DEBUGBREAK() __builtin_trap()
149#elif defined(_MSC_VER)
150#define XRT_DEBUGBREAK() __debugbreak()
152#error "compiler not supported"
157typedef volatile int32_t xrt_atomic_s32_t;
160xrt_atomic_s32_inc_return(xrt_atomic_s32_t *p)
163 return __sync_add_and_fetch(p, 1);
164#elif defined(_MSC_VER)
165 return InterlockedIncrement((
volatile LONG *)p);
167#error "compiler not supported"
171xrt_atomic_s32_dec_return(xrt_atomic_s32_t *p)
174 return __sync_sub_and_fetch(p, 1);
175#elif defined(_MSC_VER)
176 return InterlockedDecrement((
volatile LONG *)p);
178#error "compiler not supported"
182xrt_atomic_s32_cmpxchg(xrt_atomic_s32_t *p, int32_t old_, int32_t new_)
185 return __sync_val_compare_and_swap(p, old_, new_);
186#elif defined(_MSC_VER)
187 return InterlockedCompareExchange((
volatile LONG *)p, old_, new_);
189#error "compiler not supported"
193xrt_atomic_s32_store(xrt_atomic_s32_t *p, int32_t v)
196 __atomic_store_n(p, v, __ATOMIC_SEQ_CST);
197#elif defined(_MSC_VER)
198 InterlockedExchange((
volatile LONG *)p, v);
200#error "compiler not supported"
204xrt_atomic_s32_load(xrt_atomic_s32_t *p)
207 return __atomic_load_n(p, __ATOMIC_SEQ_CST);
208#elif defined(_MSC_VER)
209 return InterlockedCompareExchange((
volatile LONG *)p, 0, 0);
211#error "compiler not supported"
216typedef intptr_t ssize_t;
218#define _SSIZE_T_DEFINED
226#define container_of(ptr, type, field) (type *)((char *)ptr - offsetof(type, field))
239#define XRT_STRUCT_INIT {}
242#elif defined(__cplusplus)
245#define XRT_STRUCT_INIT {}
251#define XRT_STRUCT_INIT {0}
272#define XRT_C11_COMPOUND(X)
274#define XRT_C11_COMPOUND(X) (X)
A minimal way to include Windows.h.