From 996fad709238e5c4e24395f1c4ff8c90dfb984e5 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 13 Mar 2018 19:52:15 -0600 Subject: [PATCH] Fix fcntl header constants --- src/fcntl/cbindgen.toml | 4 ++++ src/fcntl/src/lib.rs | 52 ++++++++++++++++++++++++++++++++++++----- src/fcntl/src/linux.rs | 8 ------- src/fcntl/src/redox.rs | 20 ---------------- 4 files changed, 50 insertions(+), 34 deletions(-) delete mode 100644 src/fcntl/src/linux.rs delete mode 100644 src/fcntl/src/redox.rs diff --git a/src/fcntl/cbindgen.toml b/src/fcntl/cbindgen.toml index e9893c078d..19d473cd4a 100644 --- a/src/fcntl/cbindgen.toml +++ b/src/fcntl/cbindgen.toml @@ -3,5 +3,9 @@ include_guard = "_FCNTL_H" trailer = "#include " language = "C" +[defines] +"target_os = linux" = "__linux__" +"target_os = redox" = "__redox__" + [enum] prefix_with_name = true diff --git a/src/fcntl/src/lib.rs b/src/fcntl/src/lib.rs index 0c0fa43ce2..0e5048277a 100644 --- a/src/fcntl/src/lib.rs +++ b/src/fcntl/src/lib.rs @@ -6,15 +6,55 @@ extern crate platform; use platform::types::*; -pub use sys::*; - #[cfg(target_os = "linux")] -#[path = "linux.rs"] -pub mod sys; +pub const O_RDONLY: c_int = 0x0000; +#[cfg(target_os = "linux")] +pub const O_WRONLY: c_int = 0x0001; +#[cfg(target_os = "linux")] +pub const O_RDWR: c_int = 0x0002; +#[cfg(target_os = "linux")] +pub const O_CREAT: c_int = 0x0040; +#[cfg(target_os = "linux")] +pub const O_TRUNC: c_int = 0x0200; +#[cfg(target_os = "linux")] +pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; #[cfg(target_os = "redox")] -#[path = "redox.rs"] -pub mod sys; +pub const O_RDONLY: c_int = 0x0001_0000; +#[cfg(target_os = "redox")] +pub const O_WRONLY: c_int = 0x0002_0000; +#[cfg(target_os = "redox")] +pub const O_RDWR: c_int = 0x0003_0000; +#[cfg(target_os = "redox")] +pub const O_NONBLOCK: c_int = 0x0004_0000; +#[cfg(target_os = "redox")] +pub const O_APPEND: c_int = 0x0008_0000; +#[cfg(target_os = "redox")] +pub const O_SHLOCK: c_int = 0x0010_0000; +#[cfg(target_os = "redox")] +pub const O_EXLOCK: c_int = 0x0020_0000; +#[cfg(target_os = "redox")] +pub const O_ASYNC: c_int = 0x0040_0000; +#[cfg(target_os = "redox")] +pub const O_FSYNC: c_int = 0x0080_0000; +#[cfg(target_os = "redox")] +pub const O_CLOEXEC: c_int = 0x0100_0000; +#[cfg(target_os = "redox")] +pub const O_CREAT: c_int = 0x0200_0000; +#[cfg(target_os = "redox")] +pub const O_TRUNC: c_int = 0x0400_0000; +#[cfg(target_os = "redox")] +pub const O_EXCL: c_int = 0x0800_0000; +#[cfg(target_os = "redox")] +pub const O_DIRECTORY: c_int = 0x1000_0000; +#[cfg(target_os = "redox")] +pub const O_STAT: c_int = 0x2000_0000; +#[cfg(target_os = "redox")] +pub const O_SYMLINK: c_int = 0x4000_0000; +#[cfg(target_os = "redox")] +pub const O_NOFOLLOW: c_int = 0x8000_0000; +#[cfg(target_os = "redox")] +pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; pub const F_DUPFD: c_int = 0; pub const F_GETFD: c_int = 1; diff --git a/src/fcntl/src/linux.rs b/src/fcntl/src/linux.rs deleted file mode 100644 index fd68ffcf14..0000000000 --- a/src/fcntl/src/linux.rs +++ /dev/null @@ -1,8 +0,0 @@ -use platform::types::*; - -pub const O_RDONLY: c_int = 0x0000; -pub const O_WRONLY: c_int = 0x0001; -pub const O_RDWR: c_int = 0x0002; -pub const O_CREAT: c_int = 0x0040; -pub const O_TRUNC: c_int = 0x0200; -pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; diff --git a/src/fcntl/src/redox.rs b/src/fcntl/src/redox.rs deleted file mode 100644 index 1ea3ca45de..0000000000 --- a/src/fcntl/src/redox.rs +++ /dev/null @@ -1,20 +0,0 @@ -use platform::types::*; - -pub const O_RDONLY: c_int = 0x0001_0000; -pub const O_WRONLY: c_int = 0x0002_0000; -pub const O_RDWR: c_int = 0x0003_0000; -pub const O_NONBLOCK: c_int = 0x0004_0000; -pub const O_APPEND: c_int = 0x0008_0000; -pub const O_SHLOCK: c_int = 0x0010_0000; -pub const O_EXLOCK: c_int = 0x0020_0000; -pub const O_ASYNC: c_int = 0x0040_0000; -pub const O_FSYNC: c_int = 0x0080_0000; -pub const O_CLOEXEC: c_int = 0x0100_0000; -pub const O_CREAT: c_int = 0x0200_0000; -pub const O_TRUNC: c_int = 0x0400_0000; -pub const O_EXCL: c_int = 0x0800_0000; -pub const O_DIRECTORY: c_int = 0x1000_0000; -pub const O_STAT: c_int = 0x2000_0000; -pub const O_SYMLINK: c_int = 0x4000_0000; -pub const O_NOFOLLOW: c_int = 0x8000_0000; -pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR;