1 /* Copyright (C) 2002-2012 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 #define _SYS_EPOLL_H 1
22 #include <sys/types.h>
25 #include <bits/sigset.h>
27 #ifndef __sigset_t_defined
28 # define __sigset_t_defined
29 typedef __sigset_t sigset_t;
32 /* Get the platform-dependent flags. */
33 #include <bits/epoll.h>
35 #ifndef __EPOLL_PACKED
36 # define __EPOLL_PACKED
43 #define EPOLLIN EPOLLIN
45 #define EPOLLPRI EPOLLPRI
47 #define EPOLLOUT EPOLLOUT
49 #define EPOLLRDNORM EPOLLRDNORM
51 #define EPOLLRDBAND EPOLLRDBAND
53 #define EPOLLWRNORM EPOLLWRNORM
55 #define EPOLLWRBAND EPOLLWRBAND
57 #define EPOLLMSG EPOLLMSG
59 #define EPOLLERR EPOLLERR
61 #define EPOLLHUP EPOLLHUP
63 #define EPOLLRDHUP EPOLLRDHUP
64 EPOLLONESHOT = 1u << 30,
65 #define EPOLLONESHOT EPOLLONESHOT
67 #define EPOLLET EPOLLET
71 /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */
72 #define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */
73 #define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */
74 #define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */
77 typedef union epoll_data
87 uint32_t events; /* Epoll events */
88 epoll_data_t data; /* User data variable */
94 /* Creates an epoll instance. Returns an fd for the new instance.
95 The "size" parameter is a hint specifying the number of file
96 descriptors to be associated with the new instance. The fd
97 returned by epoll_create() should be closed with close(). */
98 extern int epoll_create (int __size) __THROW;
100 /* Same as epoll_create but with an FLAGS parameter. The unused SIZE
101 parameter has been dropped. */
102 extern int epoll_create1 (int __flags) __THROW;
105 /* Manipulate an epoll instance "epfd". Returns 0 in case of success,
106 -1 in case of error ( the "errno" variable will contain the
107 specific error code ) The "op" parameter is one of the EPOLL_CTL_*
108 constants defined above. The "fd" parameter is the target of the
109 operation. The "event" parameter describes which events the caller
110 is interested in and any associated user data. */
111 extern int epoll_ctl (int __epfd, int __op, int __fd,
112 struct epoll_event *__event) __THROW;
115 /* Wait for events on an epoll instance "epfd". Returns the number of
116 triggered events returned in "events" buffer. Or -1 in case of
117 error with the "errno" variable set to the specific error code. The
118 "events" parameter is a buffer that will contain triggered
119 events. The "maxevents" is the maximum number of events to be
120 returned ( usually size of "events" ). The "timeout" parameter
121 specifies the maximum wait time in milliseconds (-1 == infinite).
123 This function is a cancellation point and therefore not marked with
125 extern int epoll_wait (int __epfd, struct epoll_event *__events,
126 int __maxevents, int __timeout);
129 /* Same as epoll_wait, but the thread's signal mask is temporarily
130 and atomically replaced with the one provided as parameter.
132 This function is a cancellation point and therefore not marked with
134 extern int epoll_pwait (int __epfd, struct epoll_event *__events,
135 int __maxevents, int __timeout,
136 const __sigset_t *__ss);
140 #endif /* sys/epoll.h */