posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
POSIX_MAPPED_FILES

POSIX Mapped Files option group. More...

Macros

#define PROT_NONE   0x0
 Pages may not be accessed.
 
#define PROT_READ   0x1
 Pages may be read.
 
#define PROT_WRITE   0x2
 Pages may be written.
 
#define PROT_EXEC   0x4
 Pages may be executed.
 
#define MAP_SHARED   0x1
 Changes are shared between all mappings of the same object.
 
#define MAP_PRIVATE   0x2
 Changes are private (copy-on-write).
 
#define MAP_FIXED   0x4
 Map at the exact address given in addr.
 
#define MAP_ANONYMOUS   0x20
 Anonymous mapping; fd argument is ignored.
 
#define MS_SYNC   0x0
 Flush modified pages to the underlying file synchronously.
 
#define MS_ASYNC   0x1
 Schedule writes; return immediately.
 
#define MS_INVALIDATE   0x2
 Invalidate cached data so subsequent reads reflect the file.
 
#define MAP_FAILED   ((void *)-1)
 Value returned by mmap() on failure.
 

Functions

void * mmap (void *addr, size_t len, int prot, int flags, int fildes, off_t off)
 Map a file or device into memory.
 
int msync (void *addr, size_t length, int flags)
 Synchronise a memory mapping with the underlying storage.
 
int munmap (void *addr, size_t len)
 Unmap a previously mapped region.
 

Detailed Description

POSIX Mapped Files option group.

Macro Definition Documentation

◆ MAP_ANONYMOUS

#define MAP_ANONYMOUS   0x20

Anonymous mapping; fd argument is ignored.

Definition at line 41 of file mman.h.

◆ MAP_FAILED

#define MAP_FAILED   ((void *)-1)

Value returned by mmap() on failure.

Definition at line 51 of file mman.h.

◆ MAP_FIXED

#define MAP_FIXED   0x4

Map at the exact address given in addr.

Definition at line 38 of file mman.h.

◆ MAP_PRIVATE

#define MAP_PRIVATE   0x2

Changes are private (copy-on-write).

Definition at line 36 of file mman.h.

◆ MAP_SHARED

#define MAP_SHARED   0x1

Changes are shared between all mappings of the same object.

Definition at line 34 of file mman.h.

◆ MS_ASYNC

#define MS_ASYNC   0x1

Schedule writes; return immediately.

Definition at line 46 of file mman.h.

◆ MS_INVALIDATE

#define MS_INVALIDATE   0x2

Invalidate cached data so subsequent reads reflect the file.

Definition at line 48 of file mman.h.

◆ MS_SYNC

#define MS_SYNC   0x0

Flush modified pages to the underlying file synchronously.

Definition at line 44 of file mman.h.

◆ PROT_EXEC

#define PROT_EXEC   0x4

Pages may be executed.

Definition at line 31 of file mman.h.

◆ PROT_NONE

#define PROT_NONE   0x0

Pages may not be accessed.

Definition at line 25 of file mman.h.

◆ PROT_READ

#define PROT_READ   0x1

Pages may be read.

Definition at line 27 of file mman.h.

◆ PROT_WRITE

#define PROT_WRITE   0x2

Pages may be written.

Definition at line 29 of file mman.h.

Function Documentation

◆ mmap()

void * mmap ( void *  addr,
size_t  len,
int  prot,
int  flags,
int  fildes,
off_t  off 
)

Map a file or device into memory.

Parameters
addrSuggested address (hint), or NULL.
lenLength of the mapping in bytes.
protMemory protection (PROT_* flags).
flagsMapping type and options (MAP_* flags).
fildesFile descriptor (-1 for anonymous mappings).
offOffset within the file (must be page-aligned).
Returns
Base address of the mapping, or MAP_FAILED on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html

◆ msync()

int msync ( void *  addr,
size_t  length,
int  flags 
)

Synchronise a memory mapping with the underlying storage.

Parameters
addrBase address of the region (must be page-aligned).
lengthLength of the region in bytes.
flagsMS_SYNC, MS_ASYNC, or MS_INVALIDATE.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/msync.html

◆ munmap()

int munmap ( void *  addr,
size_t  len 
)

Unmap a previously mapped region.

Parameters
addrBase address of the mapping.
lenLength of the region in bytes.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/munmap.html