197403Sobrien/** 297403Sobrien * D header file for POSIX. 3169691Skan * 497403Sobrien * Copyright: Copyright Sean Kelly 2005 - 2009. 5132720Skan * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 697403Sobrien * Authors: Sean Kelly 7132720Skan * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition 897403Sobrien */ 997403Sobrien 1097403Sobrien/* Copyright Sean Kelly 2005 - 2009. 1197403Sobrien * Distributed under the Boost Software License, Version 1.0. 12132720Skan * (See accompanying file LICENSE or copy at 1397403Sobrien * http://www.boost.org/LICENSE_1_0.txt) 1497403Sobrien */ 1597403Sobrienmodule core.sys.posix.poll; 1697403Sobrien 1797403Sobrienimport core.sys.posix.config; 18132720Skan 19169691Skanversion (OSX) 20169691Skan version = Darwin; 2197403Sobrienelse version (iOS) 2297403Sobrien version = Darwin; 2397403Sobrienelse version (TVOS) 2497403Sobrien version = Darwin; 2597403Sobrienelse version (WatchOS) 2697403Sobrien version = Darwin; 2797403Sobrien 2897403Sobrienversion (Posix): 2997403Sobrienextern (C): 3097403Sobriennothrow: 31169691Skan@nogc: 3297403Sobrien@system: 3397403Sobrien 34169691Skan// 3597403Sobrien// XOpen (XSI) 3697403Sobrien// 3797403Sobrien/* 3897403Sobrienstruct pollfd 39{ 40 int fd; 41 short events; 42 short revents; 43} 44 45nfds_t 46 47int poll(pollfd[], nfds_t, int); 48*/ 49 50version (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} 63else 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} 76else 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} 89else 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} 102else 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} 115else 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} 128else 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} 141else 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} 154else 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} 167else 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} 180else 181{ 182 static assert(false, "Unsupported platform"); 183} 184 185/* 186POLLIN 187POLLRDNORM 188POLLRDBAND 189POLLPRI 190POLLOUT 191POLLWRNORM 192POLLWRBAND 193POLLERR 194POLLHUP 195POLLNVAL 196*/ 197 198version (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} 214else 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} 237else 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} 260else 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} 283else 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} 303else 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} 326else 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} 342else 343{ 344 static assert(false, "Unsupported platform"); 345} 346