1 /**
2  * D header file for POSIX.
3  *
4  * Copyright: Public Domain
5  * License:   Public Domain
6  * Authors:   Sean Kelly
7  * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8  */
9 module tango.stdc.posix.poll;
10 
11 private import tango.stdc.posix.config;
12 
13 extern (C):
14 
15 //
16 // XOpen (XSI)
17 //
18 /*
19 struct pollfd
20 {
21     int     fd;
22     short   events;
23     short   revents;
24 }
25 
26 nfds_t
27 
28 POLLIN
29 POLLRDNORM
30 POLLRDBAND
31 POLLPRI
32 POLLOUT
33 POLLWRNORM
34 POLLWRBAND
35 POLLERR
36 POLLHUP
37 POLLNVAL
38 
39 int poll(pollfd[], nfds_t, int);
40 */
41 
42 version( linux )
43 {
44     struct pollfd
45     {
46         int     fd;
47         short   events;
48         short   revents;
49     }
50 
51     alias c_ulong nfds_t;
52 
53     const POLLIN        = 0x001;
54     const POLLRDNORM    = 0x040;
55     const POLLRDBAND    = 0x080;
56     const POLLPRI       = 0x002;
57     const POLLOUT       = 0x004;
58     const POLLWRNORM    = 0x100;
59     const POLLWRBAND    = 0x200;
60     const POLLERR       = 0x008;
61     const POLLHUP       = 0x010;
62     const POLLNVAL      = 0x020;
63 
64     int poll(pollfd*, nfds_t, int);
65 }
66 else version( darwin )
67 {
68     struct pollfd
69     {
70         int     fd;
71         short   events;
72         short   revents;
73     };
74 
75     alias uint nfds_t;
76 
77     enum
78     {
79         POLLIN      = 0x0001,
80         POLLPRI     = 0x0002,
81         POLLOUT     = 0x0004,
82         POLLRDNORM  = 0x0040,
83         POLLWRNORM  = POLLOUT,
84         POLLRDBAND  = 0x0080,
85         POLLWRBAND  = 0x0100,
86         POLLEXTEND  = 0x0200,
87         POLLATTRIB  = 0x0400,
88         POLLNLINK   = 0x0800,
89         POLLWRITE   = 0x1000,
90         POLLERR     = 0x0008,
91         POLLHUP     = 0x0010,
92         POLLNVAL    = 0x0020,
93 
94         POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
95                         POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
96     }
97 
98     int poll(pollfd*, nfds_t, int);
99 }
100 else version( FreeBSD )
101 {
102     struct pollfd
103     {
104         int     fd;
105         short   events;
106         short   revents;
107     };
108 
109     alias uint nfds_t;
110 
111     enum
112     {
113         POLLIN      = 0x0001,
114         POLLPRI     = 0x0002,
115         POLLOUT     = 0x0004,
116         POLLRDNORM  = 0x0040,
117         POLLWRNORM  = POLLOUT,
118         POLLRDBAND  = 0x0080,
119         POLLWRBAND  = 0x0100,
120         //POLLEXTEND  = 0x0200,
121         //POLLATTRIB  = 0x0400,
122         //POLLNLINK   = 0x0800,
123         //POLLWRITE   = 0x1000,
124         POLLERR     = 0x0008,
125         POLLHUP     = 0x0010,
126         POLLNVAL    = 0x0020,
127 
128         POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
129 		POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
130     }
131 
132     int poll(pollfd*, nfds_t, int);
133 }
134 else version( solaris )
135 {
136 	private import tango.stdc.config;
137 	
138     struct pollfd
139     {
140         int     fd;
141         short   events;
142         short   revents;
143     }
144 
145     alias c_ulong nfds_t;
146 
147     enum
148     {
149         POLLIN      = 0x0001,
150         POLLPRI     = 0x0002,
151         POLLOUT     = 0x0004,
152         POLLRDNORM  = 0x0040,
153         POLLWRNORM  = POLLOUT,
154         POLLRDBAND  = 0x0080,
155         POLLWRBAND  = 0x0100,
156         //POLLEXTEND  = 0x0200,
157         //POLLATTRIB  = 0x0400,
158         //POLLNLINK   = 0x0800,
159         //POLLWRITE   = 0x1000,
160         POLLERR     = 0x0008,
161         POLLHUP     = 0x0010,
162         POLLNVAL    = 0x0020,
163 
164         POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
165     }
166 
167     int poll(pollfd*, nfds_t, int);
168 }
169