1MUNMAP(P) POSIX Programmer's Manual MUNMAP(P)
2
3
4
6 munmap - unmap pages of memory
7
9 #include <sys/mman.h>
10
11 int munmap(void *addr, size_t len);
12
13
15 The munmap() function shall remove any mappings for those entire pages
16 containing any part of the address space of the process starting at
17 addr and continuing for len bytes. Further references to these pages
18 shall result in the generation of a SIGSEGV signal to the process. If
19 there are no mappings in the specified address range, then munmap() has
20 no effect.
21
22 The implementation shall require that addr be a multiple of the page
23 size {PAGESIZE}.
24
25 If a mapping to be removed was private, any modifications made in this
26 address range shall be discarded.
27
28 Any memory locks (see mlock() and mlockall() ) associated with this
29 address range shall be removed, as if by an appropriate call to
30 munlock().
31
32 If a mapping removed from a typed memory object causes the correspond‐
33 ing address range of the memory pool to be inaccessible by any process
34 in the system except through allocatable mappings (that is, mappings of
35 typed memory objects opened with the POSIX_TYPED_MEM_MAP_ALLOCATABLE
36 flag), then that range of the memory pool shall become deallocated and
37 may become available to satisfy future typed memory allocation
38 requests.
39
40 A mapping removed from a typed memory object opened with the
41 POSIX_TYPED_MEM_MAP_ALLOCATABLE flag shall not affect in any way the
42 availability of that typed memory for allocation.
43
44 The behavior of this function is unspecified if the mapping was not
45 established by a call to mmap().
46
48 Upon successful completion, munmap() shall return 0; otherwise, it
49 shall return -1 and set errno to indicate the error.
50
52 The munmap() function shall fail if:
53
54 EINVAL Addresses in the range [addr,addr+len) are outside the valid
55 range for the address space of a process.
56
57 EINVAL The len argument is 0.
58
59 EINVAL The addr argument is not a multiple of the page size as returned
60 by sysconf().
61
62
63 The following sections are informative.
64
66 None.
67
69 The munmap() function is only supported if the Memory Mapped Files
70 option or the Shared Memory Objects option is supported.
71
73 The munmap() function corresponds to SVR4, just as the mmap() function
74 does.
75
76 It is possible that an application has applied process memory locking
77 to a region that contains shared memory. If this has occurred, the mun‐
78 map() call ignores those locks and, if necessary, causes those locks to
79 be removed.
80
82 None.
83
85 mlock() , mlockall() , mmap() , posix_typed_mem_open() , sysconf() ,
86 the Base Definitions volume of IEEE Std 1003.1-2001, <signal.h>,
87 <sys/mman.h>
88
90 Portions of this text are reprinted and reproduced in electronic form
91 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
92 -- Portable Operating System Interface (POSIX), The Open Group Base
93 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
94 Electrical and Electronics Engineers, Inc and The Open Group. In the
95 event of any discrepancy between this version and the original IEEE and
96 The Open Group Standard, the original IEEE and The Open Group Standard
97 is the referee document. The original Standard can be obtained online
98 at http://www.opengroup.org/unix/online.html .
99
100
101
102IEEE/The Open Group 2003 MUNMAP(P)