Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/tools/include/nolibc/poll.h
29267 views
1
/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
2
/*
3
* poll definitions for NOLIBC
4
* Copyright (C) 2017-2021 Willy Tarreau <[email protected]>
5
*/
6
7
/* make sure to include all global symbols */
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)
27
struct timespec t;
28
29
if (timeout >= 0) {
30
t.tv_sec = timeout / 1000;
31
t.tv_nsec = (timeout % 1000) * 1000000;
32
}
33
return my_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0);
34
#elif defined(__NR_ppoll_time64)
35
struct __kernel_timespec t;
36
37
if (timeout >= 0) {
38
t.tv_sec = timeout / 1000;
39
t.tv_nsec = (timeout % 1000) * 1000000;
40
}
41
return my_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0);
42
#else
43
return my_syscall3(__NR_poll, fds, nfds, timeout);
44
#endif
45
}
46
47
static __attribute__((unused))
48
int poll(struct pollfd *fds, int nfds, int timeout)
49
{
50
return __sysret(sys_poll(fds, nfds, timeout));
51
}
52
53
#endif /* _NOLIBC_POLL_H */
54
55