From 14f986e9a4a6d5d9b715a742268aa172d0488b90 Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Mon, 29 Aug 2016 22:44:38 +0200 Subject: [PATCH 01/13] [Step 2] Create the common module and submodules. --- src/unix/notbsd/linux/common/b32/arm.rs | 0 src/unix/notbsd/linux/common/b32/mips.rs | 0 src/unix/notbsd/linux/common/b32/mod.rs | 17 +++++++++++++++++ src/unix/notbsd/linux/common/b32/powerpc.rs | 0 src/unix/notbsd/linux/common/b32/x86.rs | 0 src/unix/notbsd/linux/common/b64/aarch64.rs | 0 src/unix/notbsd/linux/common/b64/mips64.rs | 0 src/unix/notbsd/linux/common/b64/mod.rs | 17 +++++++++++++++++ src/unix/notbsd/linux/common/b64/powerpc64.rs | 0 src/unix/notbsd/linux/common/b64/x86_64.rs | 0 src/unix/notbsd/linux/common/mod.rs | 17 +++++++++++++++++ 11 files changed, 51 insertions(+) create mode 100644 src/unix/notbsd/linux/common/b32/arm.rs create mode 100644 src/unix/notbsd/linux/common/b32/mips.rs create mode 100644 src/unix/notbsd/linux/common/b32/mod.rs create mode 100644 src/unix/notbsd/linux/common/b32/powerpc.rs create mode 100644 src/unix/notbsd/linux/common/b32/x86.rs create mode 100644 src/unix/notbsd/linux/common/b64/aarch64.rs create mode 100644 src/unix/notbsd/linux/common/b64/mips64.rs create mode 100644 src/unix/notbsd/linux/common/b64/mod.rs create mode 100644 src/unix/notbsd/linux/common/b64/powerpc64.rs create mode 100644 src/unix/notbsd/linux/common/b64/x86_64.rs create mode 100644 src/unix/notbsd/linux/common/mod.rs diff --git a/src/unix/notbsd/linux/common/b32/arm.rs b/src/unix/notbsd/linux/common/b32/arm.rs new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/unix/notbsd/linux/common/b32/mips.rs b/src/unix/notbsd/linux/common/b32/mips.rs new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/unix/notbsd/linux/common/b32/mod.rs b/src/unix/notbsd/linux/common/b32/mod.rs new file mode 100644 index 0000000000000..1f60a7a3c511e --- /dev/null +++ b/src/unix/notbsd/linux/common/b32/mod.rs @@ -0,0 +1,17 @@ +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "mips")] { + mod mips; + pub use self::mips::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else { + // Unknown target_arch + } +} diff --git a/src/unix/notbsd/linux/common/b32/powerpc.rs b/src/unix/notbsd/linux/common/b32/powerpc.rs new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/unix/notbsd/linux/common/b32/x86.rs b/src/unix/notbsd/linux/common/b32/x86.rs new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/unix/notbsd/linux/common/b64/aarch64.rs b/src/unix/notbsd/linux/common/b64/aarch64.rs new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/unix/notbsd/linux/common/b64/mips64.rs b/src/unix/notbsd/linux/common/b64/mips64.rs new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/unix/notbsd/linux/common/b64/mod.rs b/src/unix/notbsd/linux/common/b64/mod.rs new file mode 100644 index 0000000000000..18064a987a487 --- /dev/null +++ b/src/unix/notbsd/linux/common/b64/mod.rs @@ -0,0 +1,17 @@ +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(any(target_arch = "mips64"))] { + mod mips64; + pub use self::mips64::*; + } else if #[cfg(any(target_arch = "powerpc64"))] { + mod powerpc64; + pub use self::powerpc64::*; + } else if #[cfg(any(target_arch = "x86_64"))] { + mod x86_64; + pub use self::x86_64::*; + } else { + // Unknown target_arch + } +} diff --git a/src/unix/notbsd/linux/common/b64/powerpc64.rs b/src/unix/notbsd/linux/common/b64/powerpc64.rs new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/unix/notbsd/linux/common/b64/x86_64.rs b/src/unix/notbsd/linux/common/b64/x86_64.rs new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/unix/notbsd/linux/common/mod.rs b/src/unix/notbsd/linux/common/mod.rs new file mode 100644 index 0000000000000..82044af9c74f1 --- /dev/null +++ b/src/unix/notbsd/linux/common/mod.rs @@ -0,0 +1,17 @@ +cfg_if! { + if #[cfg(any(target_arch = "x86", + target_arch = "arm", + target_arch = "mips", + target_arch = "powerpc"))] { + mod b32; + pub use self::b32::*; + } else if #[cfg(any(target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "mips64", + target_arch = "powerpc64"))] { + mod b64; + pub use self::b64::*; + } else { + // Unknown target_arch + } +} From b7a30baa73e3ebcb12f5d6d56f58fe5c2a8b8af1 Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Mon, 29 Aug 2016 22:46:20 +0200 Subject: [PATCH 02/13] [Step 2] Make common module accessible from linux root module. --- src/unix/notbsd/linux/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 33738f4beb073..a223b60160d76 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -667,14 +667,22 @@ cfg_if! { target_os = "emscripten"))] { mod musl; pub use self::musl::*; + mod common; + pub use self::common::*; } else if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { mod mips; pub use self::mips::*; + mod common; + pub use self::common::*; } else if #[cfg(any(target_arch = "mips64"))] { mod mips64; pub use self::mips64::*; + mod common; + pub use self::common::*; } else { mod other; pub use self::other::*; + mod common; + pub use self::common::*; } } From 4cb130c07fa8658f667a382b0d773721abeda26a Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Mon, 29 Aug 2016 22:55:27 +0200 Subject: [PATCH 03/13] [Step 2] Move basic C type definitions to common module. --- src/unix/notbsd/linux/common/b32/arm.rs | 3 +++ src/unix/notbsd/linux/common/b32/mips.rs | 3 +++ src/unix/notbsd/linux/common/b32/mod.rs | 4 ++++ src/unix/notbsd/linux/common/b32/powerpc.rs | 3 +++ src/unix/notbsd/linux/common/b32/x86.rs | 3 +++ src/unix/notbsd/linux/common/b64/aarch64.rs | 3 +++ src/unix/notbsd/linux/common/b64/mips64.rs | 3 +++ src/unix/notbsd/linux/common/b64/mod.rs | 4 ++++ src/unix/notbsd/linux/common/b64/powerpc64.rs | 3 +++ src/unix/notbsd/linux/common/b64/x86_64.rs | 3 +++ src/unix/notbsd/linux/mips.rs | 3 --- src/unix/notbsd/linux/mips64.rs | 3 --- src/unix/notbsd/linux/musl/b32/arm.rs | 1 - src/unix/notbsd/linux/musl/b32/mips.rs | 1 - src/unix/notbsd/linux/musl/b32/mod.rs | 2 -- src/unix/notbsd/linux/musl/b32/x86.rs | 1 - src/unix/notbsd/linux/musl/b64/aarch64.rs | 2 -- src/unix/notbsd/linux/musl/b64/mod.rs | 2 -- src/unix/notbsd/linux/musl/b64/powerpc64.rs | 2 -- src/unix/notbsd/linux/musl/b64/x86_64.rs | 2 -- src/unix/notbsd/linux/other/b32/arm.rs | 1 - src/unix/notbsd/linux/other/b32/mod.rs | 2 -- src/unix/notbsd/linux/other/b32/powerpc.rs | 1 - src/unix/notbsd/linux/other/b32/x86.rs | 1 - src/unix/notbsd/linux/other/b64/aarch64.rs | 1 - src/unix/notbsd/linux/other/b64/mod.rs | 2 -- src/unix/notbsd/linux/other/b64/powerpc64.rs | 1 - src/unix/notbsd/linux/other/b64/x86_64.rs | 1 - 28 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/unix/notbsd/linux/common/b32/arm.rs b/src/unix/notbsd/linux/common/b32/arm.rs index e69de29bb2d1d..5eba776b9d586 100644 --- a/src/unix/notbsd/linux/common/b32/arm.rs +++ b/src/unix/notbsd/linux/common/b32/arm.rs @@ -0,0 +1,3 @@ +// Native C types +pub type c_char = u8; + diff --git a/src/unix/notbsd/linux/common/b32/mips.rs b/src/unix/notbsd/linux/common/b32/mips.rs index e69de29bb2d1d..1c1524b5d058c 100644 --- a/src/unix/notbsd/linux/common/b32/mips.rs +++ b/src/unix/notbsd/linux/common/b32/mips.rs @@ -0,0 +1,3 @@ +// Native C types +pub type c_char = i8; + diff --git a/src/unix/notbsd/linux/common/b32/mod.rs b/src/unix/notbsd/linux/common/b32/mod.rs index 1f60a7a3c511e..c53bf01fee2f8 100644 --- a/src/unix/notbsd/linux/common/b32/mod.rs +++ b/src/unix/notbsd/linux/common/b32/mod.rs @@ -1,3 +1,7 @@ +// Native C types +pub type c_long = i32; +pub type c_ulong = u32; + cfg_if! { if #[cfg(target_arch = "x86")] { mod x86; diff --git a/src/unix/notbsd/linux/common/b32/powerpc.rs b/src/unix/notbsd/linux/common/b32/powerpc.rs index e69de29bb2d1d..5eba776b9d586 100644 --- a/src/unix/notbsd/linux/common/b32/powerpc.rs +++ b/src/unix/notbsd/linux/common/b32/powerpc.rs @@ -0,0 +1,3 @@ +// Native C types +pub type c_char = u8; + diff --git a/src/unix/notbsd/linux/common/b32/x86.rs b/src/unix/notbsd/linux/common/b32/x86.rs index e69de29bb2d1d..1c1524b5d058c 100644 --- a/src/unix/notbsd/linux/common/b32/x86.rs +++ b/src/unix/notbsd/linux/common/b32/x86.rs @@ -0,0 +1,3 @@ +// Native C types +pub type c_char = i8; + diff --git a/src/unix/notbsd/linux/common/b64/aarch64.rs b/src/unix/notbsd/linux/common/b64/aarch64.rs index e69de29bb2d1d..5eba776b9d586 100644 --- a/src/unix/notbsd/linux/common/b64/aarch64.rs +++ b/src/unix/notbsd/linux/common/b64/aarch64.rs @@ -0,0 +1,3 @@ +// Native C types +pub type c_char = u8; + diff --git a/src/unix/notbsd/linux/common/b64/mips64.rs b/src/unix/notbsd/linux/common/b64/mips64.rs index e69de29bb2d1d..1c1524b5d058c 100644 --- a/src/unix/notbsd/linux/common/b64/mips64.rs +++ b/src/unix/notbsd/linux/common/b64/mips64.rs @@ -0,0 +1,3 @@ +// Native C types +pub type c_char = i8; + diff --git a/src/unix/notbsd/linux/common/b64/mod.rs b/src/unix/notbsd/linux/common/b64/mod.rs index 18064a987a487..f4767f3f49198 100644 --- a/src/unix/notbsd/linux/common/b64/mod.rs +++ b/src/unix/notbsd/linux/common/b64/mod.rs @@ -1,3 +1,7 @@ +// Native C types +pub type c_long = i64; +pub type c_ulong = u64; + cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/src/unix/notbsd/linux/common/b64/powerpc64.rs b/src/unix/notbsd/linux/common/b64/powerpc64.rs index e69de29bb2d1d..5eba776b9d586 100644 --- a/src/unix/notbsd/linux/common/b64/powerpc64.rs +++ b/src/unix/notbsd/linux/common/b64/powerpc64.rs @@ -0,0 +1,3 @@ +// Native C types +pub type c_char = u8; + diff --git a/src/unix/notbsd/linux/common/b64/x86_64.rs b/src/unix/notbsd/linux/common/b64/x86_64.rs index e69de29bb2d1d..1c1524b5d058c 100644 --- a/src/unix/notbsd/linux/common/b64/x86_64.rs +++ b/src/unix/notbsd/linux/common/b64/x86_64.rs @@ -0,0 +1,3 @@ +// Native C types +pub type c_char = i8; + diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index a2143d5e2039a..2551fd09b3047 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -1,6 +1,3 @@ -pub type c_char = i8; -pub type c_long = i32; -pub type c_ulong = u32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; diff --git a/src/unix/notbsd/linux/mips64.rs b/src/unix/notbsd/linux/mips64.rs index 7c51dffba44ac..f3eefa2ba9dc2 100644 --- a/src/unix/notbsd/linux/mips64.rs +++ b/src/unix/notbsd/linux/mips64.rs @@ -1,8 +1,5 @@ pub type blkcnt_t = i64; pub type blksize_t = i64; -pub type c_char = i8; -pub type c_long = i64; -pub type c_ulong = u64; pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; pub type ino_t = u64; diff --git a/src/unix/notbsd/linux/musl/b32/arm.rs b/src/unix/notbsd/linux/musl/b32/arm.rs index 2f27e31136a8b..8e562e0e0fb72 100644 --- a/src/unix/notbsd/linux/musl/b32/arm.rs +++ b/src/unix/notbsd/linux/musl/b32/arm.rs @@ -1,4 +1,3 @@ -pub type c_char = u8; pub type wchar_t = u32; s! { diff --git a/src/unix/notbsd/linux/musl/b32/mips.rs b/src/unix/notbsd/linux/musl/b32/mips.rs index 88542c45b4fde..c9cdae185779a 100644 --- a/src/unix/notbsd/linux/musl/b32/mips.rs +++ b/src/unix/notbsd/linux/musl/b32/mips.rs @@ -1,4 +1,3 @@ -pub type c_char = i8; pub type wchar_t = ::c_int; s! { diff --git a/src/unix/notbsd/linux/musl/b32/mod.rs b/src/unix/notbsd/linux/musl/b32/mod.rs index 6ae90bd04eb93..cafdea0180b88 100644 --- a/src/unix/notbsd/linux/musl/b32/mod.rs +++ b/src/unix/notbsd/linux/musl/b32/mod.rs @@ -1,5 +1,3 @@ -pub type c_long = i32; -pub type c_ulong = u32; pub type nlink_t = u32; s! { diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs index 593c37a261620..078a80ebf10e6 100644 --- a/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/src/unix/notbsd/linux/musl/b32/x86.rs @@ -1,4 +1,3 @@ -pub type c_char = i8; pub type wchar_t = i32; s! { diff --git a/src/unix/notbsd/linux/musl/b64/aarch64.rs b/src/unix/notbsd/linux/musl/b64/aarch64.rs index 23f7dd35e5c98..51db30f2f1a67 100644 --- a/src/unix/notbsd/linux/musl/b64/aarch64.rs +++ b/src/unix/notbsd/linux/musl/b64/aarch64.rs @@ -1,3 +1 @@ -pub type c_char = u8; - pub const SYS_perf_event_open: ::c_long = 241; diff --git a/src/unix/notbsd/linux/musl/b64/mod.rs b/src/unix/notbsd/linux/musl/b64/mod.rs index 227bffa1368cc..a407f07591e98 100644 --- a/src/unix/notbsd/linux/musl/b64/mod.rs +++ b/src/unix/notbsd/linux/musl/b64/mod.rs @@ -1,6 +1,4 @@ pub type wchar_t = i32; -pub type c_long = i64; -pub type c_ulong = u64; pub type nlink_t = u64; s! { diff --git a/src/unix/notbsd/linux/musl/b64/powerpc64.rs b/src/unix/notbsd/linux/musl/b64/powerpc64.rs index 4b8ca10aab57b..bb81863654136 100644 --- a/src/unix/notbsd/linux/musl/b64/powerpc64.rs +++ b/src/unix/notbsd/linux/musl/b64/powerpc64.rs @@ -1,3 +1 @@ -pub type c_char = u8; - pub const SYS_perf_event_open: ::c_long = 319; diff --git a/src/unix/notbsd/linux/musl/b64/x86_64.rs b/src/unix/notbsd/linux/musl/b64/x86_64.rs index 2cfd903ca84fb..02324dae3029f 100644 --- a/src/unix/notbsd/linux/musl/b64/x86_64.rs +++ b/src/unix/notbsd/linux/musl/b64/x86_64.rs @@ -1,5 +1,3 @@ -pub type c_char = i8; - s! { pub struct mcontext_t { __private: [u64; 32], diff --git a/src/unix/notbsd/linux/other/b32/arm.rs b/src/unix/notbsd/linux/other/b32/arm.rs index f3871f3c2ffba..3913ee1d6c4d3 100644 --- a/src/unix/notbsd/linux/other/b32/arm.rs +++ b/src/unix/notbsd/linux/other/b32/arm.rs @@ -1,4 +1,3 @@ -pub type c_char = u8; pub type wchar_t = u32; s! { diff --git a/src/unix/notbsd/linux/other/b32/mod.rs b/src/unix/notbsd/linux/other/b32/mod.rs index 48c3502ada1b6..9eca1582fb3ed 100644 --- a/src/unix/notbsd/linux/other/b32/mod.rs +++ b/src/unix/notbsd/linux/other/b32/mod.rs @@ -1,7 +1,5 @@ //! 32-bit specific definitions for linux-like values -pub type c_long = i32; -pub type c_ulong = u32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; diff --git a/src/unix/notbsd/linux/other/b32/powerpc.rs b/src/unix/notbsd/linux/other/b32/powerpc.rs index ef21eda0ce5cc..9d965bd98ec6f 100644 --- a/src/unix/notbsd/linux/other/b32/powerpc.rs +++ b/src/unix/notbsd/linux/other/b32/powerpc.rs @@ -1,4 +1,3 @@ -pub type c_char = u8; pub type wchar_t = i32; s! { diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index 6f8587a89363b..82472660489b9 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -1,4 +1,3 @@ -pub type c_char = i8; pub type wchar_t = i32; pub type greg_t = i32; diff --git a/src/unix/notbsd/linux/other/b64/aarch64.rs b/src/unix/notbsd/linux/other/b64/aarch64.rs index d9f940bc399af..ae6e34bac286a 100644 --- a/src/unix/notbsd/linux/other/b64/aarch64.rs +++ b/src/unix/notbsd/linux/other/b64/aarch64.rs @@ -1,6 +1,5 @@ //! AArch64-specific definitions for 64-bit linux-like values -pub type c_char = u8; pub type wchar_t = u32; pub type nlink_t = u32; pub type blksize_t = i32; diff --git a/src/unix/notbsd/linux/other/b64/mod.rs b/src/unix/notbsd/linux/other/b64/mod.rs index ccf99881f76cc..3664cce38f2af 100644 --- a/src/unix/notbsd/linux/other/b64/mod.rs +++ b/src/unix/notbsd/linux/other/b64/mod.rs @@ -1,7 +1,5 @@ //! 64-bit specific definitions for linux-like values -pub type c_long = i64; -pub type c_ulong = u64; pub type clock_t = i64; pub type time_t = i64; pub type suseconds_t = i64; diff --git a/src/unix/notbsd/linux/other/b64/powerpc64.rs b/src/unix/notbsd/linux/other/b64/powerpc64.rs index c5ce962e39aa1..ea3234bb3a46e 100644 --- a/src/unix/notbsd/linux/other/b64/powerpc64.rs +++ b/src/unix/notbsd/linux/other/b64/powerpc64.rs @@ -1,6 +1,5 @@ //! PowerPC64-specific definitions for 64-bit linux-like values -pub type c_char = u8; pub type wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = i64; diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index f19a9ffe4adcd..89cfb2ce0cb4d 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -1,6 +1,5 @@ //! x86_64-specific definitions for 64-bit linux-like values -pub type c_char = i8; pub type wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = i64; From 844f8026cd7e8012c096941e17655497c09a3199 Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Tue, 30 Aug 2016 00:54:41 +0200 Subject: [PATCH 04/13] [Step 3][fcntl.h] Types and structures. --- src/unix/notbsd/linux/common/b32/arm.rs | 17 +++++++++++++++++ src/unix/notbsd/linux/common/b32/mips.rs | 19 +++++++++++++++++++ src/unix/notbsd/linux/common/b32/powerpc.rs | 17 +++++++++++++++++ src/unix/notbsd/linux/common/b32/x86.rs | 17 +++++++++++++++++ src/unix/notbsd/linux/common/b64/mod.rs | 17 +++++++++++++++++ src/unix/notbsd/linux/common/mod.rs | 21 +++++++++++++++++++++ src/unix/notbsd/linux/mips.rs | 11 ----------- src/unix/notbsd/linux/mips64.rs | 1 - src/unix/notbsd/linux/mod.rs | 5 +++-- src/unix/notbsd/linux/musl/mod.rs | 9 --------- src/unix/notbsd/linux/other/b32/mod.rs | 1 - src/unix/notbsd/linux/other/b64/mod.rs | 1 - src/unix/notbsd/linux/other/gnu.rs | 8 ++++++++ src/unix/notbsd/linux/other/mod.rs | 21 +++++++++++++-------- src/unix/notbsd/linux/other/uclibc.rs | 0 15 files changed, 132 insertions(+), 33 deletions(-) create mode 100644 src/unix/notbsd/linux/other/gnu.rs create mode 100644 src/unix/notbsd/linux/other/uclibc.rs diff --git a/src/unix/notbsd/linux/common/b32/arm.rs b/src/unix/notbsd/linux/common/b32/arm.rs index 5eba776b9d586..dbe3be80bd28c 100644 --- a/src/unix/notbsd/linux/common/b32/arm.rs +++ b/src/unix/notbsd/linux/common/b32/arm.rs @@ -1,3 +1,20 @@ // Native C types pub type c_char = u8; +s! { + /* Header */ + cfg_if! { + if #[cfg(feature = "file_offset64")] { + type flock = ::flock64; + } else { + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + } + } +} + diff --git a/src/unix/notbsd/linux/common/b32/mips.rs b/src/unix/notbsd/linux/common/b32/mips.rs index 1c1524b5d058c..ecf7745fb9464 100644 --- a/src/unix/notbsd/linux/common/b32/mips.rs +++ b/src/unix/notbsd/linux/common/b32/mips.rs @@ -1,3 +1,22 @@ // Native C types pub type c_char = i8; +s! { + /* Header */ + cfg_if! { + if #[cfg(feature = "file_offset64")] { + type flock = ::flock64; + } else { + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_sysid: ::c_long, + pub l_pid: ::pid_t, + pad: [::c_long; 4], + } + } + } +} + diff --git a/src/unix/notbsd/linux/common/b32/powerpc.rs b/src/unix/notbsd/linux/common/b32/powerpc.rs index 5eba776b9d586..dbe3be80bd28c 100644 --- a/src/unix/notbsd/linux/common/b32/powerpc.rs +++ b/src/unix/notbsd/linux/common/b32/powerpc.rs @@ -1,3 +1,20 @@ // Native C types pub type c_char = u8; +s! { + /* Header */ + cfg_if! { + if #[cfg(feature = "file_offset64")] { + type flock = ::flock64; + } else { + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + } + } +} + diff --git a/src/unix/notbsd/linux/common/b32/x86.rs b/src/unix/notbsd/linux/common/b32/x86.rs index 1c1524b5d058c..f7d8fb8703ae9 100644 --- a/src/unix/notbsd/linux/common/b32/x86.rs +++ b/src/unix/notbsd/linux/common/b32/x86.rs @@ -1,3 +1,20 @@ // Native C types pub type c_char = i8; +s! { + /* Header */ + cfg_if! { + if #[cfg(feature = "file_offset64")] { + type flock = ::flock64; + } else { + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + } + } +} + diff --git a/src/unix/notbsd/linux/common/b64/mod.rs b/src/unix/notbsd/linux/common/b64/mod.rs index f4767f3f49198..f56d904e28d91 100644 --- a/src/unix/notbsd/linux/common/b64/mod.rs +++ b/src/unix/notbsd/linux/common/b64/mod.rs @@ -2,6 +2,23 @@ pub type c_long = i64; pub type c_ulong = u64; +/* Header */ +cfg_if! { + if #[cfg(feature = "file_offset64")] { + type flock = ::flock64; + } else { + s! { + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + } + } +} + cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/src/unix/notbsd/linux/common/mod.rs b/src/unix/notbsd/linux/common/mod.rs index 82044af9c74f1..b061448d14a19 100644 --- a/src/unix/notbsd/linux/common/mod.rs +++ b/src/unix/notbsd/linux/common/mod.rs @@ -1,3 +1,24 @@ +/* Header */ +cfg_if! { + if #[cfg(feature = "file_offset64")] { + pub type off_t = ::off64_t; + } else { + pub type off_t = ::c_long; + } +} +pub type off64_t = ::int64_t; + +s! { + /* Header */ + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } +} + cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "arm", diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index 2551fd09b3047..c98d8eb3d094c 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -2,7 +2,6 @@ pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; pub type wchar_t = i32; -pub type off_t = i32; pub type ino_t = u32; pub type blkcnt_t = i32; pub type blksize_t = i32; @@ -160,16 +159,6 @@ s! { pub c_cc: [::cc_t; ::NCCS], } - pub struct flock { - pub l_type: ::c_short, - pub l_whence: ::c_short, - pub l_start: ::off_t, - pub l_len: ::off_t, - pub l_sysid: ::c_long, - pub l_pid: ::pid_t, - pad: [::c_long; 4], - } - pub struct sysinfo { pub uptime: ::c_long, pub loads: [::c_ulong; 3], diff --git a/src/unix/notbsd/linux/mips64.rs b/src/unix/notbsd/linux/mips64.rs index f3eefa2ba9dc2..cda1cb29ef7f3 100644 --- a/src/unix/notbsd/linux/mips64.rs +++ b/src/unix/notbsd/linux/mips64.rs @@ -4,7 +4,6 @@ pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; pub type ino_t = u64; pub type nlink_t = u64; -pub type off_t = i64; pub type rlim_t = ::c_ulong; pub type suseconds_t = i64; pub type time_t = i64; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index a223b60160d76..97e3dc8b1b35d 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -6,9 +6,7 @@ pub type useconds_t = u32; pub type dev_t = u64; pub type socklen_t = u32; pub type pthread_t = c_ulong; -pub type mode_t = u32; pub type ino64_t = u64; -pub type off64_t = i64; pub type blkcnt64_t = i64; pub type rlim64_t = u64; pub type key_t = ::c_int; @@ -19,6 +17,9 @@ pub type nl_item = ::c_int; pub enum fpos64_t {} // TODO: fill this out with a struct +/* Header */ +pub type mode_t = ::uint32_t; + s! { pub struct dirent { pub d_ino: ::ino_t, diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index b9fb3d42f3ac3..8262fd30c0364 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -2,7 +2,6 @@ pub type clock_t = c_long; pub type time_t = c_long; pub type suseconds_t = c_long; pub type ino_t = u64; -pub type off_t = i64; pub type blkcnt_t = i64; pub type blksize_t = c_long; @@ -41,14 +40,6 @@ s! { pub __c_ospeed: ::speed_t, } - pub struct flock { - pub l_type: ::c_short, - pub l_whence: ::c_short, - pub l_start: ::off_t, - pub l_len: ::off_t, - pub l_pid: ::pid_t, - } - pub struct sysinfo { pub uptime: ::c_ulong, pub loads: [::c_ulong; 3], diff --git a/src/unix/notbsd/linux/other/b32/mod.rs b/src/unix/notbsd/linux/other/b32/mod.rs index 9eca1582fb3ed..4a936070f3406 100644 --- a/src/unix/notbsd/linux/other/b32/mod.rs +++ b/src/unix/notbsd/linux/other/b32/mod.rs @@ -4,7 +4,6 @@ pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; pub type ino_t = u32; -pub type off_t = i32; pub type blkcnt_t = i32; pub type __fsword_t = i32; diff --git a/src/unix/notbsd/linux/other/b64/mod.rs b/src/unix/notbsd/linux/other/b64/mod.rs index 3664cce38f2af..3fc3fc2283087 100644 --- a/src/unix/notbsd/linux/other/b64/mod.rs +++ b/src/unix/notbsd/linux/other/b64/mod.rs @@ -4,7 +4,6 @@ pub type clock_t = i64; pub type time_t = i64; pub type suseconds_t = i64; pub type ino_t = u64; -pub type off_t = i64; pub type blkcnt_t = i64; pub type __fsword_t = ::c_long; diff --git a/src/unix/notbsd/linux/other/gnu.rs b/src/unix/notbsd/linux/other/gnu.rs new file mode 100644 index 0000000000000..757e391d66410 --- /dev/null +++ b/src/unix/notbsd/linux/other/gnu.rs @@ -0,0 +1,8 @@ +s! { + /* Header */ + pub struct file_handle { + pub handle_bytes: ::c_uint, + pub handle_type: ::c_int, + pub f_handle: [::c_uchar], + } +} diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index ac3e0c39797a4..923b31bd1b37e 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -115,14 +115,6 @@ s! { pub c_ospeed: ::speed_t, } - pub struct flock { - pub l_type: ::c_short, - pub l_whence: ::c_short, - pub l_start: ::off_t, - pub l_len: ::off_t, - pub l_pid: ::pid_t, - } - // FIXME this is actually a union pub struct sem_t { #[cfg(target_pointer_width = "32")] @@ -555,3 +547,16 @@ cfg_if! { // Unknown target_arch } } + +cfg_if! { + if #[cfg(target_env = "gnu")] { + mod gnu; + pub use self::gnu::*; + } else if #[cfg(target_env = "uclibc")] { + mod uclibc; + pub use self::uclibc::*; + } else { + // Unknown target_env + } +} + diff --git a/src/unix/notbsd/linux/other/uclibc.rs b/src/unix/notbsd/linux/other/uclibc.rs new file mode 100644 index 0000000000000..e69de29bb2d1d From 084c86d466c974cab3c0e4bf586deed30155acc6 Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Tue, 30 Aug 2016 12:05:30 +0200 Subject: [PATCH 05/13] [Step 3][fcntl.h] POSIX macros and functions. --- src/unix/mod.rs | 26 ++++--- src/unix/notbsd/linux/common/b32/arm.rs | 27 +++++++ src/unix/notbsd/linux/common/b32/mips.rs | 27 +++++++ src/unix/notbsd/linux/common/b32/mod.rs | 7 ++ src/unix/notbsd/linux/common/b32/powerpc.rs | 27 +++++++ src/unix/notbsd/linux/common/b32/x86.rs | 27 +++++++ src/unix/notbsd/linux/common/b64/aarch64.rs | 21 +++++ src/unix/notbsd/linux/common/b64/mips64.rs | 21 +++++ src/unix/notbsd/linux/common/b64/powerpc64.rs | 21 +++++ src/unix/notbsd/linux/common/b64/x86_64.rs | 21 +++++ src/unix/notbsd/linux/common/mod.rs | 5 ++ src/unix/notbsd/linux/mips.rs | 16 ---- src/unix/notbsd/linux/mips64.rs | 4 - src/unix/notbsd/linux/mod.rs | 2 - src/unix/notbsd/linux/musl/b32/arm.rs | 17 ----- src/unix/notbsd/linux/musl/b32/asmjs.rs | 28 ++++--- src/unix/notbsd/linux/musl/b32/mips.rs | 17 ----- src/unix/notbsd/linux/musl/b32/x86.rs | 17 ----- src/unix/notbsd/linux/musl/b64/mod.rs | 17 ----- src/unix/notbsd/linux/musl/mod.rs | 8 +- src/unix/notbsd/linux/other/gnu.rs | 11 +++ src/unix/notbsd/linux/other/mod.rs | 18 +---- src/unix/notbsd/mod.rs | 76 +++++++++++-------- 23 files changed, 302 insertions(+), 159 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 648a7aa6fe836..39822544c15cf 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -133,8 +133,6 @@ pub const DT_REG: u8 = 8; pub const DT_LNK: u8 = 10; pub const DT_SOCK: u8 = 12; -pub const FD_CLOEXEC: ::c_int = 0x1; - pub const USRQUOTA: ::c_int = 0; pub const GRPQUOTA: ::c_int = 1; @@ -198,6 +196,9 @@ pub const PRIO_USER: ::c_int = 2; pub const PRIO_MIN: ::c_int = -20; pub const PRIO_MAX: ::c_int = 20; +/* Header */ +pub const FD_CLOEXEC: ::c_int = 0x1; + cfg_if! { if #[cfg(dox)] { // on dox builds don't pull in anything @@ -318,16 +319,6 @@ extern { pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; pub fn fileno(stream: *mut ::FILE) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "open$UNIX2003")] - pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "creat$UNIX2003")] - pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fcntl$UNIX2003")] - pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "opendir$INODE64")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), @@ -715,6 +706,17 @@ extern { pshared: ::c_int, value: ::c_uint) -> ::c_int; + + /* Header */ + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "creat$UNIX2003")] + pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fcntl$UNIX2003")] + pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "open$UNIX2003")] + pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; } // TODO: get rid of this cfg(not(...)) diff --git a/src/unix/notbsd/linux/common/b32/arm.rs b/src/unix/notbsd/linux/common/b32/arm.rs index dbe3be80bd28c..3200e250b674f 100644 --- a/src/unix/notbsd/linux/common/b32/arm.rs +++ b/src/unix/notbsd/linux/common/b32/arm.rs @@ -18,3 +18,30 @@ s! { } } +/* Header */ +if #[cfg(feature = "file_offset64")] { + pub const F_GETLK: ::c_int = 5; + pub const F_SETLK: ::c_int = 6; + pub const F_SETLKW: ::c_int = 7; +} +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; + +pub const F_GETLK64: ::c_int = 12; +pub const F_SETLK64: ::c_int = 13; +pub const F_SETLKW64: ::c_int = 14; + +// O_CLOEXEC is defined in notbsd/mod.rs +pub const O_CREAT: ::c_int = 0x40; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_EXCL: ::c_int = 0x80; +pub const O_NOCTTY: ::c_int = 0x100; +pub const O_NOFOLLOW: ::c_int = 0x8000; +// O_TRUNC is defined in notbsd/mod.rs + +pub const O_APPEND: ::c_int = 0x400; +pub const O_DSYNC: ::c_int = 0x1000; +pub const O_NONBLOCK: ::c_int = 0x800; +pub const O_RSYNC: ::c_int = 0x101000; +pub const O_SYNC: ::c_int = 0x101000; + diff --git a/src/unix/notbsd/linux/common/b32/mips.rs b/src/unix/notbsd/linux/common/b32/mips.rs index ecf7745fb9464..8e115c012ae11 100644 --- a/src/unix/notbsd/linux/common/b32/mips.rs +++ b/src/unix/notbsd/linux/common/b32/mips.rs @@ -20,3 +20,30 @@ s! { } } +/* Header */ +if #[cfg(feature = "file_offset64")] { + pub const F_GETLK: ::c_int = 14; + pub const F_SETLK: ::c_int = 6; + pub const F_SETLKW: ::c_int = 7; +} +pub const F_GETOWN: ::c_int = 23; +pub const F_SETOWN: ::c_int = 24; + +pub const F_GETLK64: ::c_int = 33; +pub const F_SETLK64: ::c_int = 34; +pub const F_SETLKW64: ::c_int = 35; + +// O_CLOEXEC is defined in notbsd/mod.rs +pub const O_CREAT: ::c_int = 0x100; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_EXCL: ::c_int = 0x400; +pub const O_NOCTTY: ::c_int = 0x800; +pub const O_NOFOLLOW: ::c_int = 0x20000; +// O_TRUNC is defined in notbsd/mod.rs + +pub const O_APPEND: ::c_int = 0x8; +pub const O_DSYNC: ::c_int = 0x10; +pub const O_NONBLOCK: ::c_int = 0x80; +pub const O_RSYNC: ::c_int = 0x4010; +pub const O_SYNC: ::c_int = 0x4010; + diff --git a/src/unix/notbsd/linux/common/b32/mod.rs b/src/unix/notbsd/linux/common/b32/mod.rs index c53bf01fee2f8..53047fefe4eb7 100644 --- a/src/unix/notbsd/linux/common/b32/mod.rs +++ b/src/unix/notbsd/linux/common/b32/mod.rs @@ -19,3 +19,10 @@ cfg_if! { // Unknown target_arch } } + +/* Header */ +if #[cfg(feature = "file_offset64")] { + pub const F_GETLK: ::c_int = ::F_GETLK64; + pub const F_SETLK: ::c_int = ::F_SETLK64; + pub const F_SETLKW: ::c_int = ::F_SETLKW64; +} diff --git a/src/unix/notbsd/linux/common/b32/powerpc.rs b/src/unix/notbsd/linux/common/b32/powerpc.rs index dbe3be80bd28c..3200e250b674f 100644 --- a/src/unix/notbsd/linux/common/b32/powerpc.rs +++ b/src/unix/notbsd/linux/common/b32/powerpc.rs @@ -18,3 +18,30 @@ s! { } } +/* Header */ +if #[cfg(feature = "file_offset64")] { + pub const F_GETLK: ::c_int = 5; + pub const F_SETLK: ::c_int = 6; + pub const F_SETLKW: ::c_int = 7; +} +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; + +pub const F_GETLK64: ::c_int = 12; +pub const F_SETLK64: ::c_int = 13; +pub const F_SETLKW64: ::c_int = 14; + +// O_CLOEXEC is defined in notbsd/mod.rs +pub const O_CREAT: ::c_int = 0x40; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_EXCL: ::c_int = 0x80; +pub const O_NOCTTY: ::c_int = 0x100; +pub const O_NOFOLLOW: ::c_int = 0x8000; +// O_TRUNC is defined in notbsd/mod.rs + +pub const O_APPEND: ::c_int = 0x400; +pub const O_DSYNC: ::c_int = 0x1000; +pub const O_NONBLOCK: ::c_int = 0x800; +pub const O_RSYNC: ::c_int = 0x101000; +pub const O_SYNC: ::c_int = 0x101000; + diff --git a/src/unix/notbsd/linux/common/b32/x86.rs b/src/unix/notbsd/linux/common/b32/x86.rs index f7d8fb8703ae9..747355904374c 100644 --- a/src/unix/notbsd/linux/common/b32/x86.rs +++ b/src/unix/notbsd/linux/common/b32/x86.rs @@ -18,3 +18,30 @@ s! { } } +/* Header */ +if #[cfg(feature = "file_offset64")] { + pub const F_GETLK: ::c_int = 5; + pub const F_SETLK: ::c_int = 6; + pub const F_SETLKW: ::c_int = 7; +} +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; + +pub const F_GETLK64: ::c_int = 12; +pub const F_SETLK64: ::c_int = 13; +pub const F_SETLKW64: ::c_int = 14; + +// O_CLOEXEC is defined in notbsd/mod.rs +pub const O_CREAT: ::c_int = 0x40; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_EXCL: ::c_int = 0x80; +pub const O_NOCTTY: ::c_int = 0x100; +pub const O_NOFOLLOW: ::c_int = 0x20000; +// O_TRUNC is defined in notbsd/mod.rs + +pub const O_APPEND: ::c_int = 0x400; +pub const O_DSYNC: ::c_int = 0x1000; +pub const O_NONBLOCK: ::c_int = 0x800; +pub const O_RSYNC: ::c_int = 0x101000; +pub const O_SYNC: ::c_int = 0x101000; + diff --git a/src/unix/notbsd/linux/common/b64/aarch64.rs b/src/unix/notbsd/linux/common/b64/aarch64.rs index 5eba776b9d586..7a40edc5c6836 100644 --- a/src/unix/notbsd/linux/common/b64/aarch64.rs +++ b/src/unix/notbsd/linux/common/b64/aarch64.rs @@ -1,3 +1,24 @@ // Native C types pub type c_char = u8; +/* Header */ +pub const F_GETLK: ::c_int = 5; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; + +// O_CLOEXEC is defined in notbsd/mod.rs +pub const O_CREAT: ::c_int = 0x40; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_EXCL: ::c_int = 0x80; +pub const O_NOCTTY: ::c_int = 0x100; +pub const O_NOFOLLOW: ::c_int = 0x8000; +// O_TRUNC is defined in notbsd/mod.rs + +pub const O_APPEND: ::c_int = 0x400; +pub const O_DSYNC: ::c_int = 0x1000; +pub const O_NONBLOCK: ::c_int = 0x800; +pub const O_RSYNC: ::c_int = 0x101000; +pub const O_SYNC: ::c_int = 0x101000; + diff --git a/src/unix/notbsd/linux/common/b64/mips64.rs b/src/unix/notbsd/linux/common/b64/mips64.rs index 1c1524b5d058c..1337e84b5e7e7 100644 --- a/src/unix/notbsd/linux/common/b64/mips64.rs +++ b/src/unix/notbsd/linux/common/b64/mips64.rs @@ -1,3 +1,24 @@ // Native C types pub type c_char = i8; +/* Header */ +pub const F_GETLK: ::c_int = 14; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_GETOWN: ::c_int = 23; +pub const F_SETOWN: ::c_int = 24; + +// O_CLOEXEC is defined in notbsd/mod.rs +pub const O_CREAT: ::c_int = 0x100; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_EXCL: ::c_int = 0x400; +pub const O_NOCTTY: ::c_int = 0x800; +pub const O_NOFOLLOW: ::c_int = 0x20000; +// O_TRUNC is defined in notbsd/mod.rs + +pub const O_APPEND: ::c_int = 0x8; +pub const O_DSYNC: ::c_int = 0x10; +pub const O_NONBLOCK: ::c_int = 0x80; +pub const O_RSYNC: ::c_int = 0x4010; +pub const O_SYNC: ::c_int = 0x4010; + diff --git a/src/unix/notbsd/linux/common/b64/powerpc64.rs b/src/unix/notbsd/linux/common/b64/powerpc64.rs index 5eba776b9d586..7a40edc5c6836 100644 --- a/src/unix/notbsd/linux/common/b64/powerpc64.rs +++ b/src/unix/notbsd/linux/common/b64/powerpc64.rs @@ -1,3 +1,24 @@ // Native C types pub type c_char = u8; +/* Header */ +pub const F_GETLK: ::c_int = 5; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; + +// O_CLOEXEC is defined in notbsd/mod.rs +pub const O_CREAT: ::c_int = 0x40; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_EXCL: ::c_int = 0x80; +pub const O_NOCTTY: ::c_int = 0x100; +pub const O_NOFOLLOW: ::c_int = 0x8000; +// O_TRUNC is defined in notbsd/mod.rs + +pub const O_APPEND: ::c_int = 0x400; +pub const O_DSYNC: ::c_int = 0x1000; +pub const O_NONBLOCK: ::c_int = 0x800; +pub const O_RSYNC: ::c_int = 0x101000; +pub const O_SYNC: ::c_int = 0x101000; + diff --git a/src/unix/notbsd/linux/common/b64/x86_64.rs b/src/unix/notbsd/linux/common/b64/x86_64.rs index 1c1524b5d058c..b32f5278553ed 100644 --- a/src/unix/notbsd/linux/common/b64/x86_64.rs +++ b/src/unix/notbsd/linux/common/b64/x86_64.rs @@ -1,3 +1,24 @@ // Native C types pub type c_char = i8; +/* Header */ +pub const F_GETLK: ::c_int = 5; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; + +// O_CLOEXEC is defined in notbsd/mod.rs +pub const O_CREAT: ::c_int = 0x40; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_EXCL: ::c_int = 0x80; +pub const O_NOCTTY: ::c_int = 0x100; +pub const O_NOFOLLOW: ::c_int = 0x20000; +// O_TRUNC is defined in notbsd/mod.rs + +pub const O_APPEND: ::c_int = 0x400; +pub const O_DSYNC: ::c_int = 0x1000; +pub const O_NONBLOCK: ::c_int = 0x800; +pub const O_RSYNC: ::c_int = 0x101000; +pub const O_SYNC: ::c_int = 0x101000; + diff --git a/src/unix/notbsd/linux/common/mod.rs b/src/unix/notbsd/linux/common/mod.rs index b061448d14a19..cedbb30b4bed4 100644 --- a/src/unix/notbsd/linux/common/mod.rs +++ b/src/unix/notbsd/linux/common/mod.rs @@ -36,3 +36,8 @@ cfg_if! { // Unknown target_arch } } + +/* Header */ +pub const F_RDLCK: ::c_short = 0; +pub const F_WRLCK: ::c_short = 1; +pub const F_UNLCK: ::c_short = 2; diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index c98d8eb3d094c..eff10f6b2ae5f 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -194,8 +194,6 @@ pub const _SC_2_C_VERSION: ::c_int = 96; pub const RUSAGE_THREAD: ::c_int = 1; pub const O_ACCMODE: ::c_int = 3; pub const O_DIRECT: ::c_int = 0x8000; -pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_NOFOLLOW: ::c_int = 0x20000; pub const RUSAGE_CHILDREN: ::c_int = -1; pub const ST_RELATIME: ::c_ulong = 4096; pub const NI_MAXHOST: ::socklen_t = 1025; @@ -208,14 +206,6 @@ pub const RLIMIT_MEMLOCK: ::c_int = 9; pub const RLIMIT_NLIMITS: ::c_int = 16; pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; -pub const O_APPEND: ::c_int = 8; -pub const O_CREAT: ::c_int = 256; -pub const O_EXCL: ::c_int = 1024; -pub const O_NOCTTY: ::c_int = 2048; -pub const O_NONBLOCK: ::c_int = 128; -pub const O_SYNC: ::c_int = 0x4010; -pub const O_RSYNC: ::c_int = 0x4010; -pub const O_DSYNC: ::c_int = 0x10; pub const O_FSYNC: ::c_int = 0x4010; pub const O_ASYNC: ::c_int = 0x1000; pub const O_NDELAY: ::c_int = 0x80; @@ -475,12 +465,6 @@ pub const MAP_HUGETLB: ::c_int = 0x080000; pub const EFD_NONBLOCK: ::c_int = 0x80; -pub const F_GETLK: ::c_int = 14; -pub const F_GETOWN: ::c_int = 23; -pub const F_SETOWN: ::c_int = 24; -pub const F_SETLK: ::c_int = 6; -pub const F_SETLKW: ::c_int = 7; - pub const SFD_NONBLOCK: ::c_int = 0x80; pub const TCGETS: ::c_ulong = 0x540d; diff --git a/src/unix/notbsd/linux/mips64.rs b/src/unix/notbsd/linux/mips64.rs index cda1cb29ef7f3..cdf977253c46d 100644 --- a/src/unix/notbsd/linux/mips64.rs +++ b/src/unix/notbsd/linux/mips64.rs @@ -188,10 +188,6 @@ pub const FIOCLEX: ::c_ulong = 0x6601; pub const FIONBIO: ::c_ulong = 0x667e; pub const MAP_ANON: ::c_int = 0x800; pub const O_ACCMODE: ::c_int = 3; -pub const O_APPEND: ::c_int = 8; -pub const O_CREAT: ::c_int = 256; -pub const O_EXCL: ::c_int = 1024; -pub const O_NONBLOCK: ::c_int = 128; pub const PTHREAD_STACK_MIN: ::size_t = 131072; pub const RLIM_INFINITY: ::rlim_t = 0xffffffffffffffff; pub const SA_ONSTACK: ::c_int = 0x08000000; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 97e3dc8b1b35d..56ec9227be776 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -544,8 +544,6 @@ extern { pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; pub fn fallocate(fd: ::c_int, mode: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; - pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, - len: ::off_t) -> ::c_int; pub fn readahead(fd: ::c_int, offset: ::off64_t, count: ::size_t) -> ::ssize_t; pub fn getxattr(path: *const c_char, name: *const c_char, diff --git a/src/unix/notbsd/linux/musl/b32/arm.rs b/src/unix/notbsd/linux/musl/b32/arm.rs index 8e562e0e0fb72..12959979609a1 100644 --- a/src/unix/notbsd/linux/musl/b32/arm.rs +++ b/src/unix/notbsd/linux/musl/b32/arm.rs @@ -92,8 +92,6 @@ s! { } pub const O_DIRECT: ::c_int = 0x4000; -pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_ASYNC: ::c_int = 0x2000; pub const FIOCLEX: ::c_int = 0x5451; @@ -105,15 +103,6 @@ pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const O_APPEND: ::c_int = 1024; -pub const O_CREAT: ::c_int = 64; -pub const O_EXCL: ::c_int = 128; -pub const O_NOCTTY: ::c_int = 256; -pub const O_NONBLOCK: ::c_int = 2048; -pub const O_SYNC: ::c_int = 1052672; -pub const O_RSYNC: ::c_int = 1052672; -pub const O_DSYNC: ::c_int = 4096; - pub const SOCK_NONBLOCK: ::c_int = 2048; pub const MAP_ANON: ::c_int = 0x0020; @@ -266,12 +255,6 @@ pub const EXTPROC: ::tcflag_t = 0x00010000; pub const MAP_HUGETLB: ::c_int = 0x040000; -pub const F_GETLK: ::c_int = 12; -pub const F_GETOWN: ::c_int = 9; -pub const F_SETLK: ::c_int = 13; -pub const F_SETLKW: ::c_int = 14; -pub const F_SETOWN: ::c_int = 8; - pub const VEOF: usize = 4; pub const VEOL: usize = 11; pub const VEOL2: usize = 16; diff --git a/src/unix/notbsd/linux/musl/b32/asmjs.rs b/src/unix/notbsd/linux/musl/b32/asmjs.rs index 991196c2a0480..6a9f1f65408a3 100644 --- a/src/unix/notbsd/linux/musl/b32/asmjs.rs +++ b/src/unix/notbsd/linux/musl/b32/asmjs.rs @@ -93,8 +93,6 @@ s! { } pub const O_DIRECT: ::c_int = 0x4000; -pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_ASYNC: ::c_int = 0x2000; pub const FIOCLEX: ::c_int = 0x5451; @@ -106,15 +104,6 @@ pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const O_APPEND: ::c_int = 1024; -pub const O_CREAT: ::c_int = 64; -pub const O_EXCL: ::c_int = 128; -pub const O_NOCTTY: ::c_int = 256; -pub const O_NONBLOCK: ::c_int = 2048; -pub const O_SYNC: ::c_int = 1052672; -pub const O_RSYNC: ::c_int = 1052672; -pub const O_DSYNC: ::c_int = 4096; - pub const SOCK_NONBLOCK: ::c_int = 2048; pub const MAP_ANON: ::c_int = 0x0020; @@ -318,3 +307,20 @@ pub const POSIX_MADV_DONTNEED: ::c_int = 0; pub const RUSAGE_CHILDREN: ::c_int = 1; pub const POLLWRNORM: ::c_short = 0x100; pub const POLLWRBAND: ::c_short = 0x200; + +/* Header */ + +// O_CLOEXEC is defined in notbsd/mod.rs +pub const O_CREAT: ::c_int = 0x40; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_EXCL: ::c_int = 0x80; +pub const O_NOCTTY: ::c_int = 0x100; +pub const O_NOFOLLOW: ::c_int = 0x20000; +// O_TRUNC is defined in notbsd/mod.rs + +pub const O_APPEND: ::c_int = 0x400; +pub const O_DSYNC: ::c_int = 0x1000; +pub const O_NONBLOCK: ::c_int = 0x800; +pub const O_RSYNC: ::c_int = 0x101000; +pub const O_SYNC: ::c_int = 0x101000; + diff --git a/src/unix/notbsd/linux/musl/b32/mips.rs b/src/unix/notbsd/linux/musl/b32/mips.rs index c9cdae185779a..1efe7b85f7df3 100644 --- a/src/unix/notbsd/linux/musl/b32/mips.rs +++ b/src/unix/notbsd/linux/musl/b32/mips.rs @@ -91,8 +91,6 @@ s! { } pub const O_DIRECT: ::c_int = 0o100000; -pub const O_DIRECTORY: ::c_int = 0o200000; -pub const O_NOFOLLOW: ::c_int = 0o400000; pub const O_ASYNC: ::c_int = 0o10000; pub const FIOCLEX: ::c_int = 0x6601; @@ -104,15 +102,6 @@ pub const RLIMIT_AS: ::c_int = 6; pub const RLIMIT_NPROC: ::c_int = 8; pub const RLIMIT_MEMLOCK: ::c_int = 9; -pub const O_APPEND: ::c_int = 0o010; -pub const O_CREAT: ::c_int = 0o400; -pub const O_EXCL: ::c_int = 0o2000; -pub const O_NOCTTY: ::c_int = 0o4000; -pub const O_NONBLOCK: ::c_int = 0o200; -pub const O_SYNC: ::c_int = 0o40020; -pub const O_RSYNC: ::c_int = 0o40020; -pub const O_DSYNC: ::c_int = 0o020; - pub const SOCK_NONBLOCK: ::c_int = 0o200; pub const MAP_ANON: ::c_int = 0x800; @@ -265,12 +254,6 @@ pub const EXTPROC: ::tcflag_t = 0o200000; pub const MAP_HUGETLB: ::c_int = 0x80000; -pub const F_GETLK: ::c_int = 33; -pub const F_GETOWN: ::c_int = 23; -pub const F_SETLK: ::c_int = 34; -pub const F_SETLKW: ::c_int = 35; -pub const F_SETOWN: ::c_int = 24; - pub const VEOF: usize = 16; pub const VEOL: usize = 17; pub const VEOL2: usize = 6; diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs index 078a80ebf10e6..63fa851488791 100644 --- a/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/src/unix/notbsd/linux/musl/b32/x86.rs @@ -105,8 +105,6 @@ s! { } pub const O_DIRECT: ::c_int = 0x4000; -pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_ASYNC: ::c_int = 0x2000; pub const FIOCLEX: ::c_int = 0x5451; @@ -118,15 +116,6 @@ pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const O_APPEND: ::c_int = 1024; -pub const O_CREAT: ::c_int = 64; -pub const O_EXCL: ::c_int = 128; -pub const O_NOCTTY: ::c_int = 256; -pub const O_NONBLOCK: ::c_int = 2048; -pub const O_SYNC: ::c_int = 1052672; -pub const O_RSYNC: ::c_int = 1052672; -pub const O_DSYNC: ::c_int = 4096; - pub const SOCK_NONBLOCK: ::c_int = 2048; pub const MAP_ANON: ::c_int = 0x0020; @@ -280,12 +269,6 @@ pub const EXTPROC: ::tcflag_t = 0x00010000; pub const MAP_HUGETLB: ::c_int = 0x040000; pub const MAP_32BIT: ::c_int = 0x0040; -pub const F_GETLK: ::c_int = 12; -pub const F_GETOWN: ::c_int = 9; -pub const F_SETLK: ::c_int = 13; -pub const F_SETLKW: ::c_int = 14; -pub const F_SETOWN: ::c_int = 8; - pub const VEOF: usize = 4; pub const VEOL: usize = 11; pub const VEOL2: usize = 16; diff --git a/src/unix/notbsd/linux/musl/b64/mod.rs b/src/unix/notbsd/linux/musl/b64/mod.rs index a407f07591e98..0333f840e91f3 100644 --- a/src/unix/notbsd/linux/musl/b64/mod.rs +++ b/src/unix/notbsd/linux/musl/b64/mod.rs @@ -115,8 +115,6 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const O_DIRECT: ::c_int = 0x4000; -pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_ASYNC: ::c_int = 0x2000; pub const FIOCLEX: ::c_int = 0x5451; @@ -128,15 +126,6 @@ pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const O_APPEND: ::c_int = 1024; -pub const O_CREAT: ::c_int = 64; -pub const O_EXCL: ::c_int = 128; -pub const O_NOCTTY: ::c_int = 256; -pub const O_NONBLOCK: ::c_int = 2048; -pub const O_SYNC: ::c_int = 1052672; -pub const O_RSYNC: ::c_int = 1052672; -pub const O_DSYNC: ::c_int = 4096; - pub const SOCK_NONBLOCK: ::c_int = 2048; pub const MAP_ANON: ::c_int = 0x0020; @@ -290,12 +279,6 @@ pub const EXTPROC: ::tcflag_t = 0x00010000; pub const MAP_HUGETLB: ::c_int = 0x040000; -pub const F_GETLK: ::c_int = 5; -pub const F_GETOWN: ::c_int = 9; -pub const F_SETLK: ::c_int = 6; -pub const F_SETLKW: ::c_int = 7; -pub const F_SETOWN: ::c_int = 8; - pub const VEOF: usize = 4; pub const VEOL: usize = 11; pub const VEOL2: usize = 16; diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index 8262fd30c0364..21ee779132527 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -61,7 +61,6 @@ s! { pub const BUFSIZ: ::c_uint = 1024; pub const TMP_MAX: ::c_uint = 10000; pub const FOPEN_MAX: ::c_uint = 1000; -pub const O_ACCMODE: ::c_int = 0o10000003; pub const O_NDELAY: ::c_int = O_NONBLOCK; pub const NI_MAXHOST: ::socklen_t = 255; pub const PTHREAD_STACK_MIN: ::size_t = 2048; @@ -210,6 +209,13 @@ pub const ICANON: ::tcflag_t = 0x00000002; pub const PENDIN: ::tcflag_t = 0x00004000; pub const NOFLSH: ::tcflag_t = 0x00000080; +/* Header */ +pub const O_ACCMODE: ::c_int = 0x3 | ::O_SEARCH; + +// Both are defined in POSIX standard, but absent from other libc. +pub const O_SEARCH: ::c_int = ::O_PATH; +pub const O_EXEC: ::c_int = ::O_PATH; + extern { pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; diff --git a/src/unix/notbsd/linux/other/gnu.rs b/src/unix/notbsd/linux/other/gnu.rs index 757e391d66410..2184902e9c990 100644 --- a/src/unix/notbsd/linux/other/gnu.rs +++ b/src/unix/notbsd/linux/other/gnu.rs @@ -6,3 +6,14 @@ s! { pub f_handle: [::c_uchar], } } + +extern { + pub fn name_to_handle_at(dfd: ::c_int, + name: *const ::c_char, + handle: *mut ::file_handle, + mnt_id: *mut ::c_int, + flags: ::c_int) -> ::c_int; + pub fn open_by_handle_at(mountdirfd: ::c_int, + handle: *mut ::file_handle, + flags: ::c_int) -> ::c_int; +} diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 923b31bd1b37e..88ca3e202f5a0 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -148,14 +148,6 @@ pub const RLIM_INFINITY: ::rlim_t = !0; pub const RLIMIT_RTTIME: ::c_int = 15; pub const RLIMIT_NLIMITS: ::c_int = 16; -pub const O_APPEND: ::c_int = 1024; -pub const O_CREAT: ::c_int = 64; -pub const O_EXCL: ::c_int = 128; -pub const O_NOCTTY: ::c_int = 256; -pub const O_NONBLOCK: ::c_int = 2048; -pub const O_SYNC: ::c_int = 1052672; -pub const O_RSYNC: ::c_int = 1052672; -pub const O_DSYNC: ::c_int = 4096; pub const O_FSYNC: ::c_int = 0x101000; pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; @@ -351,7 +343,6 @@ pub const FOPEN_MAX: ::c_uint = 16; pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const _SC_2_C_VERSION: ::c_int = 96; pub const RUSAGE_THREAD: ::c_int = 1; -pub const O_ACCMODE: ::c_int = 3; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; pub const RUSAGE_CHILDREN: ::c_int = -1; @@ -427,12 +418,6 @@ pub const MAP_HUGETLB: ::c_int = 0x040000; pub const EFD_NONBLOCK: ::c_int = 0x800; -pub const F_GETLK: ::c_int = 5; -pub const F_GETOWN: ::c_int = 9; -pub const F_SETOWN: ::c_int = 8; -pub const F_SETLK: ::c_int = 6; -pub const F_SETLKW: ::c_int = 7; - pub const SEEK_DATA: ::c_int = 3; pub const SEEK_HOLE: ::c_int = 4; @@ -484,6 +469,9 @@ cfg_if! { } } +/* Header */ +pub const O_ACCMODE: ::c_int = 3; + extern { pub fn utmpxname(file: *const ::c_char) -> ::c_int; pub fn getutxent() -> *mut utmpx; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index a3d60ca6cc237..65625f46a497b 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -184,17 +184,10 @@ pub const _IOFBF: ::c_int = 0; pub const _IONBF: ::c_int = 2; pub const _IOLBF: ::c_int = 1; -pub const F_DUPFD: ::c_int = 0; -pub const F_GETFD: ::c_int = 1; -pub const F_SETFD: ::c_int = 2; -pub const F_GETFL: ::c_int = 3; -pub const F_SETFL: ::c_int = 4; - // Linux-specific fcntls pub const F_SETLEASE: ::c_int = 1024; pub const F_GETLEASE: ::c_int = 1025; pub const F_NOTIFY: ::c_int = 1026; -pub const F_DUPFD_CLOEXEC: ::c_int = 1030; pub const F_SETPIPE_SZ: ::c_int = 1031; pub const F_GETPIPE_SZ: ::c_int = 1032; @@ -234,12 +227,6 @@ pub const RLIMIT_RTPRIO: ::c_int = 14; pub const RUSAGE_SELF: ::c_int = 0; -pub const O_RDONLY: ::c_int = 0; -pub const O_WRONLY: ::c_int = 1; -pub const O_RDWR: ::c_int = 2; -pub const O_TRUNC: ::c_int = 512; -pub const O_CLOEXEC: ::c_int = 0x80000; - pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; pub const S_IFIFO: ::mode_t = 4096; @@ -609,16 +596,6 @@ pub const SPLICE_F_GIFT: ::c_uint = 0x08; pub const RTLD_LOCAL: ::c_int = 0; -pub const POSIX_FADV_NORMAL: ::c_int = 0; -pub const POSIX_FADV_RANDOM: ::c_int = 1; -pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2; -pub const POSIX_FADV_WILLNEED: ::c_int = 3; -pub const POSIX_FADV_DONTNEED: ::c_int = 4; -pub const POSIX_FADV_NOREUSE: ::c_int = 5; - -pub const AT_FDCWD: ::c_int = -100; -pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100; - pub const LOG_CRON: ::c_int = 9 << 3; pub const LOG_AUTHPRIV: ::c_int = 10 << 3; pub const LOG_FTP: ::c_int = 11 << 3; @@ -628,6 +605,34 @@ pub const PIPE_BUF: usize = 4096; pub const SI_LOAD_SHIFT: ::c_uint = 16; +/* Header */ +pub const F_DUPFD: ::c_int = 0; +pub const F_DUPFD_CLOEXEC: ::c_int = 1030; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; + +pub const O_CLOEXEC: ::c_int = 0x80000; +pub const O_TRUNC: ::c_int = 0x200; + +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; + +pub const AT_FDCWD: ::c_int = -100; +pub const AT_EACCESS: ::c_int = 0x200; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100; +pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; +pub const AT_REMOVEDIR: ::c_int = 0x200; + +pub const POSIX_FADV_NORMAL: ::c_int = 0; +pub const POSIX_FADV_RANDOM: ::c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_FADV_WILLNEED: ::c_int = 3; +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + f! { pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; @@ -767,9 +772,6 @@ extern { iov: *const ::iovec, nr_segs: ::size_t, flags: ::c_uint) -> ::ssize_t; - - pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, - advise: ::c_int) -> ::c_int; pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; pub fn utimensat(dirfd: ::c_int, path: *const ::c_char, times: *const ::timespec, flag: ::c_int) -> ::c_int; @@ -779,7 +781,6 @@ extern { locale: *const ::c_char, base: ::locale_t) -> ::locale_t; pub fn uselocale(loc: ::locale_t) -> ::locale_t; - pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int; pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int; pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int; pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int; @@ -792,7 +793,6 @@ extern { fd: ::c_int, offset: off64_t) -> *mut ::c_void; - pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off64_t) -> ::ssize_t; pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t, @@ -804,8 +804,6 @@ extern { pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; pub fn sysinfo (info: *mut ::sysinfo) -> ::c_int; - pub fn openat(dirfd: ::c_int, pathname: *const ::c_char, - flags: ::c_int, ...) -> ::c_int; pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::c_int, flags: ::c_int) -> ::c_int; pub fn fchmodat(dirfd: ::c_int, pathname: *const ::c_char, @@ -845,6 +843,24 @@ extern { pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int; + + /* Header */ + pub fn openat(dirfd: ::c_int, pathname: *const ::c_char, + flags: ::c_int, ...) -> ::c_int; + pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, + advise: ::c_int) -> ::c_int; + pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, + len: ::off_t) -> ::c_int; + + // Here start non POSIX definitions. + pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int; + pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn openat64(dirfd: ::c_int, pathname: *const ::c_char, + flags: ::c_int, ...) -> ::c_int; + pub fn posix_fadvise64(fd: ::c_int, offset: ::off64_t, len: ::off64_t, + advise: ::c_int) -> ::c_int; + pub fn posix_fallocate64(fd: ::c_int, offset: ::off64_t, + len: ::off64_t) -> ::c_int; } cfg_if! { From eeddd77c299b333341c4c197f3a9f237d4b2ad13 Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Tue, 30 Aug 2016 15:04:29 +0200 Subject: [PATCH 06/13] [Step 3][fcntl.h] Non POSIX macros and functions. --- src/unix/notbsd/android/mod.rs | 5 ++ src/unix/notbsd/linux/common/b32/arm.rs | 9 +++ src/unix/notbsd/linux/common/b32/mips.rs | 8 +++ src/unix/notbsd/linux/common/b32/mod.rs | 15 +++-- src/unix/notbsd/linux/common/b32/powerpc.rs | 9 +++ src/unix/notbsd/linux/common/b32/x86.rs | 9 +++ src/unix/notbsd/linux/common/b64/aarch64.rs | 9 +++ src/unix/notbsd/linux/common/b64/mips64.rs | 8 +++ src/unix/notbsd/linux/common/b64/powerpc64.rs | 9 +++ src/unix/notbsd/linux/common/b64/x86_64.rs | 9 +++ src/unix/notbsd/linux/common/mod.rs | 37 ++++++++++-- src/unix/notbsd/linux/mips.rs | 6 -- src/unix/notbsd/linux/mips64.rs | 1 - src/unix/notbsd/linux/mod.rs | 15 +++-- src/unix/notbsd/linux/musl/b32/arm.rs | 3 - src/unix/notbsd/linux/musl/b32/mips.rs | 3 - src/unix/notbsd/linux/musl/b32/x86.rs | 3 - src/unix/notbsd/linux/musl/b64/mod.rs | 3 - src/unix/notbsd/linux/musl/mod.rs | 27 +++++++-- src/unix/notbsd/linux/other/b32/arm.rs | 4 -- src/unix/notbsd/linux/other/b32/powerpc.rs | 4 -- src/unix/notbsd/linux/other/b32/x86.rs | 4 -- src/unix/notbsd/linux/other/b64/aarch64.rs | 4 -- src/unix/notbsd/linux/other/b64/powerpc64.rs | 4 -- src/unix/notbsd/linux/other/b64/x86_64.rs | 4 -- src/unix/notbsd/linux/other/gnu.rs | 30 +++++++++- src/unix/notbsd/linux/other/mod.rs | 27 ++++++--- src/unix/notbsd/mod.rs | 58 +++++++++---------- 28 files changed, 225 insertions(+), 102 deletions(-) diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 11013312b7a2d..a8e8bd1682bdb 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -578,6 +578,11 @@ pub const ICANON: ::tcflag_t = 0x00000002; pub const PENDIN: ::tcflag_t = 0x00004000; pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const LOCK_SH: ::c_int = 0x1; +pub const LOCK_EX: ::c_int = 0x2; +pub const LOCK_NB: ::c_int = 0x4; +pub const LOCK_UN: ::c_int = 0x8; + f! { pub fn sigemptyset(set: *mut sigset_t) -> ::c_int { *set = 0; diff --git a/src/unix/notbsd/linux/common/b32/arm.rs b/src/unix/notbsd/linux/common/b32/arm.rs index 3200e250b674f..12eb1b37a8bda 100644 --- a/src/unix/notbsd/linux/common/b32/arm.rs +++ b/src/unix/notbsd/linux/common/b32/arm.rs @@ -45,3 +45,12 @@ pub const O_NONBLOCK: ::c_int = 0x800; pub const O_RSYNC: ::c_int = 0x101000; pub const O_SYNC: ::c_int = 0x101000; +// Here start non POSIX definitions. +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_LARGEFILE: ::c_int = 0x20000; +pub const O_NOATIME: ::c_int = 0x40000; +pub const O_PATH: ::c_int = 0x200000; +pub const O_TMPFILE: ::c_int = 0x404000; +pub const O_NDELAY: ::c_int = ::O_NONBLOCK; + diff --git a/src/unix/notbsd/linux/common/b32/mips.rs b/src/unix/notbsd/linux/common/b32/mips.rs index 8e115c012ae11..f4272c992a5e1 100644 --- a/src/unix/notbsd/linux/common/b32/mips.rs +++ b/src/unix/notbsd/linux/common/b32/mips.rs @@ -47,3 +47,11 @@ pub const O_NONBLOCK: ::c_int = 0x80; pub const O_RSYNC: ::c_int = 0x4010; pub const O_SYNC: ::c_int = 0x4010; +pub const O_ASYNC: ::c_int = 0x1000; +pub const O_DIRECT: ::c_int = 0x8000; +pub const O_LARGEFILE: ::c_int = 0x2000; +pub const O_NOATIME: ::c_int = 0x40000; +pub const O_PATH: ::c_int = 0x200000; +pub const O_TMPFILE: ::c_int = 0x410000; +pub const O_NDELAY: ::c_int = ::O_NONBLOCK; + diff --git a/src/unix/notbsd/linux/common/b32/mod.rs b/src/unix/notbsd/linux/common/b32/mod.rs index 53047fefe4eb7..12b0efd6cd4c8 100644 --- a/src/unix/notbsd/linux/common/b32/mod.rs +++ b/src/unix/notbsd/linux/common/b32/mod.rs @@ -2,6 +2,15 @@ pub type c_long = i32; pub type c_ulong = u32; +/* Header */ +cfg_if! { + if #[cfg(feature = "file_offset64")] { + pub const F_GETLK: ::c_int = ::F_GETLK64; + pub const F_SETLK: ::c_int = ::F_SETLK64; + pub const F_SETLKW: ::c_int = ::F_SETLKW64; + } +} + cfg_if! { if #[cfg(target_arch = "x86")] { mod x86; @@ -20,9 +29,3 @@ cfg_if! { } } -/* Header */ -if #[cfg(feature = "file_offset64")] { - pub const F_GETLK: ::c_int = ::F_GETLK64; - pub const F_SETLK: ::c_int = ::F_SETLK64; - pub const F_SETLKW: ::c_int = ::F_SETLKW64; -} diff --git a/src/unix/notbsd/linux/common/b32/powerpc.rs b/src/unix/notbsd/linux/common/b32/powerpc.rs index 3200e250b674f..fa1df8526ed08 100644 --- a/src/unix/notbsd/linux/common/b32/powerpc.rs +++ b/src/unix/notbsd/linux/common/b32/powerpc.rs @@ -45,3 +45,12 @@ pub const O_NONBLOCK: ::c_int = 0x800; pub const O_RSYNC: ::c_int = 0x101000; pub const O_SYNC: ::c_int = 0x101000; +// Here start non POSIX definitions. +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_DIRECT: ::c_int = 0x20000; +pub const O_LARGEFILE: ::c_int = 0x10000; +pub const O_NOATIME: ::c_int = 0x40000; +pub const O_PATH: ::c_int = 0x200000; +pub const O_TMPFILE: ::c_int = 0x404000; +pub const O_NDELAY: ::c_int = ::O_NONBLOCK; + diff --git a/src/unix/notbsd/linux/common/b32/x86.rs b/src/unix/notbsd/linux/common/b32/x86.rs index 747355904374c..be9b727feca81 100644 --- a/src/unix/notbsd/linux/common/b32/x86.rs +++ b/src/unix/notbsd/linux/common/b32/x86.rs @@ -45,3 +45,12 @@ pub const O_NONBLOCK: ::c_int = 0x800; pub const O_RSYNC: ::c_int = 0x101000; pub const O_SYNC: ::c_int = 0x101000; +// Here start non POSIX definitions. +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_LARGEFILE: ::c_int = 0x8000; +pub const O_NOATIME: ::c_int = 0x40000; +pub const O_PATH: ::c_int = 0x200000; +pub const O_TMPFILE: ::c_int = 0x410000; +pub const O_NDELAY: ::c_int = ::O_NONBLOCK; + diff --git a/src/unix/notbsd/linux/common/b64/aarch64.rs b/src/unix/notbsd/linux/common/b64/aarch64.rs index 7a40edc5c6836..ab144283f5e9f 100644 --- a/src/unix/notbsd/linux/common/b64/aarch64.rs +++ b/src/unix/notbsd/linux/common/b64/aarch64.rs @@ -22,3 +22,12 @@ pub const O_NONBLOCK: ::c_int = 0x800; pub const O_RSYNC: ::c_int = 0x101000; pub const O_SYNC: ::c_int = 0x101000; +// Here start non POSIX definitions. +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_LARGEFILE: ::c_int = 0x20000; +pub const O_NOATIME: ::c_int = 0x40000; +pub const O_PATH: ::c_int = 0x200000; +pub const O_TMPFILE: ::c_int = 0x404000; +pub const O_NDELAY: ::c_int = ::O_NONBLOCK; + diff --git a/src/unix/notbsd/linux/common/b64/mips64.rs b/src/unix/notbsd/linux/common/b64/mips64.rs index 1337e84b5e7e7..daf126d2db014 100644 --- a/src/unix/notbsd/linux/common/b64/mips64.rs +++ b/src/unix/notbsd/linux/common/b64/mips64.rs @@ -22,3 +22,11 @@ pub const O_NONBLOCK: ::c_int = 0x80; pub const O_RSYNC: ::c_int = 0x4010; pub const O_SYNC: ::c_int = 0x4010; +pub const O_ASYNC: ::c_int = 0x1000; +pub const O_DIRECT: ::c_int = 0x8000; +pub const O_LARGEFILE: ::c_int = 0; +pub const O_NOATIME: ::c_int = 0x40000; +pub const O_PATH: ::c_int = 0x200000; +pub const O_TMPFILE: ::c_int = 0x410000; +pub const O_NDELAY: ::c_int = ::O_NONBLOCK; + diff --git a/src/unix/notbsd/linux/common/b64/powerpc64.rs b/src/unix/notbsd/linux/common/b64/powerpc64.rs index 7a40edc5c6836..08302d8baf128 100644 --- a/src/unix/notbsd/linux/common/b64/powerpc64.rs +++ b/src/unix/notbsd/linux/common/b64/powerpc64.rs @@ -22,3 +22,12 @@ pub const O_NONBLOCK: ::c_int = 0x800; pub const O_RSYNC: ::c_int = 0x101000; pub const O_SYNC: ::c_int = 0x101000; +// Here start non POSIX definitions. +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_DIRECT: ::c_int = 0x20000; +pub const O_LARGEFILE: ::c_int = 0x10000; +pub const O_NOATIME: ::c_int = 0x40000; +pub const O_PATH: ::c_int = 0x200000; +pub const O_TMPFILE: ::c_int = 0x404000; +pub const O_NDELAY: ::c_int = ::O_NONBLOCK; + diff --git a/src/unix/notbsd/linux/common/b64/x86_64.rs b/src/unix/notbsd/linux/common/b64/x86_64.rs index b32f5278553ed..b01f5cbd401ac 100644 --- a/src/unix/notbsd/linux/common/b64/x86_64.rs +++ b/src/unix/notbsd/linux/common/b64/x86_64.rs @@ -22,3 +22,12 @@ pub const O_NONBLOCK: ::c_int = 0x800; pub const O_RSYNC: ::c_int = 0x101000; pub const O_SYNC: ::c_int = 0x101000; +// Here start non POSIX definitions. +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_LARGEFILE: ::c_int = 0; +pub const O_NOATIME: ::c_int = 0x40000; +pub const O_PATH: ::c_int = 0x200000; +pub const O_TMPFILE: ::c_int = 0x410000; +pub const O_NDELAY: ::c_int = ::O_NONBLOCK; + diff --git a/src/unix/notbsd/linux/common/mod.rs b/src/unix/notbsd/linux/common/mod.rs index cedbb30b4bed4..f356a1e68d7cb 100644 --- a/src/unix/notbsd/linux/common/mod.rs +++ b/src/unix/notbsd/linux/common/mod.rs @@ -19,6 +19,39 @@ s! { } } +/* Header */ +pub const F_RDLCK: ::c_short = 0; +pub const F_WRLCK: ::c_short = 1; +pub const F_UNLCK: ::c_short = 2; + +// Here start non POSIX definitions. +pub const AT_NO_AUTOMOUNT: ::c_int = 0x800; +pub const AT_EMPTY_PATH: ::c_int = 0x1000; + +pub const FAPPEND: ::c_int = ::O_APPEND; +pub const FFSYNC: ::c_int = ::O_FSYNC; +pub const FASYNC: ::c_int = ::O_ASYNC; +pub const FNONBLOCK: ::c_int = ::O_NONBLOCK; +pub const FNDELAY: ::c_int = ::O_NDELAY; + +pub const DN_ACCESS: ::c_int = 0x00000001; +pub const DN_MODIFY: ::c_int = 0x00000002; +pub const DN_CREATE: ::c_int = 0x00000004; +pub const DN_DELETE: ::c_int = 0x00000008; +pub const DN_RENAME: ::c_int = 0x00000010; +pub const DN_ATTRIB: ::c_int = 0x00000020; +pub const DN_MULTISHOT: ::c_int = 0x80000000; + +pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; +pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; + +pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 0x01; +pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 0x02; +pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 0x04; + +pub const F_SETSIG: ::c_int = 10; +pub const F_GETSIG: ::c_int = 11; + cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "arm", @@ -37,7 +70,3 @@ cfg_if! { } } -/* Header */ -pub const F_RDLCK: ::c_short = 0; -pub const F_WRLCK: ::c_short = 1; -pub const F_UNLCK: ::c_short = 2; diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index eff10f6b2ae5f..dd0a7f28605bf 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -192,8 +192,6 @@ pub const FOPEN_MAX: ::c_uint = 16; pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const _SC_2_C_VERSION: ::c_int = 96; pub const RUSAGE_THREAD: ::c_int = 1; -pub const O_ACCMODE: ::c_int = 3; -pub const O_DIRECT: ::c_int = 0x8000; pub const RUSAGE_CHILDREN: ::c_int = -1; pub const ST_RELATIME: ::c_ulong = 4096; pub const NI_MAXHOST: ::socklen_t = 1025; @@ -206,10 +204,6 @@ pub const RLIMIT_MEMLOCK: ::c_int = 9; pub const RLIMIT_NLIMITS: ::c_int = 16; pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; -pub const O_FSYNC: ::c_int = 0x4010; -pub const O_ASYNC: ::c_int = 0x1000; -pub const O_NDELAY: ::c_int = 0x80; - pub const SOCK_NONBLOCK: ::c_int = 128; pub const EDEADLK: ::c_int = 45; diff --git a/src/unix/notbsd/linux/mips64.rs b/src/unix/notbsd/linux/mips64.rs index cdf977253c46d..765639a3fc665 100644 --- a/src/unix/notbsd/linux/mips64.rs +++ b/src/unix/notbsd/linux/mips64.rs @@ -187,7 +187,6 @@ pub const ETIMEDOUT: ::c_int = 145; pub const FIOCLEX: ::c_ulong = 0x6601; pub const FIONBIO: ::c_ulong = 0x667e; pub const MAP_ANON: ::c_int = 0x800; -pub const O_ACCMODE: ::c_int = 3; pub const PTHREAD_STACK_MIN: ::size_t = 131072; pub const RLIM_INFINITY: ::rlim_t = 0xffffffffffffffff; pub const SA_ONSTACK: ::c_int = 0x08000000; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 56ec9227be776..642a7cdb9572b 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -542,10 +542,6 @@ extern { offset: ::off64_t, whence: ::c_int) -> ::c_int; pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; - pub fn fallocate(fd: ::c_int, mode: ::c_int, - offset: ::off_t, len: ::off_t) -> ::c_int; - pub fn readahead(fd: ::c_int, offset: ::off64_t, - count: ::size_t) -> ::ssize_t; pub fn getxattr(path: *const c_char, name: *const c_char, value: *mut ::c_void, size: ::size_t) -> ::ssize_t; pub fn lgetxattr(path: *const c_char, name: *const c_char, @@ -659,6 +655,17 @@ extern { mode: ::mode_t) -> ::c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); + + /* Header */ + // Here start non POSIX definitions. + pub fn fallocate(fd: ::c_int, mode: ::c_int, + offset: ::off_t, len: ::off_t) -> ::c_int; + pub fn fallocate64(fd: ::c_int, mode: ::c_int, + offset: ::off_t, len: ::off_t) -> ::c_int; + pub fn readahead(fd: ::c_int, offset: ::off64_t, + count: ::size_t) -> ::ssize_t; + pub fn sync_file_range(fd: ::c_int, from: ::off64_t, to: ::off64_t, + flags: ::c_uint) -> ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/linux/musl/b32/arm.rs b/src/unix/notbsd/linux/musl/b32/arm.rs index 12959979609a1..022f9105328f4 100644 --- a/src/unix/notbsd/linux/musl/b32/arm.rs +++ b/src/unix/notbsd/linux/musl/b32/arm.rs @@ -91,9 +91,6 @@ s! { } } -pub const O_DIRECT: ::c_int = 0x4000; -pub const O_ASYNC: ::c_int = 0x2000; - pub const FIOCLEX: ::c_int = 0x5451; pub const FIONBIO: ::c_int = 0x5421; diff --git a/src/unix/notbsd/linux/musl/b32/mips.rs b/src/unix/notbsd/linux/musl/b32/mips.rs index 1efe7b85f7df3..2dc0a813d0baf 100644 --- a/src/unix/notbsd/linux/musl/b32/mips.rs +++ b/src/unix/notbsd/linux/musl/b32/mips.rs @@ -90,9 +90,6 @@ s! { } } -pub const O_DIRECT: ::c_int = 0o100000; -pub const O_ASYNC: ::c_int = 0o10000; - pub const FIOCLEX: ::c_int = 0x6601; pub const FIONBIO: ::c_int = 0x667E; diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs index 63fa851488791..8eeceadd587b2 100644 --- a/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/src/unix/notbsd/linux/musl/b32/x86.rs @@ -104,9 +104,6 @@ s! { } } -pub const O_DIRECT: ::c_int = 0x4000; -pub const O_ASYNC: ::c_int = 0x2000; - pub const FIOCLEX: ::c_int = 0x5451; pub const FIONBIO: ::c_int = 0x5421; diff --git a/src/unix/notbsd/linux/musl/b64/mod.rs b/src/unix/notbsd/linux/musl/b64/mod.rs index 0333f840e91f3..7f65af4a467e8 100644 --- a/src/unix/notbsd/linux/musl/b64/mod.rs +++ b/src/unix/notbsd/linux/musl/b64/mod.rs @@ -114,9 +114,6 @@ s! { pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; -pub const O_DIRECT: ::c_int = 0x4000; -pub const O_ASYNC: ::c_int = 0x2000; - pub const FIOCLEX: ::c_int = 0x5451; pub const FIONBIO: ::c_int = 0x5421; diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index 21ee779132527..259bb7a7c6cdc 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -61,7 +61,6 @@ s! { pub const BUFSIZ: ::c_uint = 1024; pub const TMP_MAX: ::c_uint = 10000; pub const FOPEN_MAX: ::c_uint = 1000; -pub const O_NDELAY: ::c_int = O_NONBLOCK; pub const NI_MAXHOST: ::socklen_t = 255; pub const PTHREAD_STACK_MIN: ::size_t = 2048; @@ -84,9 +83,6 @@ pub const TCP_TIMESTAMP: ::c_int = 24; pub const SIGUNUSED: ::c_int = ::SIGSYS; -pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; -pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; - pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; @@ -216,6 +212,29 @@ pub const O_ACCMODE: ::c_int = 0x3 | ::O_SEARCH; pub const O_SEARCH: ::c_int = ::O_PATH; pub const O_EXEC: ::c_int = ::O_PATH; +// Here start non POSIX definitions. +pub const F_OFD_GETLK: ::c_int = 36; +pub const F_OFD_SETLK: ::c_int = 37; +pub const F_OFD_SETLKW: ::c_int = 38; + +pub const F_CANCELLK: ::c_int = 1029; +pub const F_ADD_SEALS: ::c_int = 1033; +pub const F_GET_SEALS: ::c_int = 1034; + +pub const F_SEAL_SEAL: ::c_int = 0x0001; +pub const F_SEAL_SHRINK: ::c_int = 0x0002; +pub const F_SEAL_GROW: ::c_int = 0x0004; +pub const F_SEAL_WRITE: ::c_int = 0x0008; + +pub const F_OWNER_TID: ::c_int = 0; +pub const F_OWNER_PID: ::c_int = 1; +pub const F_OWNER_PGRP: ::c_int = 2; +pub const F_OWNER_GID: ::c_int = ::F_OWNER_PGRP; + +pub const F_SETOWN_EX: ::c_int = 15; +pub const F_GETOWN_EX: ::c_int = 16; +pub const F_GETOWNER_UIDS: ::c_int = 17; + extern { pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; diff --git a/src/unix/notbsd/linux/other/b32/arm.rs b/src/unix/notbsd/linux/other/b32/arm.rs index 3913ee1d6c4d3..dfd95c711fa8f 100644 --- a/src/unix/notbsd/linux/other/b32/arm.rs +++ b/src/unix/notbsd/linux/other/b32/arm.rs @@ -54,10 +54,6 @@ s! { } } -pub const O_DIRECT: ::c_int = 0x10000; -pub const O_DIRECTORY: ::c_int = 0x4000; -pub const O_NOFOLLOW: ::c_int = 0x8000; - pub const MAP_LOCKED: ::c_int = 0x02000; pub const MAP_NORESERVE: ::c_int = 0x04000; diff --git a/src/unix/notbsd/linux/other/b32/powerpc.rs b/src/unix/notbsd/linux/other/b32/powerpc.rs index 9d965bd98ec6f..6c010ffbe96fe 100644 --- a/src/unix/notbsd/linux/other/b32/powerpc.rs +++ b/src/unix/notbsd/linux/other/b32/powerpc.rs @@ -54,10 +54,6 @@ s! { } } -pub const O_DIRECT: ::c_int = 0x20000; -pub const O_DIRECTORY: ::c_int = 0x4000; -pub const O_NOFOLLOW: ::c_int = 0x8000; - pub const MAP_LOCKED: ::c_int = 0x00080; pub const MAP_NORESERVE: ::c_int = 0x00040; diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index 82472660489b9..9a605798fcac0 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -88,10 +88,6 @@ s! { } } -pub const O_DIRECT: ::c_int = 0x4000; -pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_NOFOLLOW: ::c_int = 0x20000; - pub const MAP_LOCKED: ::c_int = 0x02000; pub const MAP_NORESERVE: ::c_int = 0x04000; pub const MAP_32BIT: ::c_int = 0x0040; diff --git a/src/unix/notbsd/linux/other/b64/aarch64.rs b/src/unix/notbsd/linux/other/b64/aarch64.rs index ae6e34bac286a..89e9e5cd9cfca 100644 --- a/src/unix/notbsd/linux/other/b64/aarch64.rs +++ b/src/unix/notbsd/linux/other/b64/aarch64.rs @@ -85,10 +85,6 @@ pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8; -pub const O_DIRECT: ::c_int = 0x10000; -pub const O_DIRECTORY: ::c_int = 0x4000; -pub const O_NOFOLLOW: ::c_int = 0x8000; - pub const MAP_LOCKED: ::c_int = 0x02000; pub const MAP_NORESERVE: ::c_int = 0x04000; diff --git a/src/unix/notbsd/linux/other/b64/powerpc64.rs b/src/unix/notbsd/linux/other/b64/powerpc64.rs index ea3234bb3a46e..46f5c3423d778 100644 --- a/src/unix/notbsd/linux/other/b64/powerpc64.rs +++ b/src/unix/notbsd/linux/other/b64/powerpc64.rs @@ -82,10 +82,6 @@ pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; -pub const O_DIRECTORY: ::c_int = 0x4000; -pub const O_NOFOLLOW: ::c_int = 0x8000; -pub const O_DIRECT: ::c_int = 0x20000; - pub const MAP_LOCKED: ::c_int = 0x00080; pub const MAP_NORESERVE: ::c_int = 0x00040; diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index 89cfb2ce0cb4d..3942b83de4010 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -123,10 +123,6 @@ pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; -pub const O_DIRECT: ::c_int = 0x4000; -pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_NOFOLLOW: ::c_int = 0x20000; - pub const MAP_LOCKED: ::c_int = 0x02000; pub const MAP_NORESERVE: ::c_int = 0x04000; pub const MAP_32BIT: ::c_int = 0x0040; diff --git a/src/unix/notbsd/linux/other/gnu.rs b/src/unix/notbsd/linux/other/gnu.rs index 2184902e9c990..3bd94782ca00b 100644 --- a/src/unix/notbsd/linux/other/gnu.rs +++ b/src/unix/notbsd/linux/other/gnu.rs @@ -3,11 +3,39 @@ s! { pub struct file_handle { pub handle_bytes: ::c_uint, pub handle_type: ::c_int, - pub f_handle: [::c_uchar], +// pub f_handle: [::c_uchar], } } +/* Header */ +pub const F_OFD_GETLK: ::c_int = 36; +pub const F_OFD_SETLK: ::c_int = 37; +pub const F_OFD_SETLKW: ::c_int = 38; + +// Here start non POSIX definitions. +pub const FSYNC: ::c_int = ::O_SYNC; + +pub const F_OWNER_TID: ::c_int = 0; +pub const F_OWNER_PID: ::c_int = 1; +pub const F_OWNER_PGRP: ::c_int = 2; +pub const F_OWNER_GID: ::c_int = ::F_OWNER_PGRP; + +pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08; +pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10; + +pub const MAX_HANDLE_SZ: ::size_t = 128; + +pub const O_SHLOCK: ::c_int = 0x0010; +pub const O_EXLOCK: ::c_int = 0x0020; + +pub const FREAD: ::c_int = 1; +pub const FWRITE: ::c_int = 2; + +pub const F_SETOWN_EX: ::c_int = 15; +pub const F_GETOWN_EX: ::c_int = 16; + extern { + /* Header */ pub fn name_to_handle_at(dfd: ::c_int, name: *const ::c_char, handle: *mut ::file_handle, diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 88ca3e202f5a0..515b4878d716e 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -1,6 +1,6 @@ pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; -pub type rlim_t = c_ulong; +pub type rlim_t = ::c_ulong; pub type __priority_which_t = ::c_uint; s! { @@ -148,9 +148,7 @@ pub const RLIM_INFINITY: ::rlim_t = !0; pub const RLIMIT_RTTIME: ::c_int = 15; pub const RLIMIT_NLIMITS: ::c_int = 16; -pub const O_FSYNC: ::c_int = 0x101000; - -pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; +pub const SOCK_NONBLOCK: ::c_int = ::O_NONBLOCK; pub const LC_PAPER: ::c_int = 7; pub const LC_NAME: ::c_int = 8; @@ -334,17 +332,12 @@ pub const POLLWRNORM: ::c_short = 0x100; pub const POLLRDBAND: ::c_short = 0x080; pub const POLLWRBAND: ::c_short = 0x200; -pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; -pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; - pub const BUFSIZ: ::c_uint = 8192; pub const TMP_MAX: ::c_uint = 238328; pub const FOPEN_MAX: ::c_uint = 16; pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const _SC_2_C_VERSION: ::c_int = 96; pub const RUSAGE_THREAD: ::c_int = 1; -pub const O_ASYNC: ::c_int = 0x2000; -pub const O_NDELAY: ::c_int = 0x800; pub const RUSAGE_CHILDREN: ::c_int = -1; pub const ST_RELATIME: ::c_ulong = 4096; pub const NI_MAXHOST: ::socklen_t = 1025; @@ -469,9 +462,25 @@ cfg_if! { } } +pub const LOCK_SH: ::c_int = 0x1; +pub const LOCK_EX: ::c_int = 0x2; +pub const LOCK_NB: ::c_int = 0x4; +pub const LOCK_UN: ::c_int = 0x8; + /* Header */ pub const O_ACCMODE: ::c_int = 3; +// Here start non POSIX definitions. +pub const F_EXLCK: ::c_short = 0x4; +pub const F_SHLCK: ::c_short = 0x8; + +pub const LOCK_MAND: ::c_int = 0x20; +pub const LOCK_READ: ::c_int = 0x40; +pub const LOCK_WRITE: ::c_int = 0x80; +pub const LOCK_RW: ::c_int = 0xc0; + +pub const O_FSYNC: ::c_int = ::O_SYNC; + extern { pub fn utmpxname(file: *const ::c_char) -> ::c_int; pub fn getutxent() -> *mut utmpx; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 65625f46a497b..45113977508d7 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -184,13 +184,6 @@ pub const _IOFBF: ::c_int = 0; pub const _IONBF: ::c_int = 2; pub const _IOLBF: ::c_int = 1; -// Linux-specific fcntls -pub const F_SETLEASE: ::c_int = 1024; -pub const F_GETLEASE: ::c_int = 1025; -pub const F_NOTIFY: ::c_int = 1026; -pub const F_SETPIPE_SZ: ::c_int = 1031; -pub const F_GETPIPE_SZ: ::c_int = 1032; - // TODO(#235): Include file sealing fcntls once we have a way to verify them. pub const SIGTRAP: ::c_int = 5; @@ -458,11 +451,6 @@ pub const SHUT_RD: ::c_int = 0; pub const SHUT_WR: ::c_int = 1; pub const SHUT_RDWR: ::c_int = 2; -pub const LOCK_SH: ::c_int = 1; -pub const LOCK_EX: ::c_int = 2; -pub const LOCK_NB: ::c_int = 4; -pub const LOCK_UN: ::c_int = 8; - pub const SA_NODEFER: ::c_int = 0x40000000; pub const SA_RESETHAND: ::c_int = 0x80000000; pub const SA_RESTART: ::c_int = 0x10000000; @@ -589,11 +577,6 @@ pub const __WNOTHREAD: ::c_int = 0x20000000; pub const __WALL: ::c_int = 0x40000000; pub const __WCLONE: ::c_int = 0x80000000; -pub const SPLICE_F_MOVE: ::c_uint = 0x01; -pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02; -pub const SPLICE_F_MORE: ::c_uint = 0x04; -pub const SPLICE_F_GIFT: ::c_uint = 0x08; - pub const RTLD_LOCAL: ::c_int = 0; pub const LOG_CRON: ::c_int = 9 << 3; @@ -633,6 +616,18 @@ pub const POSIX_FADV_WILLNEED: ::c_int = 3; pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const POSIX_FADV_NOREUSE: ::c_int = 5; +// Here start non POSIX definitions. +pub const F_SETLEASE: ::c_int = 1024; +pub const F_GETLEASE: ::c_int = 1025; +pub const F_NOTIFY: ::c_int = 1026; +pub const F_SETPIPE_SZ: ::c_int = 1031; +pub const F_GETPIPE_SZ: ::c_int = 1032; + +pub const SPLICE_F_MOVE: ::c_uint = 0x01; +pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02; +pub const SPLICE_F_MORE: ::c_uint = 0x04; +pub const SPLICE_F_GIFT: ::c_uint = 0x08; + f! { pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; @@ -758,20 +753,6 @@ extern { in_fd: ::c_int, offset: *mut off_t, count: ::size_t) -> ::ssize_t; - pub fn splice(fd_in: ::c_int, - off_in: *mut ::loff_t, - fd_out: ::c_int, - off_out: *mut ::loff_t, - len: ::size_t, - flags: ::c_uint) -> ::ssize_t; - pub fn tee(fd_in: ::c_int, - fd_out: ::c_int, - len: ::size_t, - flags: ::c_uint) -> ::ssize_t; - pub fn vmsplice(fd: ::c_int, - iov: *const ::iovec, - nr_segs: ::size_t, - flags: ::c_uint) -> ::ssize_t; pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; pub fn utimensat(dirfd: ::c_int, path: *const ::c_char, times: *const ::timespec, flag: ::c_int) -> ::c_int; @@ -861,6 +842,21 @@ extern { advise: ::c_int) -> ::c_int; pub fn posix_fallocate64(fd: ::c_int, offset: ::off64_t, len: ::off64_t) -> ::c_int; + + pub fn vmsplice(fd: ::c_int, + iov: *const ::iovec, + nr_segs: ::size_t, + flags: ::c_uint) -> ::ssize_t; + pub fn splice(fd_in: ::c_int, + off_in: *mut ::loff_t, + fd_out: ::c_int, + off_out: *mut ::loff_t, + len: ::size_t, + flags: ::c_uint) -> ::ssize_t; + pub fn tee(fd_in: ::c_int, + fd_out: ::c_int, + len: ::size_t, + flags: ::c_uint) -> ::ssize_t; } cfg_if! { From 64b61b6300b9da56f9e19c66d613c5a74c007e65 Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Tue, 30 Aug 2016 15:09:28 +0200 Subject: [PATCH 07/13] [Step 3][fcntl.h] This hack should make it work with musl but a better fix must be found. --- src/unix/notbsd/linux/common/b32/arm.rs | 4 ++-- src/unix/notbsd/linux/common/b32/mips.rs | 4 ++-- src/unix/notbsd/linux/common/b32/mod.rs | 2 +- src/unix/notbsd/linux/common/b32/powerpc.rs | 4 ++-- src/unix/notbsd/linux/common/b32/x86.rs | 4 ++-- src/unix/notbsd/linux/common/b64/mod.rs | 20 +++++++------------- src/unix/notbsd/linux/common/mod.rs | 2 +- 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/unix/notbsd/linux/common/b32/arm.rs b/src/unix/notbsd/linux/common/b32/arm.rs index 12eb1b37a8bda..c32408f8569e7 100644 --- a/src/unix/notbsd/linux/common/b32/arm.rs +++ b/src/unix/notbsd/linux/common/b32/arm.rs @@ -4,7 +4,7 @@ pub type c_char = u8; s! { /* Header */ cfg_if! { - if #[cfg(feature = "file_offset64")] { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { type flock = ::flock64; } else { pub struct flock { @@ -19,7 +19,7 @@ s! { } /* Header */ -if #[cfg(feature = "file_offset64")] { +if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { pub const F_GETLK: ::c_int = 5; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; diff --git a/src/unix/notbsd/linux/common/b32/mips.rs b/src/unix/notbsd/linux/common/b32/mips.rs index f4272c992a5e1..f9ef01a6f4e2f 100644 --- a/src/unix/notbsd/linux/common/b32/mips.rs +++ b/src/unix/notbsd/linux/common/b32/mips.rs @@ -4,7 +4,7 @@ pub type c_char = i8; s! { /* Header */ cfg_if! { - if #[cfg(feature = "file_offset64")] { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { type flock = ::flock64; } else { pub struct flock { @@ -21,7 +21,7 @@ s! { } /* Header */ -if #[cfg(feature = "file_offset64")] { +if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { pub const F_GETLK: ::c_int = 14; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; diff --git a/src/unix/notbsd/linux/common/b32/mod.rs b/src/unix/notbsd/linux/common/b32/mod.rs index 12b0efd6cd4c8..f4d75e2fd103f 100644 --- a/src/unix/notbsd/linux/common/b32/mod.rs +++ b/src/unix/notbsd/linux/common/b32/mod.rs @@ -4,7 +4,7 @@ pub type c_ulong = u32; /* Header */ cfg_if! { - if #[cfg(feature = "file_offset64")] { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { pub const F_GETLK: ::c_int = ::F_GETLK64; pub const F_SETLK: ::c_int = ::F_SETLK64; pub const F_SETLKW: ::c_int = ::F_SETLKW64; diff --git a/src/unix/notbsd/linux/common/b32/powerpc.rs b/src/unix/notbsd/linux/common/b32/powerpc.rs index fa1df8526ed08..e8ac4fdd3fc09 100644 --- a/src/unix/notbsd/linux/common/b32/powerpc.rs +++ b/src/unix/notbsd/linux/common/b32/powerpc.rs @@ -4,7 +4,7 @@ pub type c_char = u8; s! { /* Header */ cfg_if! { - if #[cfg(feature = "file_offset64")] { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { type flock = ::flock64; } else { pub struct flock { @@ -19,7 +19,7 @@ s! { } /* Header */ -if #[cfg(feature = "file_offset64")] { +if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { pub const F_GETLK: ::c_int = 5; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; diff --git a/src/unix/notbsd/linux/common/b32/x86.rs b/src/unix/notbsd/linux/common/b32/x86.rs index be9b727feca81..7c82838bbfd9b 100644 --- a/src/unix/notbsd/linux/common/b32/x86.rs +++ b/src/unix/notbsd/linux/common/b32/x86.rs @@ -4,7 +4,7 @@ pub type c_char = i8; s! { /* Header */ cfg_if! { - if #[cfg(feature = "file_offset64")] { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { type flock = ::flock64; } else { pub struct flock { @@ -19,7 +19,7 @@ s! { } /* Header */ -if #[cfg(feature = "file_offset64")] { +if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { pub const F_GETLK: ::c_int = 5; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; diff --git a/src/unix/notbsd/linux/common/b64/mod.rs b/src/unix/notbsd/linux/common/b64/mod.rs index f56d904e28d91..7dd2659072c12 100644 --- a/src/unix/notbsd/linux/common/b64/mod.rs +++ b/src/unix/notbsd/linux/common/b64/mod.rs @@ -3,19 +3,13 @@ pub type c_long = i64; pub type c_ulong = u64; /* Header */ -cfg_if! { - if #[cfg(feature = "file_offset64")] { - type flock = ::flock64; - } else { - s! { - pub struct flock { - pub l_type: ::c_short, - pub l_whence: ::c_short, - pub l_start: ::off_t, - pub l_len: ::off_t, - pub l_pid: ::pid_t, - } - } +s! { + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, } } diff --git a/src/unix/notbsd/linux/common/mod.rs b/src/unix/notbsd/linux/common/mod.rs index f356a1e68d7cb..a63b08f32db68 100644 --- a/src/unix/notbsd/linux/common/mod.rs +++ b/src/unix/notbsd/linux/common/mod.rs @@ -1,6 +1,6 @@ /* Header */ cfg_if! { - if #[cfg(feature = "file_offset64")] { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { pub type off_t = ::off64_t; } else { pub type off_t = ::c_long; From 715cc771ac99c59d083e8955b66cc524395be4bb Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Tue, 30 Aug 2016 15:36:13 +0200 Subject: [PATCH 08/13] [Step 3][fcntl.h] Correction for Travis. --- src/unix/notbsd/linux/common/b32/mod.rs | 2 ++ src/unix/notbsd/linux/other/gnu.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/notbsd/linux/common/b32/mod.rs b/src/unix/notbsd/linux/common/b32/mod.rs index f4d75e2fd103f..b3a364fa70e76 100644 --- a/src/unix/notbsd/linux/common/b32/mod.rs +++ b/src/unix/notbsd/linux/common/b32/mod.rs @@ -8,6 +8,8 @@ cfg_if! { pub const F_GETLK: ::c_int = ::F_GETLK64; pub const F_SETLK: ::c_int = ::F_SETLK64; pub const F_SETLKW: ::c_int = ::F_SETLKW64; + } else { + } } diff --git a/src/unix/notbsd/linux/other/gnu.rs b/src/unix/notbsd/linux/other/gnu.rs index 3bd94782ca00b..1cba49c45e4ee 100644 --- a/src/unix/notbsd/linux/other/gnu.rs +++ b/src/unix/notbsd/linux/other/gnu.rs @@ -1,6 +1,6 @@ s! { /* Header */ - pub struct file_handle { + pub struct file_handle { pub handle_bytes: ::c_uint, pub handle_type: ::c_int, // pub f_handle: [::c_uchar], From e18c675420006900c81c728974584d344b3318ec Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Tue, 30 Aug 2016 15:46:05 +0200 Subject: [PATCH 09/13] [Step 3][fcntl.h] Correction for Travis 2. --- src/unix/notbsd/linux/common/b32/arm.rs | 12 ++++++------ src/unix/notbsd/linux/common/b32/mips.rs | 12 ++++++------ src/unix/notbsd/linux/common/b32/powerpc.rs | 12 ++++++------ src/unix/notbsd/linux/common/b32/x86.rs | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/unix/notbsd/linux/common/b32/arm.rs b/src/unix/notbsd/linux/common/b32/arm.rs index c32408f8569e7..a71339fb199f2 100644 --- a/src/unix/notbsd/linux/common/b32/arm.rs +++ b/src/unix/notbsd/linux/common/b32/arm.rs @@ -1,12 +1,12 @@ // Native C types pub type c_char = u8; -s! { - /* Header */ - cfg_if! { - if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { - type flock = ::flock64; - } else { +/* Header */ +cfg_if! { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + type flock = ::flock64; + } else { + s! { pub struct flock { pub l_type: ::c_short, pub l_whence: ::c_short, diff --git a/src/unix/notbsd/linux/common/b32/mips.rs b/src/unix/notbsd/linux/common/b32/mips.rs index f9ef01a6f4e2f..e49ee85f39ec7 100644 --- a/src/unix/notbsd/linux/common/b32/mips.rs +++ b/src/unix/notbsd/linux/common/b32/mips.rs @@ -1,12 +1,12 @@ // Native C types pub type c_char = i8; -s! { - /* Header */ - cfg_if! { - if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { - type flock = ::flock64; - } else { +/* Header */ +cfg_if! { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + type flock = ::flock64; + } else { + s! { pub struct flock { pub l_type: ::c_short, pub l_whence: ::c_short, diff --git a/src/unix/notbsd/linux/common/b32/powerpc.rs b/src/unix/notbsd/linux/common/b32/powerpc.rs index e8ac4fdd3fc09..c019b904893ba 100644 --- a/src/unix/notbsd/linux/common/b32/powerpc.rs +++ b/src/unix/notbsd/linux/common/b32/powerpc.rs @@ -1,12 +1,12 @@ // Native C types pub type c_char = u8; -s! { - /* Header */ - cfg_if! { - if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { - type flock = ::flock64; - } else { +/* Header */ +cfg_if! { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + type flock = ::flock64; + } else { + s! { pub struct flock { pub l_type: ::c_short, pub l_whence: ::c_short, diff --git a/src/unix/notbsd/linux/common/b32/x86.rs b/src/unix/notbsd/linux/common/b32/x86.rs index 7c82838bbfd9b..39098e01b9299 100644 --- a/src/unix/notbsd/linux/common/b32/x86.rs +++ b/src/unix/notbsd/linux/common/b32/x86.rs @@ -1,12 +1,12 @@ // Native C types pub type c_char = i8; -s! { - /* Header */ - cfg_if! { - if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { - type flock = ::flock64; - } else { +/* Header */ +cfg_if! { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + type flock = ::flock64; + } else { + s! { pub struct flock { pub l_type: ::c_short, pub l_whence: ::c_short, From 009a9d3c629c7995ba6ce02312b4b754c41fc02f Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Tue, 30 Aug 2016 16:01:18 +0200 Subject: [PATCH 10/13] [Step 3][fcntl.h] Correction for Travis 3. --- src/unix/notbsd/linux/common/b32/arm.rs | 12 ++++++++---- src/unix/notbsd/linux/common/b32/mips.rs | 12 ++++++++---- src/unix/notbsd/linux/common/b32/powerpc.rs | 12 ++++++++---- src/unix/notbsd/linux/common/b32/x86.rs | 12 ++++++++---- src/unix/notbsd/linux/musl/mod.rs | 13 +++++++++---- 5 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/unix/notbsd/linux/common/b32/arm.rs b/src/unix/notbsd/linux/common/b32/arm.rs index a71339fb199f2..5fc151ea11765 100644 --- a/src/unix/notbsd/linux/common/b32/arm.rs +++ b/src/unix/notbsd/linux/common/b32/arm.rs @@ -19,10 +19,14 @@ cfg_if! { } /* Header */ -if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { - pub const F_GETLK: ::c_int = 5; - pub const F_SETLK: ::c_int = 6; - pub const F_SETLKW: ::c_int = 7; +cfg_if! { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + pub const F_GETLK: ::c_int = 5; + pub const F_SETLK: ::c_int = 6; + pub const F_SETLKW: ::c_int = 7; + } else { + + } } pub const F_GETOWN: ::c_int = 9; pub const F_SETOWN: ::c_int = 8; diff --git a/src/unix/notbsd/linux/common/b32/mips.rs b/src/unix/notbsd/linux/common/b32/mips.rs index e49ee85f39ec7..2b34a4fbb4e2c 100644 --- a/src/unix/notbsd/linux/common/b32/mips.rs +++ b/src/unix/notbsd/linux/common/b32/mips.rs @@ -21,10 +21,14 @@ cfg_if! { } /* Header */ -if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { - pub const F_GETLK: ::c_int = 14; - pub const F_SETLK: ::c_int = 6; - pub const F_SETLKW: ::c_int = 7; +cfg_if! { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + pub const F_GETLK: ::c_int = 14; + pub const F_SETLK: ::c_int = 6; + pub const F_SETLKW: ::c_int = 7; + } else { + + } } pub const F_GETOWN: ::c_int = 23; pub const F_SETOWN: ::c_int = 24; diff --git a/src/unix/notbsd/linux/common/b32/powerpc.rs b/src/unix/notbsd/linux/common/b32/powerpc.rs index c019b904893ba..d428eed51a4b3 100644 --- a/src/unix/notbsd/linux/common/b32/powerpc.rs +++ b/src/unix/notbsd/linux/common/b32/powerpc.rs @@ -19,10 +19,14 @@ cfg_if! { } /* Header */ -if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { - pub const F_GETLK: ::c_int = 5; - pub const F_SETLK: ::c_int = 6; - pub const F_SETLKW: ::c_int = 7; +cfg_if! { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + pub const F_GETLK: ::c_int = 5; + pub const F_SETLK: ::c_int = 6; + pub const F_SETLKW: ::c_int = 7; + } else { + + } } pub const F_GETOWN: ::c_int = 9; pub const F_SETOWN: ::c_int = 8; diff --git a/src/unix/notbsd/linux/common/b32/x86.rs b/src/unix/notbsd/linux/common/b32/x86.rs index 39098e01b9299..e3b9bf71ab522 100644 --- a/src/unix/notbsd/linux/common/b32/x86.rs +++ b/src/unix/notbsd/linux/common/b32/x86.rs @@ -19,10 +19,14 @@ cfg_if! { } /* Header */ -if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { - pub const F_GETLK: ::c_int = 5; - pub const F_SETLK: ::c_int = 6; - pub const F_SETLKW: ::c_int = 7; +cfg_if! { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + pub const F_GETLK: ::c_int = 5; + pub const F_SETLK: ::c_int = 6; + pub const F_SETLKW: ::c_int = 7; + } else { + + } } pub const F_GETOWN: ::c_int = 9; pub const F_SETOWN: ::c_int = 8; diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index 259bb7a7c6cdc..0263cc21a47c7 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -1,10 +1,10 @@ -pub type clock_t = c_long; -pub type time_t = c_long; -pub type suseconds_t = c_long; +pub type clock_t = ::c_long; +pub type time_t = ::c_long; +pub type suseconds_t = ::c_long; pub type ino_t = u64; pub type blkcnt_t = i64; -pub type blksize_t = c_long; +pub type blksize_t = ::c_long; pub type fsblkcnt_t = ::c_ulonglong; pub type fsfilcnt_t = ::c_ulonglong; pub type rlim_t = ::c_ulonglong; @@ -235,6 +235,11 @@ pub const F_SETOWN_EX: ::c_int = 15; pub const F_GETOWN_EX: ::c_int = 16; pub const F_GETOWNER_UIDS: ::c_int = 17; +// This macro is NOT defined in Musl, but the macro +// FFSYNC is defined as being equal to O_FSYNC. This is +// a bug in Musl itself, but has to be solved here for the tests to work. +pub const O_FSYNC: ::c_int = ::O_SYNC; + extern { pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; From 959d09ab94e0268d9b1846eafc48b1f1d50d60c9 Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Tue, 30 Aug 2016 17:00:31 +0200 Subject: [PATCH 11/13] [Step 3][fcntl.h] Correction for Travis 4. --- src/unix/notbsd/linux/common/b32/arm.rs | 2 +- src/unix/notbsd/linux/common/b32/mips.rs | 2 +- src/unix/notbsd/linux/common/b32/powerpc.rs | 2 +- src/unix/notbsd/linux/common/b32/x86.rs | 2 +- src/unix/notbsd/linux/mips.rs | 6 +++++- src/unix/notbsd/linux/mips64.rs | 4 ++++ src/unix/notbsd/linux/mod.rs | 2 +- src/unix/notbsd/linux/other/gnu.rs | 8 ++++---- 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/unix/notbsd/linux/common/b32/arm.rs b/src/unix/notbsd/linux/common/b32/arm.rs index 5fc151ea11765..7af4a4256f5ae 100644 --- a/src/unix/notbsd/linux/common/b32/arm.rs +++ b/src/unix/notbsd/linux/common/b32/arm.rs @@ -20,7 +20,7 @@ cfg_if! { /* Header */ cfg_if! { - if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + if #[cfg(not(any(feature = "file_offset64", target_env = "musl")))] { pub const F_GETLK: ::c_int = 5; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; diff --git a/src/unix/notbsd/linux/common/b32/mips.rs b/src/unix/notbsd/linux/common/b32/mips.rs index 2b34a4fbb4e2c..6a9116adb4a37 100644 --- a/src/unix/notbsd/linux/common/b32/mips.rs +++ b/src/unix/notbsd/linux/common/b32/mips.rs @@ -22,7 +22,7 @@ cfg_if! { /* Header */ cfg_if! { - if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + if #[cfg(not(any(feature = "file_offset64", target_env = "musl")))] { pub const F_GETLK: ::c_int = 14; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; diff --git a/src/unix/notbsd/linux/common/b32/powerpc.rs b/src/unix/notbsd/linux/common/b32/powerpc.rs index d428eed51a4b3..7fa4deb880636 100644 --- a/src/unix/notbsd/linux/common/b32/powerpc.rs +++ b/src/unix/notbsd/linux/common/b32/powerpc.rs @@ -20,7 +20,7 @@ cfg_if! { /* Header */ cfg_if! { - if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + if #[cfg(not(any(feature = "file_offset64", target_env = "musl")))] { pub const F_GETLK: ::c_int = 5; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; diff --git a/src/unix/notbsd/linux/common/b32/x86.rs b/src/unix/notbsd/linux/common/b32/x86.rs index e3b9bf71ab522..b68175634f50d 100644 --- a/src/unix/notbsd/linux/common/b32/x86.rs +++ b/src/unix/notbsd/linux/common/b32/x86.rs @@ -20,7 +20,7 @@ cfg_if! { /* Header */ cfg_if! { - if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + if #[cfg(not(any(feature = "file_offset64", target_env = "musl")))] { pub const F_GETLK: ::c_int = 5; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index dd0a7f28605bf..5cc76c90d8200 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -8,7 +8,7 @@ pub type blksize_t = i32; pub type nlink_t = u32; pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; -pub type rlim_t = c_ulong; +pub type rlim_t = ::c_ulong; s! { pub struct stat { @@ -559,6 +559,10 @@ pub const ICANON: ::tcflag_t = 0x00000002; pub const PENDIN: ::tcflag_t = 0x00004000; pub const NOFLSH: ::tcflag_t = 0x00000080; +// Dirty hack to make tests pass, but it is actually already defined +// in the `other` module. +pub const O_FSYNC: ::c_int = ::O_SYNC; + #[link(name = "util")] extern { pub fn sysctl(name: *mut ::c_int, diff --git a/src/unix/notbsd/linux/mips64.rs b/src/unix/notbsd/linux/mips64.rs index 765639a3fc665..d89786ebd70d2 100644 --- a/src/unix/notbsd/linux/mips64.rs +++ b/src/unix/notbsd/linux/mips64.rs @@ -203,6 +203,10 @@ pub const SO_RCVTIMEO: ::c_int = 4102; pub const SO_REUSEADDR: ::c_int = 4; pub const SO_SNDTIMEO: ::c_int = 4101; +// Dirty hack to make tests pass, but it is actually already defined +// in the `other` module. +pub const O_FSYNC: ::c_int = ::O_SYNC; + #[link(name = "util")] extern { pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 642a7cdb9572b..ca66feafa64f1 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -665,7 +665,7 @@ extern { pub fn readahead(fd: ::c_int, offset: ::off64_t, count: ::size_t) -> ::ssize_t; pub fn sync_file_range(fd: ::c_int, from: ::off64_t, to: ::off64_t, - flags: ::c_uint) -> ::c_int; + flags: ::c_uint) -> ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/linux/other/gnu.rs b/src/unix/notbsd/linux/other/gnu.rs index 1cba49c45e4ee..b43c451910c16 100644 --- a/src/unix/notbsd/linux/other/gnu.rs +++ b/src/unix/notbsd/linux/other/gnu.rs @@ -38,10 +38,10 @@ extern { /* Header */ pub fn name_to_handle_at(dfd: ::c_int, name: *const ::c_char, - handle: *mut ::file_handle, - mnt_id: *mut ::c_int, - flags: ::c_int) -> ::c_int; + handle: *mut ::file_handle, + mnt_id: *mut ::c_int, + flags: ::c_int) -> ::c_int; pub fn open_by_handle_at(mountdirfd: ::c_int, handle: *mut ::file_handle, - flags: ::c_int) -> ::c_int; + flags: ::c_int) -> ::c_int; } From 26125245c75c69f9bb77de80abf1cff01a0f1010 Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Tue, 30 Aug 2016 18:04:47 +0200 Subject: [PATCH 12/13] [Step 3][fcntl.h] Correction for Travis 5. --- src/unix/notbsd/linux/common/mod.rs | 5 +++++ src/unix/notbsd/linux/mod.rs | 2 +- src/unix/notbsd/linux/musl/mod.rs | 5 ----- src/unix/notbsd/linux/other/gnu.rs | 6 +++++- src/unix/notbsd/mod.rs | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/unix/notbsd/linux/common/mod.rs b/src/unix/notbsd/linux/common/mod.rs index a63b08f32db68..71704336edc1f 100644 --- a/src/unix/notbsd/linux/common/mod.rs +++ b/src/unix/notbsd/linux/common/mod.rs @@ -27,8 +27,13 @@ pub const F_UNLCK: ::c_short = 2; // Here start non POSIX definitions. pub const AT_NO_AUTOMOUNT: ::c_int = 0x800; pub const AT_EMPTY_PATH: ::c_int = 0x1000; +pub const AT_EACCESS: ::c_int = 0x200; pub const FAPPEND: ::c_int = ::O_APPEND; +// The macro O_FSYNC is NOT defined in Musl, but the macro +// FFSYNC is defined as being equal to O_FSYNC. This is +// a bug in Musl itself, but has to be solved here for the tests to work. +#[cfg(not(target_env = "musl"))] pub const FFSYNC: ::c_int = ::O_FSYNC; pub const FASYNC: ::c_int = ::O_ASYNC; pub const FNONBLOCK: ::c_int = ::O_NONBLOCK; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index ca66feafa64f1..dd9308691e5f5 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -661,7 +661,7 @@ extern { pub fn fallocate(fd: ::c_int, mode: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; pub fn fallocate64(fd: ::c_int, mode: ::c_int, - offset: ::off_t, len: ::off_t) -> ::c_int; + offset: ::off64_t, len: ::off64_t) -> ::c_int; pub fn readahead(fd: ::c_int, offset: ::off64_t, count: ::size_t) -> ::ssize_t; pub fn sync_file_range(fd: ::c_int, from: ::off64_t, to: ::off64_t, diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index 0263cc21a47c7..5d3d92438f75f 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -235,11 +235,6 @@ pub const F_SETOWN_EX: ::c_int = 15; pub const F_GETOWN_EX: ::c_int = 16; pub const F_GETOWNER_UIDS: ::c_int = 17; -// This macro is NOT defined in Musl, but the macro -// FFSYNC is defined as being equal to O_FSYNC. This is -// a bug in Musl itself, but has to be solved here for the tests to work. -pub const O_FSYNC: ::c_int = ::O_SYNC; - extern { pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; diff --git a/src/unix/notbsd/linux/other/gnu.rs b/src/unix/notbsd/linux/other/gnu.rs index b43c451910c16..2a88f91d1f236 100644 --- a/src/unix/notbsd/linux/other/gnu.rs +++ b/src/unix/notbsd/linux/other/gnu.rs @@ -13,7 +13,9 @@ pub const F_OFD_SETLK: ::c_int = 37; pub const F_OFD_SETLKW: ::c_int = 38; // Here start non POSIX definitions. -pub const FSYNC: ::c_int = ::O_SYNC; +/* Defined in glibc but doesn’t seem to exist for Linux. +pub const FSYNC: ::c_int = ::O_SYNC;) +*/ pub const F_OWNER_TID: ::c_int = 0; pub const F_OWNER_PID: ::c_int = 1; @@ -25,11 +27,13 @@ pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10; pub const MAX_HANDLE_SZ: ::size_t = 128; +/* Defined in glibc but don’t seem to exist for Linux. pub const O_SHLOCK: ::c_int = 0x0010; pub const O_EXLOCK: ::c_int = 0x0020; pub const FREAD: ::c_int = 1; pub const FWRITE: ::c_int = 2; +*/ pub const F_SETOWN_EX: ::c_int = 15; pub const F_GETOWN_EX: ::c_int = 16; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 45113977508d7..10244cec88bed 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -604,7 +604,7 @@ pub const O_WRONLY: ::c_int = 1; pub const O_RDWR: ::c_int = 2; pub const AT_FDCWD: ::c_int = -100; -pub const AT_EACCESS: ::c_int = 0x200; +// AT_EACCESS doesn’t exist in Bionic (for Android). pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100; pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; pub const AT_REMOVEDIR: ::c_int = 0x200; From 43b09bd0189203058289e824335f7ab369e8b0d7 Mon Sep 17 00:00:00 2001 From: Guillaume Lestringant Date: Tue, 30 Aug 2016 19:17:50 +0200 Subject: [PATCH 13/13] [Step 3][fcntl.h] Correction for Travis 6. --- src/unix/notbsd/linux/common/b64/aarch64.rs | 2 +- src/unix/notbsd/linux/common/b64/powerpc64.rs | 2 +- src/unix/notbsd/linux/common/mod.rs | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/unix/notbsd/linux/common/b64/aarch64.rs b/src/unix/notbsd/linux/common/b64/aarch64.rs index ab144283f5e9f..200283b7b5f80 100644 --- a/src/unix/notbsd/linux/common/b64/aarch64.rs +++ b/src/unix/notbsd/linux/common/b64/aarch64.rs @@ -25,7 +25,7 @@ pub const O_SYNC: ::c_int = 0x101000; // Here start non POSIX definitions. pub const O_ASYNC: ::c_int = 0x2000; pub const O_DIRECT: ::c_int = 0x10000; -pub const O_LARGEFILE: ::c_int = 0x20000; +pub const O_LARGEFILE: ::c_int = 0; pub const O_NOATIME: ::c_int = 0x40000; pub const O_PATH: ::c_int = 0x200000; pub const O_TMPFILE: ::c_int = 0x404000; diff --git a/src/unix/notbsd/linux/common/b64/powerpc64.rs b/src/unix/notbsd/linux/common/b64/powerpc64.rs index 08302d8baf128..f53c5378d9082 100644 --- a/src/unix/notbsd/linux/common/b64/powerpc64.rs +++ b/src/unix/notbsd/linux/common/b64/powerpc64.rs @@ -25,7 +25,7 @@ pub const O_SYNC: ::c_int = 0x101000; // Here start non POSIX definitions. pub const O_ASYNC: ::c_int = 0x2000; pub const O_DIRECT: ::c_int = 0x20000; -pub const O_LARGEFILE: ::c_int = 0x10000; +pub const O_LARGEFILE: ::c_int = 0; pub const O_NOATIME: ::c_int = 0x40000; pub const O_PATH: ::c_int = 0x200000; pub const O_TMPFILE: ::c_int = 0x404000; diff --git a/src/unix/notbsd/linux/common/mod.rs b/src/unix/notbsd/linux/common/mod.rs index 71704336edc1f..59b6b96b0e721 100644 --- a/src/unix/notbsd/linux/common/mod.rs +++ b/src/unix/notbsd/linux/common/mod.rs @@ -33,8 +33,13 @@ pub const FAPPEND: ::c_int = ::O_APPEND; // The macro O_FSYNC is NOT defined in Musl, but the macro // FFSYNC is defined as being equal to O_FSYNC. This is // a bug in Musl itself, but has to be solved here for the tests to work. -#[cfg(not(target_env = "musl"))] -pub const FFSYNC: ::c_int = ::O_FSYNC; +cfg_if! { + if #[cfg(not(target_env = "musl"))] { + pub const FFSYNC: ::c_int = ::O_FSYNC; + } else { + + } +} pub const FASYNC: ::c_int = ::O_ASYNC; pub const FNONBLOCK: ::c_int = ::O_NONBLOCK; pub const FNDELAY: ::c_int = ::O_NDELAY;