1 /* vi: set sw=4 ts=4: */
2 /*
3  * epoll_create() / epoll_ctl() / epoll_wait() / epoll_pwait() for uClibc
4  *
5  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6  *
7  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8  */
9 
10 #include <sys/syscall.h>
11 #include <sys/epoll.h>
12 #include <cancel.h>
13 
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 
28 #endif
29 
30 #ifdef __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 #ifdef __NR_epoll_wait
35 static int __NC(epoll_wait)(int epfd, struct epoll_event *events, int maxevents, int timeout)
36 {
37 	return INLINE_SYSCALL(epoll_wait, 4, epfd, events, maxevents, timeout);
38 }
39 CANCELLABLE_SYSCALL(int, epoll_wait, (int epfd, struct epoll_event *events, int maxevents, int timeout),
40 		    (epfd, events, maxevents, timeout))
41 #endif
42 
43 #ifdef __NR_epoll_pwait
44 # include <signal.h>
45 
46 # define __NR___syscall_epoll_pwait __NR_epoll_pwait
_syscall6(int,__syscall_epoll_pwait,int,epfd,struct epoll_event *,events,int,maxevents,int,timeout,const sigset_t *,sigmask,size_t,sigsetsize)47 static __always_inline _syscall6(int, __syscall_epoll_pwait, int, epfd, struct epoll_event *, events,
48 				 int, maxevents, int, timeout, const sigset_t *, sigmask, size_t, sigsetsize)
49 
50 static int __NC(epoll_pwait)(int epfd, struct epoll_event *events, int maxevents, int timeout,
51 			     const sigset_t *set)
52 {
53 	return __syscall_epoll_pwait(epfd, events, maxevents, timeout, set, __SYSCALL_SIGSET_T_SIZE);
54 }
55 CANCELLABLE_SYSCALL(int, epoll_pwait, (int epfd, struct epoll_event *events, int maxevents, int timeout,
56 				       const sigset_t *set),
57 		    (epfd, events, maxevents, timeout, set))
58 /*
59  * If epoll_wait is not defined, then call epoll_pwait instead using NULL
60  * for sigmask argument
61  */
62 # ifndef __NR_epoll_wait
63 #  include <stddef.h>
epoll_wait(int epfd,struct epoll_event * events,int maxevents,int timeout)64 int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
65 {
66 	return INLINE_SYSCALL(epoll_pwait, 5, epfd, events, maxevents, timeout, NULL);
67 }
68 # endif
69 #endif
70