From f785060318eb3a74b0b376e364f6d2fff8f8f713 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 17 Jun 2025 20:32:39 +0200 Subject: [PATCH] Call epoll_shim_ppoll() instead of ppoll() on Darwin This amends ddd348da7ea0889056843cf252729185d306b7b8 . Signed-off-by: Liang Qi --- src/wayland-client.c | 3 +-- src/wayland-os.c | 18 ++++++++++++++++++ src/wayland-os.h | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/wayland-client.c b/src/wayland-client.c index fe14a6b1..5f72ec24 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include "wayland-util.h" @@ -1999,7 +1998,7 @@ wl_display_poll(struct wl_display *display, timespec_sub_saturate(&result, &deadline, &now); remaining_timeout = &result; } - ret = ppoll(pfd, 1, remaining_timeout, NULL); + ret = wl_os_ppoll(pfd, 1, remaining_timeout, NULL); } while (ret == -1 && errno == EINTR); return ret; diff --git a/src/wayland-os.c b/src/wayland-os.c index aa44f091..9f0f6fb1 100644 --- a/src/wayland-os.c +++ b/src/wayland-os.c @@ -39,6 +39,9 @@ #ifdef HAVE_SYS_UCRED_H #include #endif +#if defined(__APPLE__) && !defined(EPOLL_SHIM_DISABLE_WRAPPER_MACROS) +#include +#endif #include "wayland-os.h" @@ -273,3 +276,18 @@ wl_os_mremap_maymove(int fd, void *old_data, ssize_t *old_size, return result; } + +int +wl_os_ppoll(struct pollfd *fds, nfds_t nfds, + const struct timespec *timeout_ts, const sigset_t *sigmask) +{ +#if defined(__APPLE__) +#ifndef EPOLL_SHIM_DISABLE_WRAPPER_MACROS + return epoll_shim_ppoll(fds, nfds, timeout_ts, sigmask); +#else + return -1; +#endif +#endif + + return ppoll(fds, nfds, timeout_ts, sigmask); +} diff --git a/src/wayland-os.h b/src/wayland-os.h index 068fd2fe..3f9d02bc 100644 --- a/src/wayland-os.h +++ b/src/wayland-os.h @@ -28,6 +28,7 @@ #include #include +#include int wl_os_socket_cloexec(int domain, int type, int protocol); @@ -51,6 +52,9 @@ void * wl_os_mremap_maymove(int fd, void *old_data, ssize_t *old_size, ssize_t new_size, int prot, int flags); +int +wl_os_ppoll(struct pollfd *fds, nfds_t nfds, + const struct timespec *timeout_ts, const sigset_t *sigmask); /* * The following are for wayland-os.c and the unit tests.