83#define UCX_VERSION_MAJOR 4
86#define UCX_VERSION_MINOR 0
89#define UCX_VERSION (((UCX_VERSION_MAJOR)<<16)|UCX_VERSION_MINOR)
106#error Missing INTPTR_MAX definition
108#if INTPTR_MAX == INT64_MAX
112#define CX_WORDSIZE 64
113#elif INTPTR_MAX == INT32_MAX
117#define CX_WORDSIZE 32
119#error Unknown pointer size or missing size macros!
130#define __attribute__(x)
136#define CX_FALLTHROUGH __attribute__((__fallthrough__))
141#define CX_NONNULL __attribute__((__nonnull__))
146#define CX_NONNULL_ARG(...) __attribute__((__nonnull__(__VA_ARGS__)))
151#define CX_RETURNS_NONNULL __attribute__((__returns_nonnull__))
156#define CX_MALLOC __attribute__((__malloc__))
158#if !defined(__clang__) && __GNUC__ >= 11
166#define CX_DEALLOC(freefunc, freefunc_arg) \
167 __attribute__((__malloc__(freefunc, freefunc_arg)))
172#define CX_DEALLOC(...)
178#define CX_DEALLOC_UCX CX_DEALLOC(cxFree, 2)
183#define CX_ALLOCSIZE(...) __attribute__((__alloc_size__(__VA_ARGS__)))
190#define CX_CSTR_ARG(idx)
194#define CX_ACCESS(mode, ...)
200#define CX_ACCESS(mode, ...)
205#define CX_ACCESS(mode, ...) __attribute__((__access__(mode, __VA_ARGS__)))
211#define CX_CSTR_ARG(idx)
218#define CX_CSTR_ARG(idx) \
219 __attribute__((__null_terminated_string_arg__(idx)))
230#define CX_ACCESS_R(...) CX_ACCESS(__read_only__, __VA_ARGS__)
238#define CX_ACCESS_RW(...) CX_ACCESS(__read_write__, __VA_ARGS__)
246#define CX_ACCESS_W(...) CX_ACCESS(__write_only__, __VA_ARGS__)
251#define CX_UNUSED __attribute__((__unused__))
256#define CX_NODISCARD __attribute__((__warn_unused_result__))
264#define cx_thread_local thread_local
267#define cx_thread_local __declspec(thread)
269#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 202300L
271#define cx_thread_local _Thread_local
274#define cx_thread_local thread_local
283#if defined(CX_WINDLL_EXPORT)
284#define CX_EXPORT __declspec(dllexport)
285#elif defined(CX_WINDLL)
286#define CX_EXPORT __declspec(dllimport)
293#define CX_EXTERN extern "C" CX_EXPORT
294#define CX_FPTR extern "C" typedef
297#define CX_EXTERN CX_EXPORT
299#define CX_FPTR typedef
306#define CX_INLINE __attribute__((always_inline)) static inline
311#define CX_INLINE static inline
316#define CX_CPPDECL static inline
345#define cx_nmemb(arr) (sizeof(arr)/sizeof((arr)[0]))
351#if (__GNUC__ >= 5 || defined(__clang__)) && !defined(CX_NO_SZMUL_BUILTIN)
352#define CX_SZMUL_BUILTIN
353#define cx_szmul(a, b, result) __builtin_mul_overflow(a, b, result)
365#define cx_szmul(a, b, result) cx_szmul_impl(a, b, result)
size_t(* cx_write_func)(const void *, size_t, size_t, void *)
Function pointer compatible with fwrite-like functions.
Definition common.h:325
size_t(* cx_read_func)(void *, size_t, size_t, void *)
Function pointer compatible with fread-like functions.
Definition common.h:330
int cx_szmul_impl(size_t a, size_t b, size_t *result)
Implementation of cx_szmul() when no compiler builtin is available.
#define CX_EXTERN
Declares a function with external linkage.
Definition common.h:297