]>
Commit | Line | Data |
---|---|---|
568035b7 | 1 | /* Copyright (C) 2002-2013 Free Software Foundation, Inc. |
db6a567d CD |
2 | This file is part of the GNU C Library. |
3 | ||
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. | |
8 | ||
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. | |
13 | ||
14 | You should have received a copy of the GNU Lesser General Public | |
ab84e3ff PE |
15 | License along with the GNU C Library. If not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
db6a567d CD |
17 | |
18 | #ifndef _SYS_EPOLL_H | |
19 | #define _SYS_EPOLL_H 1 | |
20 | ||
21 | #include <stdint.h> | |
22 | #include <sys/types.h> | |
23 | ||
24 | /* Get __sigset_t. */ | |
25 | #include <bits/sigset.h> | |
26 | ||
27 | #ifndef __sigset_t_defined | |
28 | # define __sigset_t_defined | |
29 | typedef __sigset_t sigset_t; | |
30 | #endif | |
31 | ||
32 | ||
33 | /* Flags to be passed to epoll_create1. */ | |
34 | enum | |
35 | { | |
36 | EPOLL_CLOEXEC = 010000000, | |
37 | #define EPOLL_CLOEXEC EPOLL_CLOEXEC | |
38 | EPOLL_NONBLOCK = 00200004 /* HPUX has separate NDELAY & NONBLOCK */ | |
39 | #define EPOLL_NONBLOCK EPOLL_NONBLOCK | |
40 | }; | |
41 | ||
42 | ||
43 | enum EPOLL_EVENTS | |
44 | { | |
45 | EPOLLIN = 0x001, | |
46 | #define EPOLLIN EPOLLIN | |
47 | EPOLLPRI = 0x002, | |
48 | #define EPOLLPRI EPOLLPRI | |
49 | EPOLLOUT = 0x004, | |
50 | #define EPOLLOUT EPOLLOUT | |
51 | EPOLLRDNORM = 0x040, | |
52 | #define EPOLLRDNORM EPOLLRDNORM | |
53 | EPOLLRDBAND = 0x080, | |
54 | #define EPOLLRDBAND EPOLLRDBAND | |
55 | EPOLLWRNORM = 0x100, | |
56 | #define EPOLLWRNORM EPOLLWRNORM | |
57 | EPOLLWRBAND = 0x200, | |
58 | #define EPOLLWRBAND EPOLLWRBAND | |
59 | EPOLLMSG = 0x400, | |
60 | #define EPOLLMSG EPOLLMSG | |
61 | EPOLLERR = 0x008, | |
62 | #define EPOLLERR EPOLLERR | |
63 | EPOLLHUP = 0x010, | |
64 | #define EPOLLHUP EPOLLHUP | |
65 | EPOLLRDHUP = 0x2000, | |
66 | #define EPOLLRDHUP EPOLLRDHUP | |
f8d44fdc AJ |
67 | EPOLLWAKEUP = 1u << 29, |
68 | #define EPOLLWAKEUP EPOLLWAKEUP | |
ad8ae7da | 69 | EPOLLONESHOT = 1u << 30, |
db6a567d | 70 | #define EPOLLONESHOT EPOLLONESHOT |
ad8ae7da | 71 | EPOLLET = 1u << 31 |
db6a567d CD |
72 | #define EPOLLET EPOLLET |
73 | }; | |
74 | ||
75 | ||
76 | /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ | |
77 | #define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ | |
78 | #define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ | |
79 | #define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ | |
80 | ||
81 | ||
82 | typedef union epoll_data | |
83 | { | |
84 | void *ptr; | |
85 | int fd; | |
86 | uint32_t u32; | |
87 | uint64_t u64; | |
88 | } epoll_data_t; | |
89 | ||
90 | struct epoll_event | |
91 | { | |
92 | uint32_t events; /* Epoll events */ | |
93 | epoll_data_t data; /* User data variable */ | |
94 | }; | |
95 | ||
96 | ||
97 | __BEGIN_DECLS | |
98 | ||
99 | /* Creates an epoll instance. Returns an fd for the new instance. | |
100 | The "size" parameter is a hint specifying the number of file | |
101 | descriptors to be associated with the new instance. The fd | |
102 | returned by epoll_create() should be closed with close(). */ | |
103 | extern int epoll_create (int __size) __THROW; | |
104 | ||
105 | /* Same as epoll_create but with an FLAGS parameter. The unused SIZE | |
106 | parameter has been dropped. */ | |
107 | extern int epoll_create1 (int __flags) __THROW; | |
108 | ||
109 | ||
110 | /* Manipulate an epoll instance "epfd". Returns 0 in case of success, | |
111 | -1 in case of error ( the "errno" variable will contain the | |
112 | specific error code ) The "op" parameter is one of the EPOLL_CTL_* | |
113 | constants defined above. The "fd" parameter is the target of the | |
114 | operation. The "event" parameter describes which events the caller | |
115 | is interested in and any associated user data. */ | |
116 | extern int epoll_ctl (int __epfd, int __op, int __fd, | |
117 | struct epoll_event *__event) __THROW; | |
118 | ||
119 | ||
120 | /* Wait for events on an epoll instance "epfd". Returns the number of | |
121 | triggered events returned in "events" buffer. Or -1 in case of | |
122 | error with the "errno" variable set to the specific error code. The | |
123 | "events" parameter is a buffer that will contain triggered | |
124 | events. The "maxevents" is the maximum number of events to be | |
125 | returned ( usually size of "events" ). The "timeout" parameter | |
126 | specifies the maximum wait time in milliseconds (-1 == infinite). | |
127 | ||
128 | This function is a cancellation point and therefore not marked with | |
129 | __THROW. */ | |
130 | extern int epoll_wait (int __epfd, struct epoll_event *__events, | |
131 | int __maxevents, int __timeout); | |
132 | ||
133 | ||
134 | /* Same as epoll_wait, but the thread's signal mask is temporarily | |
135 | and atomically replaced with the one provided as parameter. | |
136 | ||
137 | This function is a cancellation point and therefore not marked with | |
138 | __THROW. */ | |
139 | extern int epoll_pwait (int __epfd, struct epoll_event *__events, | |
140 | int __maxevents, int __timeout, | |
2f4e7894 | 141 | const __sigset_t *__ss); |
db6a567d CD |
142 | |
143 | __END_DECLS | |
144 | ||
145 | #endif /* sys/epoll.h */ |