1818
1919#include < sys/syscall.h> // SYS_poll, SYS_ppoll
2020
21- #ifdef SYS_poll
22- constexpr auto POLL_SYSCALL_ID = SYS_poll;
23- #elif defined(SYS_ppoll)
24- constexpr auto POLL_SYSCALL_ID = SYS_ppoll;
25- #elif defined(SYS_ppoll_time64)
26- constexpr auto POLL_SYSCALL_ID = SYS_ppoll_time64;
27- #else
28- #error "poll, ppoll, ppoll_time64 syscalls not available."
29- #endif
30-
3121namespace LIBC_NAMESPACE_DECL {
3222
3323LLVM_LIBC_FUNCTION (int , poll, (pollfd * fds, nfds_t nfds, int timeout)) {
3424 int ret = 0 ;
3525
36- #ifdef SYS_poll
37- ret = LIBC_NAMESPACE::syscall_impl<int >(POLL_SYSCALL_ID , fds, nfds, timeout);
38- #elif defined(SYS_ppoll) || defined(SYS_ppoll_time64)
26+ #if defined( SYS_poll)
27+ ret = LIBC_NAMESPACE::syscall_impl<int >(SYS_poll , fds, nfds, timeout);
28+ #else // no SYS_poll
3929 timespec ts, *tsp;
4030 if (timeout >= 0 ) {
4131 ts.tv_sec = timeout / 1000 ;
@@ -44,9 +34,16 @@ LLVM_LIBC_FUNCTION(int, poll, (pollfd * fds, nfds_t nfds, int timeout)) {
4434 } else {
4535 tsp = nullptr ;
4636 }
47- ret = LIBC_NAMESPACE::syscall_impl<int >(POLL_SYSCALL_ID, fds, nfds, tsp,
37+ #if defined(SYS_ppoll)
38+ ret =
39+ LIBC_NAMESPACE::syscall_impl<int >(SYS_ppoll, fds, nfds, tsp, nullptr , 0 );
40+ #elif defined(SYS_ppoll_time64)
41+ ret = LIBC_NAMESPACE::syscall_impl<int >(SYS_ppoll_time64, fds, nfds, tsp,
4842 nullptr , 0 );
49- #endif
43+ #else
44+ #error "poll, ppoll, ppoll_time64 syscalls not available."
45+ #endif // defined(SYS_ppoll) || defined(SYS_ppoll_time64)
46+ #endif // defined(SYS_poll)
5047
5148 if (ret < 0 ) {
5249 libc_errno = -ret;
0 commit comments