Skip to content

Commit 4858568

Browse files
committed
Add MADV_* constants for Linux
1 parent b9f0372 commit 4858568

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

libc-test/build.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,14 @@ fn test_android(target: &str) {
17881788
// kernel 5.10 minimum required
17891789
"MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ" | "MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ" => true,
17901790

1791+
// kernel 5.18 minimum
1792+
| "MADV_COLD"
1793+
| "MADV_DONTNEED_LOCKED"
1794+
| "MADV_PAGEOUT"
1795+
| "MADV_POPULATE_READ"
1796+
| "MADV_POPULATE_WRITE" => true,
1797+
1798+
17911799
_ => false,
17921800
}
17931801
});
@@ -3714,13 +3722,20 @@ fn test_linux(target: &str) {
37143722
// Added in Linux 5.13
37153723
"PTRACE_GET_RSEQ_CONFIGURATION" if sparc64 => true,
37163724

3725+
| "MADV_COLD"
3726+
| "MADV_PAGEOUT"
3727+
| "MADV_POPULATE_READ"
3728+
| "MADV_POPULATE_WRITE"
3729+
if musl => true,
3730+
37173731
// FIXME: Requires more recent kernel headers
37183732
| "IFLA_PARENT_DEV_NAME" // linux v5.13+
37193733
| "IFLA_PARENT_DEV_BUS_NAME" // linux v5.13+
37203734
| "IFLA_GRO_MAX_SIZE" // linux v5.16+
37213735
| "IFLA_TSO_MAX_SIZE" // linux v5.18+
37223736
| "IFLA_TSO_MAX_SEGS" // linux v5.18+
37233737
| "IFLA_ALLMULTI" // linux v6.0+
3738+
| "MADV_DONTNEED_LOCKED" // linux v5.18+
37243739
=> true,
37253740
"SCTP_FUTURE_ASSOC" | "SCTP_CURRENT_ASSOC" | "SCTP_ALL_ASSOC" | "SCTP_PEER_ADDR_THLDS_V2" => true, // linux 5.5+
37263741

libc-test/semver/linux.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,22 +1286,29 @@ LOG_FTP
12861286
LOG_NFACILITIES
12871287
LOG_PERROR
12881288
L_tmpnam
1289+
MADV_COLD
12891290
MADV_DODUMP
12901291
MADV_DOFORK
12911292
MADV_DONTDUMP
12921293
MADV_DONTFORK
12931294
MADV_DONTNEED
1295+
MADV_DONTNEED_LOCKED
12941296
MADV_FREE
12951297
MADV_HUGEPAGE
12961298
MADV_HWPOISON
1299+
MADV_KEEPONFORK
12971300
MADV_MERGEABLE
12981301
MADV_NOHUGEPAGE
12991302
MADV_NORMAL
1303+
MADV_PAGEOUT
1304+
MADV_POPULATE_READ
1305+
MADV_POPULATE_WRITE
13001306
MADV_RANDOM
13011307
MADV_REMOVE
13021308
MADV_SEQUENTIAL
13031309
MADV_UNMERGEABLE
13041310
MADV_WILLNEED
1311+
MADV_WIPEONFORK
13051312
MAP_DENYWRITE
13061313
MAP_EXECUTABLE
13071314
MAP_FILE

src/unix/linux_like/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,18 @@ pub const MADV_HUGEPAGE: ::c_int = 14;
654654
pub const MADV_NOHUGEPAGE: ::c_int = 15;
655655
pub const MADV_DONTDUMP: ::c_int = 16;
656656
pub const MADV_DODUMP: ::c_int = 17;
657+
pub const MADV_WIPEONFORK: ::c_int = 18;
658+
pub const MADV_KEEPONFORK: ::c_int = 19;
659+
pub const MADV_COLD: ::c_int = 20;
660+
pub const MADV_PAGEOUT: ::c_int = 21;
657661
pub const MADV_HWPOISON: ::c_int = 100;
662+
cfg_if! {
663+
if #[cfg(not(target_os = "emscripten"))] {
664+
pub const MADV_POPULATE_READ: ::c_int = 22;
665+
pub const MADV_POPULATE_WRITE: ::c_int = 23;
666+
pub const MADV_DONTNEED_LOCKED: ::c_int = 24;
667+
}
668+
}
658669

659670
pub const IFF_UP: ::c_int = 0x1;
660671
pub const IFF_BROADCAST: ::c_int = 0x2;

0 commit comments

Comments
 (0)