| 1 |
|
| 2 | |
| 3 | * poll definitions for NOLIBC
|
| 4 | * Copyright (C) 2017-2021 Willy Tarreau <[email protected]>
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 | #include "nolibc.h"
|
| 9 |
|
| 10 | #ifndef _NOLIBC_POLL_H
|
| 11 | #define _NOLIBC_POLL_H
|
| 12 |
|
| 13 | #include "arch.h"
|
| 14 | #include "sys.h"
|
| 15 |
|
| 16 | #include <linux/poll.h>
|
| 17 | #include <linux/time.h>
|
| 18 |
|
| 19 | |
| 20 | * int poll(struct pollfd *fds, int nfds, int timeout);
|
| 21 |
|
| 22 |
|
| 23 | static __attribute__((unused))
|
| 24 | int _sys_poll(struct pollfd *fds, int nfds, int timeout)
|
| 25 | {
|
| 26 | #if defined(__NR_ppoll_time64)
|
| 27 | struct __kernel_timespec t;
|
| 28 |
|
| 29 | if (timeout >= 0) {
|
| 30 | t.tv_sec = timeout / 1000;
|
| 31 | t.tv_nsec = (timeout % 1000) * 1000000;
|
| 32 | }
|
| 33 | return __nolibc_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0);
|
| 34 | #else
|
| 35 | struct __kernel_old_timespec t;
|
| 36 |
|
| 37 | if (timeout >= 0) {
|
| 38 | t.tv_sec = timeout / 1000;
|
| 39 | t.tv_nsec = (timeout % 1000) * 1000000;
|
| 40 | }
|
| 41 | return __nolibc_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0);
|
| 42 | #endif
|
| 43 | }
|
| 44 |
|
| 45 | static __attribute__((unused))
|
| 46 | int poll(struct pollfd *fds, int nfds, int timeout)
|
| 47 | {
|
| 48 | return __sysret(_sys_poll(fds, nfds, timeout));
|
| 49 | }
|
| 50 |
|
| 51 | #endif
|