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 private 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
33 //
34 // XOpen (XSI)
35 //
36 /*
37 struct pollfd
38 {
39 int fd;
40 short events;
41 short revents;
42 }
43
44 nfds_t
45
46 POLLIN
47 POLLRDNORM
48 POLLRDBAND
49 POLLPRI
50 POLLOUT
51 POLLWRNORM
52 POLLWRBAND
53 POLLERR
54 POLLHUP
55 POLLNVAL
56
57 int poll(pollfd[], nfds_t, int);
58 */
59
60 version (CRuntime_Glibc)
61 {
62 struct pollfd
63 {
64 int fd;
65 short events;
66 short revents;
67 }
68
69 alias c_ulong nfds_t;
70
71 enum
72 {
73 POLLIN = 0x001,
74 POLLRDNORM = 0x040,
75 POLLRDBAND = 0x080,
76 POLLPRI = 0x002,
77 POLLOUT = 0x004,
78 POLLWRNORM = 0x100,
79 POLLWRBAND = 0x200,
80 POLLERR = 0x008,
81 POLLHUP = 0x010,
82 POLLNVAL = 0x020,
83 }
84
85 int poll(pollfd*, nfds_t, int);
86 }
version(Darwin)87 else version (Darwin)
88 {
89 struct pollfd
90 {
91 int fd;
92 short events;
93 short revents;
94 };
95
96 alias uint nfds_t;
97
98 enum
99 {
100 POLLIN = 0x0001,
101 POLLPRI = 0x0002,
102 POLLOUT = 0x0004,
103 POLLRDNORM = 0x0040,
104 POLLWRNORM = POLLOUT,
105 POLLRDBAND = 0x0080,
106 POLLWRBAND = 0x0100,
107 POLLEXTEND = 0x0200,
108 POLLATTRIB = 0x0400,
109 POLLNLINK = 0x0800,
110 POLLWRITE = 0x1000,
111 POLLERR = 0x0008,
112 POLLHUP = 0x0010,
113 POLLNVAL = 0x0020,
114
115 POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
116 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
117 }
118
119 int poll(pollfd*, nfds_t, int);
120 }
version(FreeBSD)121 else version (FreeBSD)
122 {
123 alias uint nfds_t;
124
125 struct pollfd
126 {
127 int fd;
128 short events;
129 short revents;
130 };
131
132 enum
133 {
134 POLLIN = 0x0001,
135 POLLPRI = 0x0002,
136 POLLOUT = 0x0004,
137 POLLRDNORM = 0x0040,
138 POLLWRNORM = POLLOUT,
139 POLLRDBAND = 0x0080,
140 POLLWRBAND = 0x0100,
141 //POLLEXTEND = 0x0200,
142 //POLLATTRIB = 0x0400,
143 //POLLNLINK = 0x0800,
144 //POLLWRITE = 0x1000,
145 POLLERR = 0x0008,
146 POLLHUP = 0x0010,
147 POLLNVAL = 0x0020,
148
149 POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
150 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
151 }
152
153 int poll(pollfd*, nfds_t, int);
154 }
version(NetBSD)155 else version (NetBSD)
156 {
157 alias uint nfds_t;
158
159 struct pollfd
160 {
161 int fd;
162 short events;
163 short revents;
164 };
165
166 enum
167 {
168 POLLIN = 0x0001,
169 POLLPRI = 0x0002,
170 POLLOUT = 0x0004,
171 POLLRDNORM = 0x0040,
172 POLLWRNORM = POLLOUT,
173 POLLRDBAND = 0x0080,
174 POLLWRBAND = 0x0100,
175 //POLLEXTEND = 0x0200,
176 //POLLATTRIB = 0x0400,
177 //POLLNLINK = 0x0800,
178 //POLLWRITE = 0x1000,
179 POLLERR = 0x0008,
180 POLLHUP = 0x0010,
181 POLLNVAL = 0x0020,
182
183 POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
184 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
185 }
186
187 int poll(pollfd*, nfds_t, int);
188 }
version(OpenBSD)189 else version (OpenBSD)
190 {
191 alias uint nfds_t;
192
193 struct pollfd
194 {
195 int fd;
196 short events;
197 short revents;
198 };
199
200 enum
201 {
202 POLLIN = 0x0001,
203 POLLPRI = 0x0002,
204 POLLOUT = 0x0004,
205 POLLRDNORM = 0x0040,
206 POLLNORM = POLLRDNORM,
207 POLLWRNORM = POLLOUT,
208 POLLRDBAND = 0x0080,
209 POLLWRBAND = 0x0100,
210 POLLERR = 0x0008,
211 POLLHUP = 0x0010,
212 POLLNVAL = 0x0020,
213
214 POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
215 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
216 }
217
218 int poll(pollfd*, nfds_t, int);
219 }
version(DragonFlyBSD)220 else version (DragonFlyBSD)
221 {
222 alias uint nfds_t;
223
224 struct pollfd
225 {
226 int fd;
227 short events;
228 short revents;
229 };
230
231 enum
232 {
233 POLLIN = 0x0001,
234 POLLPRI = 0x0002,
235 POLLOUT = 0x0004,
236 POLLRDNORM = 0x0040,
237 POLLWRNORM = POLLOUT,
238 POLLRDBAND = 0x0080,
239 POLLWRBAND = 0x0100,
240 //POLLEXTEND = 0x0200,
241 //POLLATTRIB = 0x0400,
242 //POLLNLINK = 0x0800,
243 //POLLWRITE = 0x1000,
244 POLLERR = 0x0008,
245 POLLHUP = 0x0010,
246 POLLNVAL = 0x0020,
247
248 POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
249 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
250 }
251
252 int poll(pollfd*, nfds_t, int);
253 }
version(Solaris)254 else version (Solaris)
255 {
256 alias c_ulong nfds_t;
257
258 struct pollfd
259 {
260 int fd;
261 short events;
262 short revents;
263 }
264
265 enum
266 {
267 POLLIN = 0x0001,
268 POLLPRI = 0x0002,
269 POLLOUT = 0x0004,
270 POLLRDNORM = 0x0040,
271 POLLWRNORM = POLLOUT,
272 POLLRDBAND = 0x0080,
273 POLLWRBAND = 0x0100,
274 POLLERR = 0x0008,
275 POLLHUP = 0x0010,
276 POLLNVAL = 0x0020,
277 }
278
279 int poll(pollfd*, nfds_t, int);
280 }
version(CRuntime_Bionic)281 else version (CRuntime_Bionic)
282 {
283 struct pollfd
284 {
285 int fd;
286 short events;
287 short revents;
288 }
289
290 alias uint nfds_t;
291
292 enum
293 {
294 POLLIN = 0x001,
295 POLLRDNORM = 0x040,
296 POLLRDBAND = 0x080,
297 POLLPRI = 0x002,
298 POLLOUT = 0x004,
299 POLLWRNORM = 0x100,
300 POLLWRBAND = 0x200,
301 POLLERR = 0x008,
302 POLLHUP = 0x010,
303 POLLNVAL = 0x020,
304 }
305
306 int poll(pollfd*, nfds_t, c_long);
307 }
version(CRuntime_Musl)308 else version (CRuntime_Musl)
309 {
310 struct pollfd
311 {
312 int fd;
313 short events;
314 short revents;
315 }
316
317 alias uint nfds_t;
318
319 enum
320 {
321 POLLIN = 0x001,
322 POLLPRI = 0x002,
323 POLLOUT = 0x004,
324 POLLERR = 0x008,
325 POLLHUP = 0x010,
326 POLLNVAL = 0x020,
327 POLLRDNORM = 0x040,
328 POLLRDBAND = 0x080,
329 POLLWRNORM = 0x100,
330 POLLWRBAND = 0x200,
331 }
332
333 int poll(pollfd*, nfds_t, c_long);
334 }
version(CRuntime_UClibc)335 else version (CRuntime_UClibc)
336 {
337 struct pollfd
338 {
339 int fd;
340 short events;
341 short revents;
342 }
343
344 alias c_ulong nfds_t;
345
346 enum
347 {
348 POLLIN = 0x001,
349 POLLRDNORM = 0x040,
350 POLLRDBAND = 0x080,
351 POLLPRI = 0x002,
352 POLLOUT = 0x004,
353 POLLWRNORM = 0x100,
354 POLLWRBAND = 0x200,
355 POLLMSG = 0x400,
356 POLLREMOVE = 0x1000,
357 POLLRDHUP = 0x2000,
358 POLLERR = 0x008,
359 POLLHUP = 0x010,
360 POLLNVAL = 0x020,
361 }
362
363 int poll(pollfd*, nfds_t, int);
364 }
365