Alfred Agrell (@Alcaro) commented about dlls/winewayland.drv/waylanddrv.h:
+# error C11 Atomic Operations not support. +#else +#include <stdatomic.h> +#include <stdint.h> +#include <unistd.h> +#include <linux/futex.h> +#include <sys/syscall.h> +#define WINEWAYLAND_USE_ATOMIC +#define WINEWAYLAND_RESOURCE_TYPE _Atomic unsigned char +#define WINEWAYLAND_RESOURCE_INIT ATOMIC_VAR_INIT(0) +#define WINEWAYLAND_RESOURCE_LOCK(RESOURCE) { \
- unsigned char expected = 0; \
- while(!atomic_compare_exchange_weak(RESOURCE, &expected, 1)) { \
syscall(SYS_futex, RESOURCE, FUTEX_WAIT, 1, NULL, NULL, 0); \
- } \
+}
Please wrap function-like macros in `do { body; } while(0)`, so they don't screw up if used in if-else cases without braces.
Or even better, make them static inline functions. (Don't worry about function call overhead, it'll get inlined.)