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