1 #include <sys/epoll.h>
2 #include <signal.h>
3 #include <errno.h>
4 #include "syscall.h"
5
epoll_create(int size)6 int epoll_create(int size)
7 {
8 return epoll_create1(0);
9 }
10
epoll_create1(int flags)11 int epoll_create1(int flags)
12 {
13 int r = __syscall(SYS_epoll_create1, flags);
14 #ifdef SYS_epoll_create
15 if (r==-ENOSYS && !flags) r = __syscall(SYS_epoll_create, 1);
16 #endif
17 return __syscall_ret(r);
18 }
19
epoll_ctl(int fd,int op,int fd2,struct epoll_event * ev)20 int epoll_ctl(int fd, int op, int fd2, struct epoll_event *ev)
21 {
22 return syscall(SYS_epoll_ctl, fd, op, fd2, ev);
23 }
24
epoll_pwait(int fd,struct epoll_event * ev,int cnt,int to,const sigset_t * sigs)25 int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs)
26 {
27 int r = __syscall(SYS_epoll_pwait, fd, ev, cnt, to, sigs, _NSIG/8);
28 #ifdef SYS_epoll_wait
29 if (r==-ENOSYS && !sigs) r = __syscall(SYS_epoll_wait, fd, ev, cnt, to);
30 #endif
31 return __syscall_ret(r);
32 }
33
epoll_wait(int fd,struct epoll_event * ev,int cnt,int to)34 int epoll_wait(int fd, struct epoll_event *ev, int cnt, int to)
35 {
36 return epoll_pwait(fd, ev, cnt, to, 0);
37 }
38