Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit b351bc3

Browse files
ljmf00dlang-bot
authored andcommitted
sys/linux/epoll: add EPOLLWAKEUP constant, epoll_pwait() call and add documentation
Signed-off-by: Luís Ferreira <contact@lsferreira.net>
1 parent 06d1bfa commit b351bc3

File tree

1 file changed

+84
-4
lines changed

1 file changed

+84
-4
lines changed

src/core/sys/linux/epoll.d

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ module core.sys.linux.epoll;
1010

1111
version (linux):
1212

13+
import core.sys.posix.signal : sigset_t;
14+
1315
extern (C):
1416
@system:
1517
@nogc:
@@ -52,16 +54,19 @@ enum
5254
EPOLLHUP = 0x010,
5355
EPOLLRDHUP = 0x2000, // since Linux 2.6.17
5456
EPOLLEXCLUSIVE = 1u << 28, // since Linux 4.5
57+
EPOLLWAKEUP = 1u << 29,
5558
EPOLLONESHOT = 1u << 30,
5659
EPOLLET = 1u << 31
5760
}
5861

59-
/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */
62+
/**
63+
* Valid opcodes ( "op" parameter ) to issue to epoll_ctl().
64+
*/
6065
enum
6166
{
62-
EPOLL_CTL_ADD = 1, // Add a file descriptor to the interface.
63-
EPOLL_CTL_DEL = 2, // Remove a file descriptor from the interface.
64-
EPOLL_CTL_MOD = 3, // Change file descriptor epoll_event structure.
67+
EPOLL_CTL_ADD = 1, /// Add a file descriptor to the interface.
68+
EPOLL_CTL_DEL = 2, /// Remove a file descriptor from the interface.
69+
EPOLL_CTL_MOD = 3, /// Change file descriptor epoll_event structure.
6570
}
6671

6772
version (X86_Any)
@@ -142,7 +147,82 @@ union epoll_data_t
142147
ulong u64;
143148
}
144149

150+
/**
151+
* Creates an epoll instance.
152+
*
153+
* Params:
154+
* size = a hint specifying the number of file descriptors to be associated
155+
* with the new instance. T
156+
* Returns: an fd for the new instance. The fd returned by epoll_create() should
157+
* be closed with close().
158+
* See_also: epoll_create1 (int flags)
159+
*/
145160
int epoll_create (int size);
161+
162+
/* Same as epoll_create but with an FLAGS parameter. The unused SIZE
163+
parameter has been dropped. */
164+
165+
/**
166+
* Creates an epoll instance.
167+
*
168+
* Params:
169+
* flags = a specified flag. If flags is 0, then, other than the fact that the
170+
* obsolete size argument is dropped, epoll_create1() is the same as
171+
* epoll_create().
172+
* Returns: an fd for the new instance. The fd returned by epoll_create() should
173+
* be closed with close().
174+
* See_also: epoll_create (int size)
175+
*/
146176
int epoll_create1 (int flags);
177+
178+
/**
179+
* Manipulate an epoll instance
180+
*
181+
* Params:
182+
* epfd = an epoll file descriptor instance
183+
* op = one of the EPOLL_CTL_* constants
184+
* fd = target file descriptor of the operation
185+
* event = describes which events the caller is interested in and any
186+
* associated user dat
187+
* Returns: 0 in case of success, -1 in case of error ( the "errno" variable
188+
* will contain the specific error code )
189+
*/
147190
int epoll_ctl (int epfd, int op, int fd, epoll_event *event);
191+
192+
193+
/**
194+
* Wait for events on an epoll instance.
195+
*
196+
*
197+
* Params:
198+
* epfd = an epoll file descriptor instance
199+
* events = a buffer that will contain triggered events
200+
* maxevents = the maximum number of events to be returned ( usually size of
201+
* "events" )
202+
* timeout = specifies the maximum wait time in milliseconds (-1 == infinite)
203+
*
204+
* Returns: the number of triggered events returned in "events" buffer. Or -1 in
205+
* case of error with the "errno" variable set to the specific error
206+
* code.
207+
*/
148208
int epoll_wait (int epfd, epoll_event *events, int maxevents, int timeout);
209+
210+
/**
211+
* Wait for events on an epoll instance
212+
*
213+
*
214+
* Params:
215+
* epfd = an epoll file descriptor instance
216+
* events = a buffer that will contain triggered events
217+
* maxevents = the maximum number of events to be returned ( usually size of
218+
* "events" )
219+
* timeout = specifies the maximum wait time in milliseconds (-1 == infinite)
220+
* ss = a signal set. May be specified as `null`, in which case epoll_pwait() is
221+
* equivalent to epoll_wait().
222+
*
223+
* Returns: the number of triggered events returned in "events" buffer. Or -1 in
224+
* case of error with the "errno" variable set to the specific error
225+
* code.
226+
*/
227+
int epoll_pwait (int epfd, epoll_event *events, int maxevents, int timeout,
228+
const sigset_t *ss);

0 commit comments

Comments
 (0)