Alfred Agrell (@Alcaro) commented about dlls/winewayland.drv/waylanddrv.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); \
- } \
+} +#define WINEWAYLAND_RESOURCE_UNLOCK(RESOURCE) { \
- atomic_store(RESOURCE, 0); \
- syscall(SYS_futex, RESOURCE, FUTEX_WAKE, 1, NULL, NULL, 0); \
An unconditional syscall in the wake path? I'm pretty sure that will make it slower than pthread mutex.
I completely agree with benchmarking and testing this thing before de-drafting it. I don't trust eyeball measurements for this kind of stuff, I suspect they'll measure mostly placebo.