mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-05-02 06:46:26 -04:00
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:
parent
03e68b01ac
commit
2454dd0eec
2 changed files with 17 additions and 0 deletions
|
|
@ -51,6 +51,7 @@ have_funcs = [
|
||||||
'getpeereid',
|
'getpeereid',
|
||||||
'mkostemp',
|
'mkostemp',
|
||||||
'posix_fallocate',
|
'posix_fallocate',
|
||||||
|
'ppoll',
|
||||||
'prctl',
|
'prctl',
|
||||||
'memfd_create',
|
'memfd_create',
|
||||||
'mremap',
|
'mremap',
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,15 @@
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include "../config.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
@ -2055,7 +2058,20 @@ wl_display_poll(struct wl_display *display,
|
||||||
timespec_sub_saturate(&result, &deadline, &now);
|
timespec_sub_saturate(&result, &deadline, &now);
|
||||||
remaining_timeout = &result;
|
remaining_timeout = &result;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_PPOLL
|
||||||
ret = ppoll(pfd, 1, remaining_timeout, NULL);
|
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);
|
} while (ret == -1 && errno == EINTR);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue