83#define UCX_VERSION_MAJOR 3
86#define UCX_VERSION_MINOR 1
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_attr_nonnull __attribute__((__nonnull__))
141#define cx_attr_nonnull_arg(...) __attribute__((__nonnull__(__VA_ARGS__)))
146#define cx_attr_returns_nonnull __attribute__((__returns_nonnull__))
151#define cx_attr_malloc __attribute__((__malloc__))
153#if !defined(__clang__) && __GNUC__ >= 11
161#define cx_attr_dealloc(freefunc, freefunc_arg) \
162 __attribute__((__malloc__(freefunc, freefunc_arg)))
167#define cx_attr_dealloc(...)
173#define cx_attr_dealloc_ucx cx_attr_dealloc(cxFree, 2)
178#define cx_attr_allocsize(...) __attribute__((__alloc_size__(__VA_ARGS__)))
185#define cx_attr_cstr_arg(idx)
189#define cx_attr_access(mode, ...)
195#define cx_attr_access(mode, ...)
200#define cx_attr_access(mode, ...) __attribute__((__access__(mode, __VA_ARGS__)))
206#define cx_attr_cstr_arg(idx)
213#define cx_attr_cstr_arg(idx) \
214 __attribute__((__null_terminated_string_arg__(idx)))
225#define cx_attr_access_r(...) cx_attr_access(__read_only__, __VA_ARGS__)
233#define cx_attr_access_rw(...) cx_attr_access(__read_write__, __VA_ARGS__)
241#define cx_attr_access_w(...) cx_attr_access(__write_only__, __VA_ARGS__)
243#if __STDC_VERSION__ >= 202300L
248#define cx_attr_unused [[maybe_unused]]
253#define cx_attr_nodiscard [[nodiscard]]
260#define cx_attr_unused __attribute__((__unused__))
265#define cx_attr_nodiscard __attribute__((__warn_unused_result__))
276#define _Thread_local __declspec(thread)
279#if defined(CX_WINDLL_EXPORT)
280#define cx_attr_export __declspec(dllexport)
281#elif defined(CX_WINDLL)
282#define cx_attr_export __declspec(dllimport)
285#define cx_attr_export
325#define cx_nmemb(arr) (sizeof(arr)/sizeof((arr)[0]))
331#if (__GNUC__ >= 5 || defined(__clang__)) && !defined(CX_NO_SZMUL_BUILTIN)
332#define CX_SZMUL_BUILTIN
333#define cx_szmul(a, b, result) __builtin_mul_overflow(a, b, result)
345#define cx_szmul(a, b, result) cx_szmul_impl(a, b, result)
#define cx_attr_export
Only used for building Windows DLLs.
Definition common.h:285
size_t(* cx_write_func)(const void *, size_t, size_t, void *)
Function pointer compatible with fwrite-like functions.
Definition common.h:295
size_t(* cx_read_func)(void *, size_t, size_t, void *)
Function pointer compatible with fread-like functions.
Definition common.h:305
int cx_szmul_impl(size_t a, size_t b, size_t *result)
Implementation of cx_szmul() when no compiler builtin is available.