diff -r a202cb1ee175 -r 956c03c25edd src/ucx/cx/common.h --- a/src/ucx/cx/common.h Fri Nov 07 11:06:58 2025 +0100 +++ b/src/ucx/cx/common.h Sun Nov 09 23:51:03 2025 +0100 @@ -49,7 +49,7 @@ * https://uap-core.de/hg/ucx *

* - *

LICENCE

+ *

LICENSE

* * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. * @@ -131,6 +131,11 @@ #endif /** + * Inform the compiler that falling through a switch case is intentional. + */ +#define cx_attr_fallthrough __attribute__((__fallthrough__)) + +/** * All pointer arguments must be non-NULL. */ #define cx_attr_nonnull __attribute__((__nonnull__)) @@ -184,7 +189,7 @@ */ #define cx_attr_cstr_arg(idx) /** - * No support for access attribute in clang. + * No support for the access attribute in clang. */ #define cx_attr_access(mode, ...) #else @@ -260,15 +265,32 @@ #define _Thread_local __declspec(thread) #endif // _MSC_VER +// --------------------------------------------------------------------------- +// Exported and inlined functions +// --------------------------------------------------------------------------- + #if defined(CX_WINDLL_EXPORT) -#define cx_attr_export __declspec(dllexport) +#define CX_EXPORT __declspec(dllexport) #elif defined(CX_WINDLL) -#define cx_attr_export __declspec(dllimport) +#define CX_EXPORT __declspec(dllimport) #else /** Only used for building Windows DLLs. */ -#define cx_attr_export +#define CX_EXPORT #endif // CX_WINDLL / CX_WINDLL_EXPORT +#ifdef __GNUC__ +/** + * Declares a function to be inlined. + */ +#define CX_INLINE __attribute__((always_inline)) static inline +#else +#define CX_INLINE static inline +#endif +/** + * Declares a compatibility function for C++ builds. + */ +#define CX_CPPDECL static inline + // --------------------------------------------------------------------------- // Useful function pointers // --------------------------------------------------------------------------- @@ -276,22 +298,12 @@ /** * Function pointer compatible with fwrite-like functions. */ -typedef size_t (*cx_write_func)( - const void *, - size_t, - size_t, - void * -); +typedef size_t (*cx_write_func)(const void*, size_t, size_t, void*); /** * Function pointer compatible with fread-like functions. */ -typedef size_t (*cx_read_func)( - void *, - size_t, - size_t, - void * -); +typedef size_t (*cx_read_func)(void*, size_t, size_t, void*); // --------------------------------------------------------------------------- // Utility macros @@ -343,9 +355,7 @@ #if __cplusplus extern "C" #endif -cx_attr_export int cx_szmul_impl(size_t a, size_t b, size_t *result); +CX_EXPORT int cx_szmul_impl(size_t a, size_t b, size_t *result); #endif // cx_szmul - - #endif // UCX_COMMON_H