Module sys/mmap

sys/mmap

Memory-mapped I/O operations.

Synchronous wrappers for mmap/munmap/mprotect/msync.

mmap returns:

  • Mapped pointer on success
  • Encoded error pointer on failure (negative errno cast to pointer)

Functions

mmap function
fn(addr : Option(*(u8)), length : usize, prot : i32, flags : i32, fd : i32, offset : i64) -> Option(*(u8))

Parameters

NameTypeNotes
addrOption(*(u8))
lengthusize
proti32
flagsi32
fdi32
offseti64

Returns: Option(*(u8))

is_error function
fn(addr : Option(*(u8))) -> bool

Parameters

NameTypeNotes
addrOption(*(u8))

Returns: bool

error_code function
fn(addr : Option(*(u8))) -> i32

Parameters

NameTypeNotes
addrOption(*(u8))

Returns: i32

munmap function
fn(addr : *(u8), length : usize) -> i32

Parameters

NameTypeNotes
addr*(u8)
lengthusize

Returns: i32

mprotect function
fn(addr : *(u8), length : usize, prot : i32) -> i32

Parameters

NameTypeNotes
addr*(u8)
lengthusize
proti32

Returns: i32

msync function
fn(addr : *(u8), length : usize, flags : i32) -> i32

Parameters

NameTypeNotes
addr*(u8)
lengthusize
flagsi32

Returns: i32

Constants

PROT_NONE constant i32

Value: 0

PROT_READ constant i32

Value: 1

PROT_WRITE constant i32

Value: 2

PROT_EXEC constant i32

Value: 4

MAP_SHARED constant i32

Value: 1

MAP_PRIVATE constant i32

Value: 2

MAP_ANONYMOUS constant i32

Value: 32

MS_ASYNC constant i32

Value: 1

MS_INVALIDATE constant i32

Value: 2

MS_SYNC constant i32

Value: 4