Open jeremyhu opened 1 year ago
Wayland does:
static int
set_timer(int timerfd, struct timespec deadline) {
struct itimerspec its;
its.it_interval.tv_sec = 0;
its.it_interval.tv_nsec = 0;
its.it_value = deadline;
return timerfd_settime(timerfd, TFD_TIMER_ABSTIME, &its, NULL);
}
static int
clear_timer(int timerfd)
{
struct itimerspec its;
its.it_interval.tv_sec = 0;
its.it_interval.tv_nsec = 0;
its.it_value.tv_sec = 0;
its.it_value.tv_nsec = 0;
return timerfd_settime(timerfd, 0, &its, NULL);
}
Thanks for the report! I had hoped to avoid defining that struct since it's either:
<time.h>
But that would of course mean that every program using epoll-shim
on an OS that doesn't provide itimerspec
would have to shim that struct itself, which leads to much duplication.
On which OS did that build error happen? macOS?
A solution could be for epoll-shim
to provide a <time.h>
shim header on OS's that need it.
Yep, this is happening on macOS.
Note that macOS is POSIX compliant. It's one of the few OSs that actually is certified POSIX compliant.
struct itimerspec
is part of a the RT POSIX extension and is not required for POSIX compliance.
struct itimerspec
is required for POSIX.1-2008 compliance: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html
macOS seems to be stuck on POSIX.1-2001, which is a shame, really...
Please define the struct in the header. Failure to do so results in build failures in clients such as Wayland: