Skip to content

Commit 6846305

Browse files
committed
Auto merge of rust-lang#722 - Susurrus:mman_constants, r=alexcrichton
Add some more missing pieces * some constants for mman * `WIFCONTINUED()` for NetBSD & OpenBSD
2 parents 65dac15 + 70975a2 commit 6846305

File tree

10 files changed

+26
-18
lines changed

10 files changed

+26
-18
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/bsd/freebsdlike/freebsd/aarch64.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ s! {
2828
pub st_birthtime_nsec: ::c_long,
2929
}
3030
}
31+
32+
pub const MAP_32BIT: ::c_int = 0x00080000;

src/unix/bsd/freebsdlike/freebsd/x86_64.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ s! {
2828
pub st_birthtime_nsec: ::c_long,
2929
}
3030
}
31+
32+
pub const MAP_32BIT: ::c_int = 0x00080000;

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,10 @@ f! {
743743
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int {
744744
unsafe { *(dirp as *const ::c_int) }
745745
}
746+
747+
pub fn WIFCONTINUED(status: ::c_int) -> bool {
748+
status == 0xffff
749+
}
746750
}
747751

748752
extern {

src/unix/bsd/netbsdlike/openbsdlike/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,12 @@ pub const SOCK_CLOEXEC: ::c_int = 0x8000;
583583
pub const SOCK_NONBLOCK: ::c_int = 0x4000;
584584
pub const SOCK_DNS: ::c_int = 0x1000;
585585

586+
f! {
587+
pub fn WIFCONTINUED(status: ::c_int) -> bool {
588+
status & 0o177777 == 0o177777
589+
}
590+
}
591+
586592
extern {
587593
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
588594
pub fn getnameinfo(sa: *const ::sockaddr,

src/unix/notbsd/android/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,6 @@ pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b;
581581
pub const TMPFS_MAGIC: ::c_long = 0x01021994;
582582
pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2;
583583

584-
pub const MADV_HUGEPAGE: ::c_int = 14;
585-
pub const MADV_NOHUGEPAGE: ::c_int = 15;
586584
pub const MAP_HUGETLB: ::c_int = 0x040000;
587585

588586
pub const PTRACE_TRACEME: ::c_int = 0;

src/unix/notbsd/linux/musl/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,8 @@ pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
185185
pub const PTRACE_LISTEN: ::c_int = 0x4208;
186186
pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
187187

188-
pub const MADV_DODUMP: ::c_int = 17;
189-
pub const MADV_DONTDUMP: ::c_int = 16;
190-
191188
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
192189

193-
pub const MADV_HUGEPAGE: ::c_int = 14;
194-
pub const MADV_NOHUGEPAGE: ::c_int = 15;
195-
196190
pub const PTRACE_GETFPREGS: ::c_uint = 14;
197191
pub const PTRACE_SETFPREGS: ::c_uint = 15;
198192
pub const PTRACE_GETFPXREGS: ::c_uint = 18;

src/unix/notbsd/linux/other/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,8 @@ pub const PTRACE_INTERRUPT: ::c_uint = 0x4207;
410410
pub const PTRACE_LISTEN: ::c_uint = 0x4208;
411411
pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209;
412412

413-
pub const MADV_DODUMP: ::c_int = 17;
414-
pub const MADV_DONTDUMP: ::c_int = 16;
415-
416413
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
417414

418-
pub const MADV_HUGEPAGE: ::c_int = 14;
419-
pub const MADV_NOHUGEPAGE: ::c_int = 15;
420415
pub const MAP_HUGETLB: ::c_int = 0x040000;
421416

422417
pub const SEEK_DATA: ::c_int = 3;

src/unix/notbsd/linux/s390x.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,8 @@ pub const PTRACE_INTERRUPT: ::c_uint = 0x4207;
698698
pub const PTRACE_LISTEN: ::c_uint = 0x4208;
699699
pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209;
700700

701-
pub const MADV_DODUMP: ::c_int = 17;
702-
pub const MADV_DONTDUMP: ::c_int = 16;
703-
704701
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
705702

706-
pub const MADV_HUGEPAGE: ::c_int = 14;
707-
pub const MADV_NOHUGEPAGE: ::c_int = 15;
708703
pub const MAP_HUGETLB: ::c_int = 0x040000;
709704

710705
pub const EFD_NONBLOCK: ::c_int = 0x800;

src/unix/notbsd/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,18 @@ 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;
420+
pub const MADV_HUGEPAGE: ::c_int = 14;
421+
pub const MADV_NOHUGEPAGE: ::c_int = 15;
422+
pub const MADV_DONTDUMP: ::c_int = 16;
423+
pub const MADV_DODUMP: ::c_int = 17;
419424
pub const MADV_HWPOISON: ::c_int = 100;
425+
pub const MADV_SOFT_OFFLINE: ::c_int = 101;
420426

421427
pub const IFF_UP: ::c_int = 0x1;
422428
pub const IFF_BROADCAST: ::c_int = 0x2;

0 commit comments

Comments
 (0)