Skip to content

Commit c9e6f55

Browse files
committed
Add MADV_FREE and MADV_SOFT_OFFLINE for Android/Linux
1 parent 916b82d commit c9e6f55

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

libc-test/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ fn main() {
199199
}
200200

201201
if linux || android {
202+
cfg.header("asm/mman.h");
202203
cfg.header("malloc.h");
203204
cfg.header("net/ethernet.h");
204205
cfg.header("netpacket/packet.h");
@@ -459,6 +460,11 @@ fn main() {
459460
// asm/termios.h and ioctl.h (+ some other headers) because of redeclared types.
460461
"CMSPAR" if mips && linux && !musl => true,
461462

463+
// On mips Linux targets, MADV_SOFT_OFFLINE is currently missing, though it's been added but CI has too old
464+
// of a Linux version. Since it exists on all other Linux targets, just ignore this for now and remove once
465+
// it's been fixed in CI.
466+
"MADV_SOFT_OFFLINE" if mips && linux => true,
467+
462468
_ => false,
463469
}
464470
});

src/unix/notbsd/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,14 @@ pub const MADV_RANDOM: ::c_int = 1;
411411
pub const MADV_SEQUENTIAL: ::c_int = 2;
412412
pub const MADV_WILLNEED: ::c_int = 3;
413413
pub const MADV_DONTNEED: ::c_int = 4;
414+
pub const MADV_FREE: ::c_int = 8;
414415
pub const MADV_REMOVE: ::c_int = 9;
415416
pub const MADV_DONTFORK: ::c_int = 10;
416417
pub const MADV_DOFORK: ::c_int = 11;
417418
pub const MADV_MERGEABLE: ::c_int = 12;
418419
pub const MADV_UNMERGEABLE: ::c_int = 13;
419420
pub const MADV_HWPOISON: ::c_int = 100;
421+
pub const MADV_SOFT_OFFLINE: ::c_int = 101;
420422

421423
pub const IFF_UP: ::c_int = 0x1;
422424
pub const IFF_BROADCAST: ::c_int = 0x2;

0 commit comments

Comments
 (0)