18
18
19
19
#include < sys/syscall.h> // SYS_poll, SYS_ppoll
20
20
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
-
31
21
namespace LIBC_NAMESPACE_DECL {
32
22
33
23
LLVM_LIBC_FUNCTION (int , poll, (pollfd * fds, nfds_t nfds, int timeout)) {
34
24
int ret = 0 ;
35
25
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
39
29
timespec ts, *tsp;
40
30
if (timeout >= 0 ) {
41
31
ts.tv_sec = timeout / 1000 ;
@@ -44,9 +34,16 @@ LLVM_LIBC_FUNCTION(int, poll, (pollfd * fds, nfds_t nfds, int timeout)) {
44
34
} else {
45
35
tsp = nullptr ;
46
36
}
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,
48
42
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)
50
47
51
48
if (ret < 0 ) {
52
49
libc_errno = -ret;
0 commit comments