munmap_flags()

Unmap previously mapped addresses, exercising more control than possible with munmap()

Synopsis:

#include <sys/mman.h>

int munmap_flags( void * addr,
                  size_t len,
                  unsigned flags );

Arguments:

addr
The beginning of the range of addresses that you want to unmap.
len
The length of the range of addresses, in bytes.
flags
0, or a combination of the following bits:
  • UNMAP_INT_REQUIRED
  • UNMAP_INT_OPTIONAL
  • UNMAP_CLEAN
  • UNMAP_NOCLEAN

For more information, see below.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The munmap_flags() function removes any mappings for pages in the address range starting at addr and continuing for len bytes, rounded up to the next multiple of the page size. Subsequent references to these pages cause a SIGSEGV signal to be set on the process.

If there are no mappings in the specified address range, then munmap_flags() has no effect.

If you specify 0 for the flags, munmap_flags() is the same as munmap() . The flags change the way munmap_flags() behaves, as follows:

UNMAP_INT_REQUIRED
POSIX initialization of the page to all zeros is required the next time the underlying physical memory is allocated.
UNMAP_INT_OPTIONAL
Initialization of the underlying physical memory to zeros on its next allocation is optional. If you specify this flag, and you specify MAP_NOINIT when you next call mmap() for this physical memory, the POSIX requirement that the memory be zeroed is relaxed.
UNMAP_CLEAN
Clean the memory region when the unmapping is done, if possible (it isn't cleaned if there are still other references to it, for example if it's a shared memory region and there are still other processes referencing it).
UNMAP_NOCLEAN
Don't clean the memory on unmapping, even if clean-on-unmapping is the default behavior. Instead, the cleaning is done the next time the memory pages are allocated to another process. This is the default behavior if you haven't specified the -mc option for procnto .

The memory-manager configuration (-m) option for procnto affects the default behavior of munmap_flags() (unless overridden by the flags argument), as detailed below:

-mi
Act as if UNMAP_INIT_REQUIRED were specified (the default).
-m~i
Act as if UNMAP_INIT_OPTIONAL were specified.
-mc
Act as if UNMAP_CLEAN were specified.
-m~c
Act as if UNMAP_NOCLEAN were specified.

Returns:

0
Success.
-1
Failure; errno is set.

Errors:

EINVAL
The addresses in the specified range are outside the range allowed for the address space of a process.
ENOSYS
The function munmap_flags() isn't supported by this implementation.

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

Last modified: 2013-12-23

comments powered by Disqus