diff --git a/src/header/fcntl/linux.rs b/src/header/fcntl/linux.rs index 9e3a7a516724fb66498a6ec1ceb9b9abc090bd42..ae1bcc97e589f73c9704cb996f8f473b24b8bd3f 100644 --- a/src/header/fcntl/linux.rs +++ b/src/header/fcntl/linux.rs @@ -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; diff --git a/src/header/fcntl/mod.rs b/src/header/fcntl/mod.rs index c2178c4eb79c5e8e8943210cfc4a0a7ca5f8921b..1946c6bebb8e2887596ad706e2e070b984807774 100644 --- a/src/header/fcntl/mod.rs +++ b/src/header/fcntl/mod.rs @@ -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; diff --git a/src/header/fcntl/redox.rs b/src/header/fcntl/redox.rs index ddc189baa8e127498767315e5e7a06ead96ae15e..b3a397b5d7b80416f99e0fc831f34d336fa27169 100644 --- a/src/header/fcntl/redox.rs +++ b/src/header/fcntl/redox.rs @@ -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; diff --git a/src/header/mod.rs b/src/header/mod.rs index 901238bfa6b98eddb28d2cddcc8f5a742aee127b..6b540342335b7e398f6d99dec1ff8c7fd0d59c9a 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -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; diff --git a/src/header/sys_epoll/cbindgen.toml b/src/header/sys_epoll/cbindgen.toml new file mode 100644 index 0000000000000000000000000000000000000000..e162dbb4f6ce185318d8a0e8d9e9e35a0907fe7f --- /dev/null +++ b/src/header/sys_epoll/cbindgen.toml @@ -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 diff --git a/src/header/sys_epoll/linux.rs b/src/header/sys_epoll/linux.rs new file mode 100644 index 0000000000000000000000000000000000000000..af4972e7006f0365147d6c408ae6a27e53c3ebf7 --- /dev/null +++ b/src/header/sys_epoll/linux.rs @@ -0,0 +1,3 @@ +use platform::types::*; + +pub const EPOLL_CLOEXEC: c_int = 0x8_0000; diff --git a/src/header/sys_epoll/mod.rs b/src/header/sys_epoll/mod.rs new file mode 100644 index 0000000000000000000000000000000000000000..c5ef76ef78a5ed39264fc3c296e421215112b4c6 --- /dev/null +++ b/src/header/sys_epoll/mod.rs @@ -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) +} diff --git a/src/header/sys_epoll/redox.rs b/src/header/sys_epoll/redox.rs new file mode 100644 index 0000000000000000000000000000000000000000..870f7f9d9f9c4864ca6fb158276313c8397c8bb7 --- /dev/null +++ b/src/header/sys_epoll/redox.rs @@ -0,0 +1,3 @@ +use platform::types::*; + +pub const EPOLL_CLOEXEC: c_int = 0x0100_0000;