From 48585683b9aea479f398c1dab54c6aca05deaa6e Mon Sep 17 00:00:00 2001 From: tatref Date: Fri, 21 Apr 2023 22:43:36 +0200 Subject: Add MADV_* constants for Linux --- libc-test/build.rs | 15 +++++++++++++++ libc-test/semver/linux.txt | 7 +++++++ src/unix/linux_like/mod.rs | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index ac0f996fc4..e4141b45ac 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1788,6 +1788,14 @@ fn test_android(target: &str) { // kernel 5.10 minimum required "MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ" | "MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ" => true, + // kernel 5.18 minimum + | "MADV_COLD" + | "MADV_DONTNEED_LOCKED" + | "MADV_PAGEOUT" + | "MADV_POPULATE_READ" + | "MADV_POPULATE_WRITE" => true, + + _ => false, } }); @@ -3714,6 +3722,12 @@ fn test_linux(target: &str) { // Added in Linux 5.13 "PTRACE_GET_RSEQ_CONFIGURATION" if sparc64 => true, + | "MADV_COLD" + | "MADV_PAGEOUT" + | "MADV_POPULATE_READ" + | "MADV_POPULATE_WRITE" + if musl => true, + // FIXME: Requires more recent kernel headers | "IFLA_PARENT_DEV_NAME" // linux v5.13+ | "IFLA_PARENT_DEV_BUS_NAME" // linux v5.13+ @@ -3721,6 +3735,7 @@ fn test_linux(target: &str) { | "IFLA_TSO_MAX_SIZE" // linux v5.18+ | "IFLA_TSO_MAX_SEGS" // linux v5.18+ | "IFLA_ALLMULTI" // linux v6.0+ + | "MADV_DONTNEED_LOCKED" // linux v5.18+ => true, "SCTP_FUTURE_ASSOC" | "SCTP_CURRENT_ASSOC" | "SCTP_ALL_ASSOC" | "SCTP_PEER_ADDR_THLDS_V2" => true, // linux 5.5+ diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 178f76d946..c360a7da86 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -1286,22 +1286,29 @@ LOG_FTP LOG_NFACILITIES LOG_PERROR L_tmpnam +MADV_COLD MADV_DODUMP MADV_DOFORK MADV_DONTDUMP MADV_DONTFORK MADV_DONTNEED +MADV_DONTNEED_LOCKED MADV_FREE MADV_HUGEPAGE MADV_HWPOISON +MADV_KEEPONFORK MADV_MERGEABLE MADV_NOHUGEPAGE MADV_NORMAL +MADV_PAGEOUT +MADV_POPULATE_READ +MADV_POPULATE_WRITE MADV_RANDOM MADV_REMOVE MADV_SEQUENTIAL MADV_UNMERGEABLE MADV_WILLNEED +MADV_WIPEONFORK MAP_DENYWRITE MAP_EXECUTABLE MAP_FILE diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index db57745967..61f03ad8c2 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -654,7 +654,18 @@ pub const MADV_HUGEPAGE: ::c_int = 14; pub const MADV_NOHUGEPAGE: ::c_int = 15; pub const MADV_DONTDUMP: ::c_int = 16; pub const MADV_DODUMP: ::c_int = 17; +pub const MADV_WIPEONFORK: ::c_int = 18; +pub const MADV_KEEPONFORK: ::c_int = 19; +pub const MADV_COLD: ::c_int = 20; +pub const MADV_PAGEOUT: ::c_int = 21; pub const MADV_HWPOISON: ::c_int = 100; +cfg_if! { + if #[cfg(not(target_os = "emscripten"))] { + pub const MADV_POPULATE_READ: ::c_int = 22; + pub const MADV_POPULATE_WRITE: ::c_int = 23; + pub const MADV_DONTNEED_LOCKED: ::c_int = 24; + } +} pub const IFF_UP: ::c_int = 0x1; pub const IFF_BROADCAST: ::c_int = 0x2; -- cgit v1.2.1 From f3e1417b9ff392372a374fac2ac84e4c984b6bf5 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 22 Apr 2023 11:15:33 +0900 Subject: Ignore on sparc64 as well --- libc-test/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index e4141b45ac..85536110cf 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3726,7 +3726,7 @@ fn test_linux(target: &str) { | "MADV_PAGEOUT" | "MADV_POPULATE_READ" | "MADV_POPULATE_WRITE" - if musl => true, + if sparc64 || musl => true, // FIXME: Requires more recent kernel headers | "IFLA_PARENT_DEV_NAME" // linux v5.13+ -- cgit v1.2.1