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/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 new file mode 100644 index 0000000000000..7af4a4256f5ae --- /dev/null +++ b/src/unix/notbsd/linux/common/b32/arm.rs @@ -0,0 +1,60 @@ +// Native C types +pub type c_char = u8; + +/* 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, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + } + } +} + +/* Header */ +cfg_if! { + 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; + } else { + + } +} +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; + +// 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 new file mode 100644 index 0000000000000..6a9116adb4a37 --- /dev/null +++ b/src/unix/notbsd/linux/common/b32/mips.rs @@ -0,0 +1,61 @@ +// Native C types +pub type c_char = i8; + +/* 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, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_sysid: ::c_long, + pub l_pid: ::pid_t, + pad: [::c_long; 4], + } + } + } +} + +/* Header */ +cfg_if! { + 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; + } else { + + } +} +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; + +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 new file mode 100644 index 0000000000000..b3a364fa70e76 --- /dev/null +++ b/src/unix/notbsd/linux/common/b32/mod.rs @@ -0,0 +1,33 @@ +// Native C types +pub type c_long = i32; +pub type c_ulong = u32; + +/* Header */ +cfg_if! { + 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; + } else { + + } +} + +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..7fa4deb880636 --- /dev/null +++ b/src/unix/notbsd/linux/common/b32/powerpc.rs @@ -0,0 +1,60 @@ +// Native C types +pub type c_char = u8; + +/* 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, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + } + } +} + +/* Header */ +cfg_if! { + 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; + } else { + + } +} +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; + +// 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 new file mode 100644 index 0000000000000..b68175634f50d --- /dev/null +++ b/src/unix/notbsd/linux/common/b32/x86.rs @@ -0,0 +1,60 @@ +// Native C types +pub type c_char = i8; + +/* 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, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + } + } +} + +/* Header */ +cfg_if! { + 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; + } else { + + } +} +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; + +// 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 new file mode 100644 index 0000000000000..200283b7b5f80 --- /dev/null +++ b/src/unix/notbsd/linux/common/b64/aarch64.rs @@ -0,0 +1,33 @@ +// 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; + +// 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 = 0; +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 new file mode 100644 index 0000000000000..daf126d2db014 --- /dev/null +++ b/src/unix/notbsd/linux/common/b64/mips64.rs @@ -0,0 +1,32 @@ +// 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; + +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/mod.rs b/src/unix/notbsd/linux/common/b64/mod.rs new file mode 100644 index 0000000000000..7dd2659072c12 --- /dev/null +++ b/src/unix/notbsd/linux/common/b64/mod.rs @@ -0,0 +1,32 @@ +// Native C types +pub type c_long = i64; +pub type c_ulong = u64; + +/* Header */ +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, + } +} + +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..f53c5378d9082 --- /dev/null +++ b/src/unix/notbsd/linux/common/b64/powerpc64.rs @@ -0,0 +1,33 @@ +// 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; + +// 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 = 0; +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 new file mode 100644 index 0000000000000..b01f5cbd401ac --- /dev/null +++ b/src/unix/notbsd/linux/common/b64/x86_64.rs @@ -0,0 +1,33 @@ +// 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; + +// 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 new file mode 100644 index 0000000000000..59b6b96b0e721 --- /dev/null +++ b/src/unix/notbsd/linux/common/mod.rs @@ -0,0 +1,82 @@ +/* Header */ +cfg_if! { + if #[cfg(any(feature = "file_offset64", target_env = "musl"))] { + 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, + } +} + +/* 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 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_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; + +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", + 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 + } +} + diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index a2143d5e2039a..5cc76c90d8200 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -1,18 +1,14 @@ -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; 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; 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 { @@ -163,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], @@ -206,10 +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 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; @@ -222,18 +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_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; - pub const SOCK_NONBLOCK: ::c_int = 128; pub const EDEADLK: ::c_int = 45; @@ -489,12 +459,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; @@ -595,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 7c51dffba44ac..d89786ebd70d2 100644 --- a/src/unix/notbsd/linux/mips64.rs +++ b/src/unix/notbsd/linux/mips64.rs @@ -1,13 +1,9 @@ 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; 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; @@ -191,11 +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 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; @@ -212,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 33738f4beb073..dd9308691e5f5 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, @@ -541,12 +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 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, value: *mut ::c_void, size: ::size_t) -> ::ssize_t; pub fn lgetxattr(path: *const c_char, name: *const c_char, @@ -660,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: ::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, + flags: ::c_uint) -> ::c_int; } cfg_if! { @@ -667,14 +673,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::*; } } diff --git a/src/unix/notbsd/linux/musl/b32/arm.rs b/src/unix/notbsd/linux/musl/b32/arm.rs index 2f27e31136a8b..022f9105328f4 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! { @@ -92,11 +91,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; pub const FIONBIO: ::c_int = 0x5421; @@ -106,15 +100,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; @@ -267,12 +252,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 88542c45b4fde..2dc0a813d0baf 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! { @@ -91,11 +90,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; pub const FIONBIO: ::c_int = 0x667E; @@ -105,15 +99,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; @@ -266,12 +251,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/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..8eeceadd587b2 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! { @@ -105,11 +104,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; pub const FIONBIO: ::c_int = 0x5421; @@ -119,15 +113,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; @@ -281,12 +266,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/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..7f65af4a467e8 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! { @@ -116,11 +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_DIRECTORY: ::c_int = 0x10000; -pub const O_NOFOLLOW: ::c_int = 0x20000; -pub const O_ASYNC: ::c_int = 0x2000; - pub const FIOCLEX: ::c_int = 0x5451; pub const FIONBIO: ::c_int = 0x5421; @@ -130,15 +123,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; @@ -292,12 +276,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/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/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index b9fb3d42f3ac3..5d3d92438f75f 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -1,11 +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 off_t = i64; 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; @@ -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], @@ -70,8 +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; @@ -94,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; @@ -219,6 +205,36 @@ 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; + +// 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 f3871f3c2ffba..dfd95c711fa8f 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! { @@ -55,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/mod.rs b/src/unix/notbsd/linux/other/b32/mod.rs index 48c3502ada1b6..4a936070f3406 100644 --- a/src/unix/notbsd/linux/other/b32/mod.rs +++ b/src/unix/notbsd/linux/other/b32/mod.rs @@ -1,12 +1,9 @@ //! 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; 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/b32/powerpc.rs b/src/unix/notbsd/linux/other/b32/powerpc.rs index ef21eda0ce5cc..6c010ffbe96fe 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! { @@ -55,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 6f8587a89363b..9a605798fcac0 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; @@ -89,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 d9f940bc399af..89e9e5cd9cfca 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; @@ -86,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/mod.rs b/src/unix/notbsd/linux/other/b64/mod.rs index ccf99881f76cc..3fc3fc2283087 100644 --- a/src/unix/notbsd/linux/other/b64/mod.rs +++ b/src/unix/notbsd/linux/other/b64/mod.rs @@ -1,12 +1,9 @@ //! 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; 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/b64/powerpc64.rs b/src/unix/notbsd/linux/other/b64/powerpc64.rs index c5ce962e39aa1..46f5c3423d778 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; @@ -83,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 f19a9ffe4adcd..3942b83de4010 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; @@ -124,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 new file mode 100644 index 0000000000000..2a88f91d1f236 --- /dev/null +++ b/src/unix/notbsd/linux/other/gnu.rs @@ -0,0 +1,51 @@ +s! { + /* Header */ + pub struct file_handle { + pub handle_bytes: ::c_uint, + pub handle_type: ::c_int, +// 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. +/* 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; +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; + +/* 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; + +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; + 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 ac3e0c39797a4..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! { @@ -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")] @@ -156,17 +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_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; +pub const SOCK_NONBLOCK: ::c_int = ::O_NONBLOCK; pub const LC_PAPER: ::c_int = 7; pub const LC_NAME: ::c_int = 8; @@ -350,18 +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_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; pub const ST_RELATIME: ::c_ulong = 4096; pub const NI_MAXHOST: ::socklen_t = 1025; @@ -435,12 +411,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; @@ -492,6 +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; @@ -555,3 +544,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 diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index a3d60ca6cc237..10244cec88bed 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -184,20 +184,6 @@ 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; - // TODO(#235): Include file sealing fcntls once we have a way to verify them. pub const SIGTRAP: ::c_int = 5; @@ -234,12 +220,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; @@ -471,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; @@ -602,23 +577,8 @@ 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 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 +588,46 @@ 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; +// 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; + +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; + +// 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; @@ -753,23 +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 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 +762,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 +774,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 +785,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 +824,39 @@ 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; + + 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! {