#include #include #include #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); }