From d573a99525642d32c6f5b389b4deb92026d1720c Mon Sep 17 00:00:00 2001 From: Xavier L'Heureux Date: Fri, 15 May 2020 17:31:41 -0400 Subject: [PATCH] Add extra functions & constants from sys/mman.h for Redox --- src/unix/redox/mod.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 7f66f1b4..7b4b0217 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -587,6 +587,23 @@ pub const TIOCSPGRP: ::c_ulong = 0x5410; pub const TIOCGWINSZ: ::c_ulong = 0x5413; pub const TIOCSWINSZ: ::c_ulong = 0x5414; +// sys/mman.h +pub const PROT_NONE: ::c_int = 0x0000; +pub const PROT_READ: ::c_int = 0x0004; +pub const PROT_WRITE: ::c_int = 0x0002; +pub const PROT_EXEC: ::c_int = 0x0001; + +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; +pub const MAP_FIXED: ::c_int = 0x0010; +pub const MAP_FAILED: *mut ::c_void = !0 as _; + +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MS_SYNC: ::c_int = 0x0004; + // sys/select.h pub const FD_SETSIZE: usize = 1024; @@ -934,6 +951,24 @@ extern "C" { // sys/ioctl.h pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + // sys/mman.h + pub fn msync( + addr: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn mprotect( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn shm_open( + name: *const c_char, + oflag: ::c_int, + mode: mode_t, + ) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + // sys/resource.h pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;