Memory management functions. Currently, only only MAP_ANONYMOUS is supported.
It is possible to request memory from a specific pool by supplying a file
descriptor to the appropriate /kfs/mem/bank*/ file.
mmap
Map a section of memory into the current process address space.
Syntax
#include <sys/mman.h>
void *mmap (void *addr, size_t length, int prot, int flags, int fd, off_t offset);
Parameters
-
addrThe offset of where to place the mapping. A value of zero means that the kernel is free to select the offset. Only a value of zero is currently allowed.
-
lengthThe length (size) of memory to allocate.
-
protMemory protection to apply. Must be a combination of
PROT_READandPROT_WRITE.PROT_EXECis not supported. -
flagsFlags describing the memory allocation. Must be
(MAP_PRIVATE | MAP_ANONYMOUS), since only "regular" memory allocation is supported. -
fdFile descriptor to map in. Currently only available for specifying the memory bank to allocate from, by giving a file descriptor for a file in
/kfs/mem/bank*.A value of zero means that the kernel is free to choose what memory pool to allocate from.
-
offsetOffset whithin the file. Must be zero.
Return Value
The return value is a pointer to the mapped memory if successful. Otherwise, the return value is null and errno is set:
-
EINVAL
Operation not supported. May be returned if there was an internal system call error or the API is not available because it has been disabled.
The length is zero.
Invalid or unknown flags.
Flags are not
(MAP_PRIVATE | MAP_ANONYMOUS)(unsupported). -
ENOTSUP
Non-null address is not supported.
Executable memory is not allowed.
-
ENOMEM
Out of memory.
Remarks
None
munmap
Un-map a section of memory.
Syntax
#include <sys/mman.h>
int munmap (void *addr, size_t length);
Parameters
-
addrThe offset/address of the memory to unmap.
-
lengthThe length (size) of memory to de-allocate.
Return Value
The return value is zero successful. Otherwise, the return value is negative and errno is set:
-
EINVAL
Operation not supported. May be returned if there was an internal system call error or the API is not available because it has been disabled.
The address is not valid.
Remarks
None