2 * fake epoll_pwait() implemented using ppoll + epoll_wait.
3 * This is only for Linux 2.6.18 / glibc 2.5 systems (Enterprise distros :P)
5 * Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
6 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
9 #if !defined(HAVE_EPOLL_PWAIT) \
10 && defined(HAVE_PPOLL) && defined(HAVE_EPOLL_WAIT)
11 static int my_epoll_pwait(int epfd
, struct epoll_event
*events
,
12 int maxevents
, int timeout
, const sigset_t
*sigmask
)
14 struct pollfd pfds
= { .fd
= epfd
, .events
= POLLIN
};
22 ts
.tv_sec
= timeout
/ 1000;
23 ts
.tv_nsec
= (timeout
% 1000) * 1000000;
27 /* wait on just the epoll descriptor itself */
28 rc
= ppoll(&pfds
, 1, tsp
, sigmask
);
30 assert((errno
== EINTR
|| errno
== ENOMEM
)
31 && "ppoll usage bug");
33 /* no sleep for the actual epoll call */
34 return rc
> 0 ? epoll_wait(epfd
, events
, maxevents
, 0) : 0;
36 #define epoll_pwait(epfd,events,maxevents,timeout,sigmask) \
37 my_epoll_pwait((epfd),(events),(maxevents),(timeout),(sigmask))
38 #endif /* epoll_pwait */