1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| | #include <poll.h>
#include <time.h>
#include <signal.h>
#include "syscall.h"
int poll(struct pollfd *fds, nfds_t n, int timeout)
{
time_t s = timeout >= 0 ? timeout / 1000 : 0;
long ns = timeout >= 0 ? timeout % 1000 * 1000000 : 0;
int r = -ENOSYS;
#ifdef SYS_ppoll_time64
int r = __syscall_cp(SYS_ppoll_time64, fds, n,
timeout >= 0 ? ((long long[]){s, ns}) : 0,
0, _NSIG / 8);
if (SYS_ppoll == SYS_ppoll_time64 || r != -ENOSYS)
return __syscall_ret(r);
#endif
#ifdef SYS_ppoll
r = __syscall_cp(SYS_ppoll, fds, n,
timeout >= 0 ? ((long[]){s, ns}) : 0,
0, _NSIG / 8);
#endif
#ifdef SYS_poll
if (r == -ENOSYS)
r = __syscall_cp(SYS_poll, fds, n, timeout);
#endif
return __syscall_ret(r);
}
|