| 1 |
//! Header: `sys/mman.h` |
| 2 |
//! |
| 3 |
//! Memory mapping functions and constants from Hexagon toolchain. |
| 4 |
|
| 5 |
use super::super::*; |
| 6 |
use crate::prelude::*; |
| 7 |
|
| 8 |
// Memory protection constants |
| 9 |
pub const PROT_NONE: c_int = 0x00; |
| 10 |
pub const PROT_READ: c_int = 0x01; |
| 11 |
pub const PROT_WRITE: c_int = 0x02; |
| 12 |
pub const PROT_EXEC: c_int = 0x04; |
| 13 |
|
| 14 |
// Memory mapping constants |
| 15 |
pub const MAP_SHARED: c_int = 0x0001; |
| 16 |
pub const MAP_PRIVATE: c_int = 0x0002; |
| 17 |
pub const MAP_FIXED: c_int = 0x0010; |
| 18 |
pub const MAP_ANON: c_int = 0x1000; |
| 19 |
pub const MAP_ANONYMOUS: c_int = MAP_ANON; |
| 20 |
pub const MAP_FILE: c_int = 0x0000; |
| 21 |
pub const MAP_RENAME: c_int = 0x0020; |
| 22 |
pub const MAP_NORESERVE: c_int = 0x0040; |
| 23 |
pub const MAP_INHERIT: c_int = 0x0080; |
| 24 |
pub const MAP_HASSEMAPHORE: c_int = 0x0200; |
| 25 |
pub const MAP_TRYFIXED: c_int = 0x0400; |
| 26 |
pub const MAP_WIRED: c_int = 0x0800; |
| 27 |
|
| 28 |
pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; |
| 29 |
|
| 30 |
// Memory sync constants |
| 31 |
pub const MS_ASYNC: c_int = 0x01; |
| 32 |
pub const MS_INVALIDATE: c_int = 0x02; |
| 33 |
pub const MS_SYNC: c_int = 0x04; |
| 34 |
|
| 35 |
// Memory lock constants |
| 36 |
pub const MCL_CURRENT: c_int = 0x01; |
| 37 |
pub const MCL_FUTURE: c_int = 0x02; |
| 38 |
|
| 39 |
extern "C" { |
| 40 |
pub fn mmap( |
| 41 |
addr: *mut c_void, |
| 42 |
len: size_t, |
| 43 |
prot: c_int, |
| 44 |
flags: c_int, |
| 45 |
fd: c_int, |
| 46 |
offset: off_t, |
| 47 |
) -> *mut c_void; |
| 48 |
pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; |
| 49 |
pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; |
| 50 |
pub fn mlock(addr: *const c_void, len: size_t) -> c_int; |
| 51 |
pub fn munlock(addr: *const c_void, len: size_t) -> c_int; |
| 52 |
pub fn mlockall(flags: c_int) -> c_int; |
| 53 |
pub fn munlockall() -> c_int; |
| 54 |
pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; |
| 55 |
} |