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;