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 if (size<=0) return __syscall_ret(-EINVAL);
9 return epoll_create1(0);
10 }
11
epoll_create1(int flags)12 int epoll_create1(int flags)
13 {
14 int r = __syscall(SYS_epoll_create1, flags);
15 #ifdef SYS_epoll_create
16 if (r==-ENOSYS && !flags) r = __syscall(SYS_epoll_create, 1);
17 #endif
18 return __syscall_ret(r);
19 }
20
epoll_ctl(int fd,int op,int fd2,struct epoll_event * ev)21 int epoll_ctl(int fd, int op, int fd2, struct epoll_event *ev)
22 {
23 return syscall(SYS_epoll_ctl, fd, op, fd2, ev);
24 }
25
epoll_pwait(int fd,struct epoll_event * ev,int cnt,int to,const sigset_t * sigs)26 int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs)
27 {
28 int r = __syscall_cp(SYS_epoll_pwait, fd, ev, cnt, to, sigs, _NSIG/8);
29 #ifdef SYS_epoll_wait
30 if (r==-ENOSYS && !sigs) r = __syscall_cp(SYS_epoll_wait, fd, ev, cnt, to);
31 #endif
32 return __syscall_ret(r);
33 }
34
epoll_wait(int fd,struct epoll_event * ev,int cnt,int to)35 int epoll_wait(int fd, struct epoll_event *ev, int cnt, int to)
36 {
37 return epoll_pwait(fd, ev, cnt, to, 0);
38 }
39