OSDN Git Service

libc: split multi-source epoll.c
[uclinux-h8/uclibc-ng.git] / libc / sysdeps / linux / common / epoll.c
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 L_epoll_create
15 # ifdef __NR_epoll_create
16 _syscall1(int, epoll_create, int, size)
17 # endif
18
19 # ifdef __NR_epoll_create1
20 _syscall1(int, epoll_create1, int, flags)
21 # endif
22
23 # if defined __NR_epoll_create1 && !defined __NR_epoll_create
24 int epoll_create(int size)
25 {
26         return INLINE_SYSCALL(epoll_create1, 1, 0);
27 }
28 # endif
29 #endif
30
31 #if defined L_epoll_ctl && defined __NR_epoll_ctl
32 _syscall4(int, epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, event)
33 #endif
34
35 #if defined L_epoll_pwait && defined __NR_epoll_pwait
36 # include <signal.h>
37
38 # define __NR___syscall_epoll_pwait __NR_epoll_pwait
39 static __always_inline _syscall6(int, __syscall_epoll_pwait, int, epfd, struct epoll_event *, events,
40                                  int, maxevents, int, timeout, const sigset_t *, sigmask, size_t, sigsetsize)
41
42 static int __NC(epoll_pwait)(int epfd, struct epoll_event *events, int maxevents, int timeout,
43                              const sigset_t *set)
44 {
45         return __syscall_epoll_pwait(epfd, events, maxevents, timeout, set, __SYSCALL_SIGSET_T_SIZE);
46 }
47 CANCELLABLE_SYSCALL(int, epoll_pwait, (int epfd, struct epoll_event *events, int maxevents, int timeout,
48                                        const sigset_t *set),
49                     (epfd, events, maxevents, timeout, set))
50 #endif
51
52 #if defined L_epoll_wait
53 # if defined __NR_epoll_wait
54 static int __NC(epoll_wait)(int epfd, struct epoll_event *events, int maxevents, int timeout)
55 {
56         return INLINE_SYSCALL(epoll_wait, 4, epfd, events, maxevents, timeout);
57 }
58 CANCELLABLE_SYSCALL(int, epoll_wait, (int epfd, struct epoll_event *events, int maxevents, int timeout),
59                     (epfd, events, maxevents, timeout))
60
61
62 # elif /* !defined L_epoll_wait && */ defined __NR_epoll_pwait
63 /*
64  * If epoll_wait is not defined, then call epoll_pwait instead using NULL
65  * for sigmask argument
66  */
67 #  include <stddef.h>
68 int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
69 {
70         return INLINE_SYSCALL(epoll_pwait, 5, epfd, events, maxevents, timeout, NULL);
71 }
72 # endif
73 #endif