1 /**
2 * D header file for POSIX.
3 *
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6 * Authors: Sean Kelly
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 */
9
10 /* Copyright Sean Kelly 2005 - 2009.
11 * Distributed under the Boost Software License, Version 1.0.
12 * (See accompanying file LICENSE or copy at
13 * http://www.boost.org/LICENSE_1_0.txt)
14 */
15 module core.sys.posix.poll;
16
17 import core.sys.posix.config;
18
19 version (OSX)
20 version = Darwin;
21 else version (iOS)
22 version = Darwin;
23 else version (TVOS)
24 version = Darwin;
25 else version (WatchOS)
26 version = Darwin;
27
version(Posix)28 version (Posix):
29 extern (C):
30 nothrow:
31 @nogc:
32 @system:
33
34 //
35 // XOpen (XSI)
36 //
37 /*
38 struct pollfd
39 {
40 int fd;
41 short events;
42 short revents;
43 }
44
45 nfds_t
46
47 int poll(pollfd[], nfds_t, int);
48 */
49
50 version (CRuntime_Glibc)
51 {
52 struct pollfd
53 {
54 int fd;
55 short events;
56 short revents;
57 }
58
59 alias c_ulong nfds_t;
60
61 int poll(pollfd*, nfds_t, int);
62 }
version(Darwin)63 else version (Darwin)
64 {
65 struct pollfd
66 {
67 int fd;
68 short events;
69 short revents;
70 }
71
72 alias uint nfds_t;
73
74 int poll(pollfd*, nfds_t, int);
75 }
version(FreeBSD)76 else version (FreeBSD)
77 {
78 alias uint nfds_t;
79
80 struct pollfd
81 {
82 int fd;
83 short events;
84 short revents;
85 }
86
87 int poll(pollfd*, nfds_t, int);
88 }
version(NetBSD)89 else version (NetBSD)
90 {
91 alias uint nfds_t;
92
93 struct pollfd
94 {
95 int fd;
96 short events;
97 short revents;
98 }
99
100 int poll(pollfd*, nfds_t, int);
101 }
version(OpenBSD)102 else version (OpenBSD)
103 {
104 alias uint nfds_t;
105
106 struct pollfd
107 {
108 int fd;
109 short events;
110 short revents;
111 }
112
113 int poll(pollfd*, nfds_t, int);
114 }
version(DragonFlyBSD)115 else version (DragonFlyBSD)
116 {
117 alias uint nfds_t;
118
119 struct pollfd
120 {
121 int fd;
122 short events;
123 short revents;
124 }
125
126 int poll(pollfd*, nfds_t, int);
127 }
version(Solaris)128 else version (Solaris)
129 {
130 alias c_ulong nfds_t;
131
132 struct pollfd
133 {
134 int fd;
135 short events;
136 short revents;
137 }
138
139 int poll(pollfd*, nfds_t, int);
140 }
version(CRuntime_Bionic)141 else version (CRuntime_Bionic)
142 {
143 struct pollfd
144 {
145 int fd;
146 short events;
147 short revents;
148 }
149
150 alias uint nfds_t;
151
152 int poll(pollfd*, nfds_t, c_long);
153 }
version(CRuntime_Musl)154 else version (CRuntime_Musl)
155 {
156 struct pollfd
157 {
158 int fd;
159 short events;
160 short revents;
161 }
162
163 alias uint nfds_t;
164
165 int poll(pollfd*, nfds_t, c_long);
166 }
version(CRuntime_UClibc)167 else version (CRuntime_UClibc)
168 {
169 struct pollfd
170 {
171 int fd;
172 short events;
173 short revents;
174 }
175
176 alias c_ulong nfds_t;
177
178 int poll(pollfd*, nfds_t, int);
179 }
180 else
181 {
182 static assert(false, "Unsupported platform");
183 }
184
185 /*
186 POLLIN
187 POLLRDNORM
188 POLLRDBAND
189 POLLPRI
190 POLLOUT
191 POLLWRNORM
192 POLLWRBAND
193 POLLERR
194 POLLHUP
195 POLLNVAL
196 */
197
version(linux)198 version (linux)
199 {
200 enum
201 {
202 POLLIN = 0x001,
203 POLLRDNORM = 0x040,
204 POLLRDBAND = 0x080,
205 POLLPRI = 0x002,
206 POLLOUT = 0x004,
207 POLLWRNORM = 0x100,
208 POLLWRBAND = 0x200,
209 POLLERR = 0x008,
210 POLLHUP = 0x010,
211 POLLNVAL = 0x020,
212 }
213 }
214 else version (Darwin)
215 {
216 enum
217 {
218 POLLIN = 0x0001,
219 POLLPRI = 0x0002,
220 POLLOUT = 0x0004,
221 POLLRDNORM = 0x0040,
222 POLLWRNORM = POLLOUT,
223 POLLRDBAND = 0x0080,
224 POLLWRBAND = 0x0100,
225 POLLEXTEND = 0x0200,
226 POLLATTRIB = 0x0400,
227 POLLNLINK = 0x0800,
228 POLLWRITE = 0x1000,
229 POLLERR = 0x0008,
230 POLLHUP = 0x0010,
231 POLLNVAL = 0x0020,
232
233 POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
234 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
235 }
236 }
237 else version (FreeBSD)
238 {
239 enum
240 {
241 POLLIN = 0x0001,
242 POLLPRI = 0x0002,
243 POLLOUT = 0x0004,
244 POLLRDNORM = 0x0040,
245 POLLWRNORM = POLLOUT,
246 POLLRDBAND = 0x0080,
247 POLLWRBAND = 0x0100,
248 //POLLEXTEND = 0x0200,
249 //POLLATTRIB = 0x0400,
250 //POLLNLINK = 0x0800,
251 //POLLWRITE = 0x1000,
252 POLLERR = 0x0008,
253 POLLHUP = 0x0010,
254 POLLNVAL = 0x0020,
255
256 POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
257 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
258 }
259 }
260 else version (NetBSD)
261 {
262 enum
263 {
264 POLLIN = 0x0001,
265 POLLPRI = 0x0002,
266 POLLOUT = 0x0004,
267 POLLRDNORM = 0x0040,
268 POLLWRNORM = POLLOUT,
269 POLLRDBAND = 0x0080,
270 POLLWRBAND = 0x0100,
271 //POLLEXTEND = 0x0200,
272 //POLLATTRIB = 0x0400,
273 //POLLNLINK = 0x0800,
274 //POLLWRITE = 0x1000,
275 POLLERR = 0x0008,
276 POLLHUP = 0x0010,
277 POLLNVAL = 0x0020,
278
279 POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
280 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
281 }
282 }
283 else version (OpenBSD)
284 {
285 enum
286 {
287 POLLIN = 0x0001,
288 POLLPRI = 0x0002,
289 POLLOUT = 0x0004,
290 POLLRDNORM = 0x0040,
291 POLLNORM = POLLRDNORM,
292 POLLWRNORM = POLLOUT,
293 POLLRDBAND = 0x0080,
294 POLLWRBAND = 0x0100,
295 POLLERR = 0x0008,
296 POLLHUP = 0x0010,
297 POLLNVAL = 0x0020,
298
299 POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
300 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
301 }
302 }
303 else version (DragonFlyBSD)
304 {
305 enum
306 {
307 POLLIN = 0x0001,
308 POLLPRI = 0x0002,
309 POLLOUT = 0x0004,
310 POLLRDNORM = 0x0040,
311 POLLWRNORM = POLLOUT,
312 POLLRDBAND = 0x0080,
313 POLLWRBAND = 0x0100,
314 //POLLEXTEND = 0x0200,
315 //POLLATTRIB = 0x0400,
316 //POLLNLINK = 0x0800,
317 //POLLWRITE = 0x1000,
318 POLLERR = 0x0008,
319 POLLHUP = 0x0010,
320 POLLNVAL = 0x0020,
321
322 POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
323 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
324 }
325 }
326 else version (Solaris)
327 {
328 enum
329 {
330 POLLIN = 0x0001,
331 POLLPRI = 0x0002,
332 POLLOUT = 0x0004,
333 POLLRDNORM = 0x0040,
334 POLLWRNORM = POLLOUT,
335 POLLRDBAND = 0x0080,
336 POLLWRBAND = 0x0100,
337 POLLERR = 0x0008,
338 POLLHUP = 0x0010,
339 POLLNVAL = 0x0020,
340 }
341 }
342 else
343 {
344 static assert(false, "Unsupported platform");
345 }
346