summaryrefslogtreecommitdiff
path: root/src/sys/epoll.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/epoll.rs')
-rw-r--r--src/sys/epoll.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/sys/epoll.rs b/src/sys/epoll.rs
index 2090a0df..67449e87 100644
--- a/src/sys/epoll.rs
+++ b/src/sys/epoll.rs
@@ -8,12 +8,20 @@ mod ffi {
extern {
pub fn epoll_create(size: c_int) -> c_int;
+ pub fn epoll_create1(flags: c_int) -> c_int;
pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *const EpollEvent) -> c_int;
pub fn epoll_wait(epfd: c_int, events: *mut EpollEvent, max_events: c_int, timeout: c_int) -> c_int;
}
}
bitflags!(
+ flags EpollFdFlag: c_int {
+ const EPOLL_NONBLOCK = 0x800,
+ const EPOLL_CLOEXEC = 0x80000
+ }
+);
+
+bitflags!(
#[repr(C)]
flags EpollEventKind: u32 {
const EPOLLIN = 0x001,
@@ -80,6 +88,13 @@ pub fn epoll_create() -> Result<RawFd> {
}
#[inline]
+pub fn epoll_create1(flags: EpollFdFlag) -> Result<RawFd> {
+ let res = unsafe { ffi::epoll_create1(flags.bits() | EPOLL_CLOEXEC.bits) };
+
+ Errno::result(res)
+}
+
+#[inline]
pub fn epoll_ctl(epfd: RawFd, op: EpollOp, fd: RawFd, event: &EpollEvent) -> Result<()> {
let res = unsafe { ffi::epoll_ctl(epfd, op as c_int, fd, event as *const EpollEvent) };