diff -r b60487c3ec36 -r af685cc9d623 ucx/cx/common.h
--- a/ucx/cx/common.h Sun Aug 31 14:39:13 2025 +0200
+++ b/ucx/cx/common.h Sat Nov 08 23:06:11 2025 +0100
@@ -46,10 +46,10 @@
* Repositories:
* https://sourceforge.net/p/ucx/code
* - or -
- * https://develop.uap-core.de/hg/ucx
+ * 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__))
@@ -150,7 +155,7 @@
*/
#define cx_attr_malloc __attribute__((__malloc__))
-#ifndef __clang__
+#if !defined(__clang__) && __GNUC__ >= 11
/**
* The pointer returned by the attributed function is supposed to be freed
* by @p freefunc.
@@ -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
@@ -240,20 +245,6 @@
*/
#define cx_attr_access_w(...) cx_attr_access(__write_only__, __VA_ARGS__)
-#if __STDC_VERSION__ >= 202300L
-
-/**
- * Do not warn about unused variable.
- */
-#define cx_attr_unused [[maybe_unused]]
-
-/**
- * Warn about discarded return value.
- */
-#define cx_attr_nodiscard [[nodiscard]]
-
-#else // no C23
-
/**
* Do not warn about unused variable.
*/
@@ -264,8 +255,6 @@
*/
#define cx_attr_nodiscard __attribute__((__warn_unused_result__))
-#endif // __STDC_VERSION__
-
// ---------------------------------------------------------------------------
// MSVC specifics
@@ -276,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
// ---------------------------------------------------------------------------
@@ -292,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
@@ -359,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