summaryrefslogtreecommitdiffstats
path: root/man3p/munmap.3p
blob: d8a1d905c70690b95477079e6e8a67ec1d121236 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "MUNMAP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" munmap 
.SH NAME
munmap \- unmap pages of memory
.SH SYNOPSIS
.LP
\fB#include <sys/mman.h>
.br
.sp
int munmap(void *\fP\fIaddr\fP\fB, size_t\fP \fIlen\fP\fB); \fP
\fB
.br
\fP
.SH DESCRIPTION
.LP
The \fImunmap\fP() function shall remove any mappings for those entire
pages containing any part of the address space of the
process starting at \fIaddr\fP and continuing for \fIlen\fP bytes.
Further references to these pages shall result in the
generation of a SIGSEGV signal to the process. If there are no mappings
in the specified address range, then \fImunmap\fP() has no
effect.
.LP
The implementation shall require that \fIaddr\fP be a multiple of
the page size {PAGESIZE}.
.LP
If a mapping to be removed was private, any modifications made in
this address range shall be discarded.
.LP
Any memory locks (see \fImlock\fP() and \fImlockall\fP() ) associated
with
this address range shall be removed, as if by an appropriate call
to \fImunlock\fP(). 
.LP
If a mapping removed from a typed memory object causes the corresponding
address range of the memory pool to be inaccessible by any
process in the system except through allocatable mappings (that is,
mappings of typed memory objects opened with the
POSIX_TYPED_MEM_MAP_ALLOCATABLE flag), then that range of the memory
pool shall become deallocated and may become available to
satisfy future typed memory allocation requests.
.LP
A mapping removed from a typed memory object opened with the POSIX_TYPED_MEM_MAP_ALLOCATABLE
flag shall not affect in any way
the availability of that typed memory for allocation. 
.LP
The behavior of this function is unspecified if the mapping was not
established by a call to \fImmap\fP().
.SH RETURN VALUE
.LP
Upon successful completion, \fImunmap\fP() shall return 0; otherwise,
it shall return -1 and set \fIerrno\fP to indicate the
error.
.SH ERRORS
.LP
The \fImunmap\fP() function shall fail if:
.TP 7
.B EINVAL
Addresses in the range [\fIaddr\fP,\fIaddr\fP+\fIlen\fP) are outside
the valid range for the address space of a
process.
.TP 7
.B EINVAL
The \fIlen\fP argument is 0.
.TP 7
.B EINVAL
The \fIaddr\fP argument is not a multiple of the page size as returned
by \fIsysconf\fP().
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
The \fImunmap\fP() function is only supported if the Memory Mapped
Files option or the Shared Memory Objects option is
supported.
.SH RATIONALE
.LP
The \fImunmap\fP() function corresponds to SVR4, just as the \fImmap\fP()
function
does.
.LP
It is possible that an application has applied process memory locking
to a region that contains shared memory. If this has
occurred, the \fImunmap\fP() call ignores those locks and, if necessary,
causes those locks to be removed.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fImlock\fP() , \fImlockall\fP() , \fImmap\fP()
, \fIposix_typed_mem_open\fP() , \fIsysconf\fP() , the Base
Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<signal.h>\fP, \fI<sys/mman.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .