Skip to content

Commit

Permalink
Upstream a few more constants from rustix.
Browse files Browse the repository at this point in the history
 - And a definition for `RLIM64_INFINITY` on linux_like platforms.
 - Declare the `sync` function on Android and solarish.
   - Solaris: https://docs.oracle.com/cd/E26502_01/html/E29032/sync-2.html
   - Illumos: https://illumos.org/man/2/sync
 - Enable `FICLONE` and `FICLONERANGE` on more architectures.
  • Loading branch information
sunfishcode committed Apr 18, 2023
1 parent 88740ef commit 0ba1fc4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2025,6 +2025,7 @@ RESOLVE_IN_ROOT
RESOLVE_NO_MAGICLINKS
RESOLVE_NO_SYMLINKS
RESOLVE_NO_XDEV
RLIM64_INFINITY
RLIMIT_AS
RLIMIT_CORE
RLIMIT_CPU
Expand Down
18 changes: 18 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,23 @@ pub const FIONREAD: ::c_int = 0x541B;
pub const TIOCCONS: ::c_int = 0x541D;
pub const TIOCSBRK: ::c_int = 0x5427;
pub const TIOCCBRK: ::c_int = 0x5428;
cfg_if! {
if #[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "s390x"))] {
pub const FICLONE: ::c_int = 0x40049409;
pub const FICLONERANGE: ::c_int = 0x4020940D;
} else if #[cfg(any(target_arch = "mips",
target_arch = "mips64",
target_arch = "powerpc",
target_arch = "powerpc64"))] {
pub const FICLONE: ::c_int = 0x80049409;
pub const FICLONERANGE: ::c_int = 0x8020940D;
}
}

pub const ST_RDONLY: ::c_ulong = 1;
pub const ST_NOSUID: ::c_ulong = 2;
Expand Down Expand Up @@ -3531,6 +3548,7 @@ extern "C" {
longindex: *mut ::c_int,
) -> ::c_int;

pub fn sync();
pub fn syncfs(fd: ::c_int) -> ::c_int;
}

Expand Down
11 changes: 10 additions & 1 deletion src/unix/linux_like/linux/arch/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,18 @@ cfg_if! {
cfg_if! {
if #[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "aarch64"))] {
target_arch = "arm",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "s390x"))] {
pub const FICLONE: ::c_ulong = 0x40049409;
pub const FICLONERANGE: ::c_ulong = 0x4020940D;
} else if #[cfg(any(target_arch = "mips",
target_arch = "mips64",
target_arch = "powerpc",
target_arch = "powerpc64"))] {
pub const FICLONE: ::c_ulong = 0x80049409;
pub const FICLONERANGE: ::c_ulong = 0x8020940D;
}
}
// pub const SO_PREFER_BUSY_POLL: ::c_int = 69;
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,14 @@ pub const PROT_EXEC: ::c_int = 4;
pub const XATTR_CREATE: ::c_int = 0x1;
pub const XATTR_REPLACE: ::c_int = 0x2;

cfg_if! {
if #[cfg(target_os = "android")] {
pub const RLIM64_INFINITY: ::c_ulonglong = !0;
} else {
pub const RLIM64_INFINITY: ::rlim64_t = !0;
}
}

cfg_if! {
if #[cfg(target_env = "ohos")] {
pub const LC_CTYPE: ::c_int = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/unix/solarish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3196,6 +3196,8 @@ extern "C" {
longopts: *const option,
longindex: *mut ::c_int,
) -> ::c_int;

pub fn sync();
}

#[link(name = "sendfile")]
Expand Down

0 comments on commit 0ba1fc4

Please sign in to comment.