From e197968734b2a0c1dd77034611361a121ecfc5ab Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 7 Jul 2019 14:31:27 +1000 Subject: [PATCH] std: Make linux MAP_ definitions match kernel --- std/os/bits/linux.zig | 31 ++++++++++++++++++++----------- std/os/bits/linux/arm64.zig | 30 ++++++++++++++++++++++++++++++ std/os/bits/linux/x86_64.zig | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 11 deletions(-) diff --git a/std/os/bits/linux.zig b/std/os/bits/linux.zig index 40d142c9ba..ee6305f91b 100644 --- a/std/os/bits/linux.zig +++ b/std/os/bits/linux.zig @@ -74,22 +74,31 @@ pub const PROT_EXEC = 4; pub const PROT_GROWSDOWN = 0x01000000; pub const PROT_GROWSUP = 0x02000000; -pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); +/// Share changes pub const MAP_SHARED = 0x01; + +/// Changes are private pub const MAP_PRIVATE = 0x02; + +/// share + validate extension flags +pub const MAP_SHARED_VALIDATE = 0x03; + +/// Mask for type of mapping pub const MAP_TYPE = 0x0f; + +/// Interpret addr exactly pub const MAP_FIXED = 0x10; + +/// don't use a file pub const MAP_ANONYMOUS = 0x20; -pub const MAP_NORESERVE = 0x4000; -pub const MAP_GROWSDOWN = 0x0100; -pub const MAP_DENYWRITE = 0x0800; -pub const MAP_EXECUTABLE = 0x1000; -pub const MAP_LOCKED = 0x2000; -pub const MAP_POPULATE = 0x8000; -pub const MAP_NONBLOCK = 0x10000; -pub const MAP_STACK = 0x20000; -pub const MAP_HUGETLB = 0x40000; -pub const MAP_FILE = 0; + +/// For anonymous mmap, memory could be uninitialized +pub const MAP_UNINITIALIZED = 0x4000000; + +// MAP_ 0x0100 - 0x80000 flags are per architecture + +/// MAP_FIXED which doesn't unmap underlying mapping +pub const MAP_FIXED_NOREPLACE = 0x100000; pub const F_OK = 0; pub const X_OK = 1; diff --git a/std/os/bits/linux/arm64.zig b/std/os/bits/linux/arm64.zig index 269a34a5ab..9547feb6ee 100644 --- a/std/os/bits/linux/arm64.zig +++ b/std/os/bits/linux/arm64.zig @@ -331,6 +331,36 @@ pub const F_GETOWN_EX = 16; pub const F_GETOWNER_UIDS = 17; +/// stack-like segment +pub const MAP_GROWSDOWN = 0x0100; + +/// ETXTBSY +pub const MAP_DENYWRITE = 0x0800; + +/// mark it as an executable +pub const MAP_EXECUTABLE = 0x1000; + +/// pages are locked +pub const MAP_LOCKED = 0x2000; + +/// don't check for reservations +pub const MAP_NORESERVE = 0x4000; + +/// populate (prefault) pagetables +pub const MAP_POPULATE = 0x8000; + +/// do not block on IO +pub const MAP_NONBLOCK = 0x10000; + +/// give out an address that is best suited for process/thread stacks +pub const MAP_STACK = 0x20000; + +/// create a huge page mapping +pub const MAP_HUGETLB = 0x40000; + +/// perform synchronous page faults for the mapping +pub const MAP_SYNC = 0x80000; + pub const VDSO_USEFUL = true; pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; pub const VDSO_CGT_VER = "LINUX_2.6.39"; diff --git a/std/os/bits/linux/x86_64.zig b/std/os/bits/linux/x86_64.zig index e7124ca99e..39ad760078 100644 --- a/std/os/bits/linux/x86_64.zig +++ b/std/os/bits/linux/x86_64.zig @@ -394,6 +394,39 @@ pub const F_GETOWN_EX = 16; pub const F_GETOWNER_UIDS = 17; +/// only give out 32bit addresses +pub const MAP_32BIT = 0x40; + +/// stack-like segment +pub const MAP_GROWSDOWN = 0x0100; + +/// ETXTBSY +pub const MAP_DENYWRITE = 0x0800; + +/// mark it as an executable +pub const MAP_EXECUTABLE = 0x1000; + +/// pages are locked +pub const MAP_LOCKED = 0x2000; + +/// don't check for reservations +pub const MAP_NORESERVE = 0x4000; + +/// populate (prefault) pagetables +pub const MAP_POPULATE = 0x8000; + +/// do not block on IO +pub const MAP_NONBLOCK = 0x10000; + +/// give out an address that is best suited for process/thread stacks +pub const MAP_STACK = 0x20000; + +/// create a huge page mapping +pub const MAP_HUGETLB = 0x40000; + +/// perform synchronous page faults for the mapping +pub const MAP_SYNC = 0x80000; + pub const VDSO_USEFUL = true; pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; pub const VDSO_CGT_VER = "LINUX_2.6";