Add epoll (WIP)

This commit is contained in:
Jeremy Soller
2019-02-21 20:40:03 -07:00
parent 74d0b24939
commit 887d89c2bb
8 changed files with 84 additions and 2 deletions
+2
View File
@@ -13,3 +13,5 @@ pub const O_DIRECTORY: c_int = 0x1_0000;
pub const O_NOFOLLOW: c_int = 0x2_0000;
pub const O_CLOEXEC: c_int = 0x8_0000;
pub const O_PATH: c_int = 0x20_0000;
pub const FD_CLOEXEC: c_int = 0x8_0000;
-2
View File
@@ -23,8 +23,6 @@ pub const F_GETLK: c_int = 5;
pub const F_SETLK: c_int = 6;
pub const F_SETLKW: c_int = 7;
pub const FD_CLOEXEC: c_int = 0x0100_0000;
pub const F_RDLCK: c_int = 0;
pub const F_WRLCK: c_int = 1;
pub const F_UNLCK: c_int = 2;
+2
View File
@@ -18,3 +18,5 @@ pub const O_DIRECTORY: c_int = 0x1000_0000;
pub const O_PATH: c_int = 0x2000_0000;
pub const O_SYMLINK: c_int = 0x4000_0000;
pub const O_NOFOLLOW: c_int = 0x8000_0000;
pub const FD_CLOEXEC: c_int = 0x0100_0000;
+1
View File
@@ -30,6 +30,7 @@ pub mod stdio;
pub mod stdlib;
pub mod string;
pub mod strings;
pub mod sys_epoll;
pub mod sys_file;
pub mod sys_ioctl;
pub mod sys_mman;
+11
View File
@@ -0,0 +1,11 @@
sys_includes = []
include_guard = "_SYS_EPOLL_H"
language = "C"
style = "Tag"
[defines]
"target_os=linux" = "__linux__"
"target_os=redox" = "__redox__"
[enum]
prefix_with_name = true
+3
View File
@@ -0,0 +1,3 @@
use platform::types::*;
pub const EPOLL_CLOEXEC: c_int = 0x8_0000;
+62
View File
@@ -0,0 +1,62 @@
//! sys/epoll.h implementation for Redox, following http://man7.org/linux/man-pages/man7/epoll.7.html
use core::ptr;
use header::signal::sigset_t;
use platform::types::*;
pub use self::sys::*;
#[cfg(target_os = "linux")]
#[path = "linux.rs"]
pub mod sys;
#[cfg(target_os = "redox")]
#[path = "redox.rs"]
pub mod sys;
pub const EPOLL_CTL_ADD: c_int = 1;
pub const EPOLL_CTL_DEL: c_int = 2;
pub const EPOLL_CTL_MOD: c_int = 3;
#[repr(C)]
pub union epoll_data {
ptr: *mut c_void,
fd: c_int,
u32: u32,
u64: u64,
}
#[repr(C)]
pub struct epoll_event {
events: u32,
data: epoll_data,
}
#[no_mangle]
pub extern "C" fn epoll_create(_size: c_int) -> c_int {
epoll_create1(0)
}
#[no_mangle]
pub extern "C" fn epoll_create1(flags: c_int) -> c_int {
unimplemented!()
//Sys::epoll_create1(flags)
}
#[no_mangle]
pub extern "C" fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut epoll_event) -> c_int {
unimplemented!()
//Sys::epoll_ctl(epfd, op, fd, event)
}
#[no_mangle]
pub extern "C" fn epoll_wait(epfd: c_int, events: *mut epoll_event, maxevents: c_int, timeout: c_int) -> c_int {
epoll_pwait(epfd, events, maxevents, timeout, ptr::null())
}
#[no_mangle]
pub extern "C" fn epoll_pwait(epfd: c_int, events: *mut epoll_event, maxevents: c_int, timeout: c_int, sigmask: *const sigset_t) -> c_int {
unimplemented!()
//Sys::epoll_pwait(epfd, events, maxevents, timeout, sigmask)
}
+3
View File
@@ -0,0 +1,3 @@
use platform::types::*;
pub const EPOLL_CLOEXEC: c_int = 0x0100_0000;