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 <jeremyhu@apple.com>
This commit is contained in:
Jeremy Huddleston Sequoia 2026-04-19 10:35:49 -07:00
parent 03e68b01ac
commit 2454dd0eec
2 changed files with 17 additions and 0 deletions

View file

@ -26,12 +26,15 @@
#define _GNU_SOURCE
#include "../config.h"
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
#include <limits.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
@ -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;