Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/munmap.html
2024-02-19 00:21:47 -05:00

209 lines
7.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>munmap</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="munmap"></a> <a name="tag_03_400"></a><!-- munmap -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_03_400_01"></a>NAME</h4>
<blockquote>munmap - unmap pages of memory</blockquote>
<h4><a name="tag_03_400_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<div class="box"><code><tt><sup>[<a href="javascript:open_code('MF')">MF|SHM</a>]</sup> <img src="../images/opt-start.gif" alt=
"[Option Start]" border="0"> #include &lt;<a href="../basedefs/sys/mman.h.html">sys/mman.h</a>&gt;<br>
<br>
int munmap(void *</tt><i>addr</i><tt>, size_t</tt> <i>len</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border=
"0"></tt></code></div>
<tt><br>
</tt></blockquote>
<h4><a name="tag_03_400_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>munmap</i>() function shall remove any mappings for those entire pages containing any part of the address space of the
process starting at <i>addr</i> and continuing for <i>len</i> 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 <i>munmap</i>() has no
effect.</p>
<p>The implementation shall require that <i>addr</i> be a multiple of the page size {PAGESIZE}.</p>
<p>If a mapping to be removed was private, any modifications made in this address range shall be discarded.</p>
<p><sup>[<a href="javascript:open_code('ML')">ML|MLR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Any memory locks (see <a href="mlock.html"><i>mlock</i>()</a> and <a href="mlockall.html"><i>mlockall</i>()</a> ) associated with
this address range shall be removed, as if by an appropriate call to <a href="../functions/munlock.html"><i>munlock</i>()</a>. <img
src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
<p><sup>[<a href="javascript:open_code('TYM')">TYM</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
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.</p>
<p>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. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
<p>The behavior of this function is unspecified if the mapping was not established by a call to <a href=
"../functions/mmap.html"><i>mmap</i>()</a>.</p>
</blockquote>
<h4><a name="tag_03_400_04"></a>RETURN VALUE</h4>
<blockquote>
<p>Upon successful completion, <i>munmap</i>() shall return 0; otherwise, it shall return -1 and set <i>errno</i> to indicate the
error.</p>
</blockquote>
<h4><a name="tag_03_400_05"></a>ERRORS</h4>
<blockquote>
<p>The <i>munmap</i>() function shall fail if:</p>
<dl compact>
<dt>[EINVAL]</dt>
<dd>Addresses in the range [<i>addr</i>,<i>addr</i>+<i>len</i>) are outside the valid range for the address space of a
process.</dd>
<dt>[EINVAL]</dt>
<dd>The <i>len</i> argument is 0.</dd>
<dt>[EINVAL]</dt>
<dd>The <i>addr</i> argument is not a multiple of the page size as returned by <a href=
"../functions/sysconf.html"><i>sysconf</i>()</a>.</dd>
</dl>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_03_400_06"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_400_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>The <i>munmap</i>() function is only supported if the Memory Mapped Files option or the Shared Memory Objects option is
supported.</p>
</blockquote>
<h4><a name="tag_03_400_08"></a>RATIONALE</h4>
<blockquote>
<p>The <i>munmap</i>() function corresponds to SVR4, just as the <a href="../functions/mmap.html"><i>mmap</i>()</a> function
does.</p>
<p>It is possible that an application has applied process memory locking to a region that contains shared memory. If this has
occurred, the <i>munmap</i>() call ignores those locks and, if necessary, causes those locks to be removed.</p>
</blockquote>
<h4><a name="tag_03_400_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_400_10"></a>SEE ALSO</h4>
<blockquote>
<p><a href="mlock.html"><i>mlock</i>()</a> , <a href="mlockall.html"><i>mlockall</i>()</a> , <a href="mmap.html"><i>mmap</i>()</a>
, <a href="posix_typed_mem_open.html"><i>posix_typed_mem_open</i>()</a> , <a href="sysconf.html"><i>sysconf</i>()</a> , the Base
Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/signal.h.html"><i>&lt;signal.h&gt;</i></a>, <a href=
"../basedefs/sys/mman.h.html"><i>&lt;sys/mman.h&gt;</i></a></p>
</blockquote>
<h4><a name="tag_03_400_11"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 4, Version 2.</p>
</blockquote>
<h4><a name="tag_03_400_12"></a>Issue 5</h4>
<blockquote>
<p>Moved from X/OPEN UNIX extension to BASE.</p>
<p>Aligned with <i>munmap</i>() in the POSIX Realtime Extension as follows:</p>
<ul>
<li>
<p>The DESCRIPTION is extensively reworded.</p>
</li>
<li>
<p>The SIGBUS error is no longer permitted to be generated.</p>
</li>
</ul>
</blockquote>
<h4><a name="tag_03_400_13"></a>Issue 6</h4>
<blockquote>
<p>The <i>munmap</i>() function is marked as part of the Memory Mapped Files and Shared Memory Objects option.</p>
<p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
<ul>
<li>
<p>The DESCRIPTION is updated to state that implementations require <i>addr</i> to be a multiple of the page size.</p>
</li>
<li>
<p>The [EINVAL] error conditions are added.</p>
</li>
</ul>
<p>The following changes are made for alignment with IEEE&nbsp;Std&nbsp;1003.1j-2000:</p>
<ul>
<li>
<p>Semantics for typed memory objects are added to the DESCRIPTION.</p>
</li>
<li>
<p>The <a href="../functions/posix_typed_mem_open.html"><i>posix_typed_mem_open</i>()</a> function is added to the SEE ALSO
section.</p>
</li>
</ul>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>