From 2454dd0eec2fb5af08b740ece91799184f3ceed9 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Sun, 19 Apr 2026 10:35:49 -0700 Subject: [PATCH] client: Use poll() as fallback when ppoll() is unavailable On platforms like darwin that lack ppoll(), fall back to poll() with a millisecond timeout. Since the ppoll() call uses a NULL signal mask, the behavior is equivalent. Signed-off-by: Jeremy Huddleston Sequoia --- meson.build | 1 + src/wayland-client.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/meson.build b/meson.build index 1c5caf3e..15564db6 100644 --- a/meson.build +++ b/meson.build @@ -51,6 +51,7 @@ have_funcs = [ 'getpeereid', 'mkostemp', 'posix_fallocate', + 'ppoll', 'prctl', 'memfd_create', 'mremap', diff --git a/src/wayland-client.c b/src/wayland-client.c index 50b3b4b2..ee596b08 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -26,12 +26,15 @@ #define _GNU_SOURCE +#include "../config.h" + #include #include #include #include #include #include +#include #include #include #include @@ -2055,7 +2058,20 @@ wl_display_poll(struct wl_display *display, timespec_sub_saturate(&result, &deadline, &now); remaining_timeout = &result; } +#ifdef HAVE_PPOLL ret = ppoll(pfd, 1, remaining_timeout, NULL); +#else + if (remaining_timeout) { + long timeout_ms = + remaining_timeout->tv_sec * 1000 + + (remaining_timeout->tv_nsec + 999999) / 1000000; + if (timeout_ms > INT_MAX) + timeout_ms = INT_MAX; + ret = poll(pfd, 1, (int)timeout_ms); + } else { + ret = poll(pfd, 1, -1); + } +#endif } while (ret == -1 && errno == EINTR); return ret;