1 /*
2 * epoll_create() / epoll_ctl() / epoll_wait() / epoll_pwait() for uClibc
3 *
4 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
5 *
6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7 */
8
9 #include <sys/syscall.h>
10 #include <sys/epoll.h>
11 #include <cancel.h>
12
13 #ifdef L_epoll_create
14 # ifdef __NR_epoll_create
_syscall1(int,epoll_create,int,size)15 _syscall1(int, epoll_create, int, size)
16 # endif
17
18 # ifdef __NR_epoll_create1
19 _syscall1(int, epoll_create1, int, flags)
20 # endif
21
22 # if defined __NR_epoll_create1 && !defined __NR_epoll_create
23 int epoll_create(int size)
24 {
25 return INLINE_SYSCALL(epoll_create1, 1, 0);
26 }
27 # endif
28 #endif
29
30 #if defined L_epoll_ctl && defined __NR_epoll_ctl
_syscall4(int,epoll_ctl,int,epfd,int,op,int,fd,struct epoll_event *,event)31 _syscall4(int, epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, event)
32 #endif
33
34 #if defined L_epoll_pwait && defined __NR_epoll_pwait
35 # include <signal.h>
36
37 # define __NR___syscall_epoll_pwait __NR_epoll_pwait
38 static __always_inline _syscall6(int, __syscall_epoll_pwait, int, epfd, struct epoll_event *, events,
39 int, maxevents, int, timeout, const sigset_t *, sigmask, size_t, sigsetsize)
40
41 static int __NC(epoll_pwait)(int epfd, struct epoll_event *events, int maxevents, int timeout,
42 const sigset_t *set)
43 {
44 return __syscall_epoll_pwait(epfd, events, maxevents, timeout, set, __SYSCALL_SIGSET_T_SIZE);
45 }
46 CANCELLABLE_SYSCALL(int, epoll_pwait, (int epfd, struct epoll_event *events, int maxevents, int timeout,
47 const sigset_t *set),
48 (epfd, events, maxevents, timeout, set))
49 #endif
50
51 #if defined L_epoll_wait
52 # if defined __NR_epoll_wait
__NC(epoll_wait)53 static int __NC(epoll_wait)(int epfd, struct epoll_event *events, int maxevents, int timeout)
54 {
55 return INLINE_SYSCALL(epoll_wait, 4, epfd, events, maxevents, timeout);
56 }
57 CANCELLABLE_SYSCALL(int, epoll_wait, (int epfd, struct epoll_event *events, int maxevents, int timeout),
58 (epfd, events, maxevents, timeout))
59
60
61 # elif /* !defined L_epoll_wait && */ defined __NR_epoll_pwait
62 /*
63 * If epoll_wait is not defined, then call epoll_pwait instead using NULL
64 * for sigmask argument
65 */
66 # include <stddef.h>
67 int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
68 {
69 return INLINE_SYSCALL(epoll_pwait, 5, epfd, events, maxevents, timeout, NULL);
70 }
71 # endif
72 #endif
73