1.\" $NetBSD: mremap.2,v 1.4 2011/04/28 12:00:55 wiz Exp $ 2.\" 3.\" Copyright (c) 2007 Thomas Klausner and Joerg Sonnenberger 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND 16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE 19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" SUCH DAMAGE. 26.\" 27.\" ------------------------------------------------------------ 28.Dd February 14, 2008 29.Dt MREMAP 2 30.Os 31.Sh NAME 32.Nm mremap 33.Nd re-map a virtual memory address 34.\" ------------------------------------------------------------ 35.Sh LIBRARY 36.Lb libc 37.Sh SYNOPSIS 38.In sys/mman.h 39.Ft void * 40.Fn mremap "void *oldp" "size_t oldsize" "void *newp" "size_t newsize" \ 41"int flags" 42.\" ------------------------------------------------------------ 43.Sh DESCRIPTION 44The 45.Fn mremap 46function resizes the mapped range (see 47.Xr mmap 2 ) 48starting at 49.Ar oldp 50and having size 51.Ar oldsize 52to 53.Ar newsize . 54The following arguments can be 55.Dv OR Ap ed 56together in the 57.Ar flags 58argument: 59.Bl -tag -width XXMAPXALIGNEDXnXX 60.It Dv MAP_ALIGNED Ns Pq Ar n 61The allocation should be aligned to the given boundary, i.e. ensure 62that the lowest 63.Ar n 64bits of the address are zero. 65The parameter 66.Ar n 67should be the base 2 logarithm of the desired alignment (e.g., to 68request alignment to 16K, use 14 as the value for n). 69The alignment must be equal to or greater than the platform's page 70size as returned by 71.Xr sysconf 3 72with the 73.Dv _SC_PAGESIZE 74request. 75.It Dv MAP_FIXED 76.Ar newp 77is tried and 78.Fn mremap 79fails if that address can't be used as new base address for the range. 80Otherwise, 81.Ar oldp 82and 83.Ar newp 84are used as hints for the position, factoring in the given alignment. 85.El 86.Sh RETURN VALUES 87.Fn mremap 88returns the new address or 89.Dv MAP_FAILED , 90if the remap failed. 91.Sh COMPATIBILITY 92The semantics of 93.Fn mremap 94differ from the one provided by glibc on Linux in that the 95.Ar newp 96argument was added and a different set of 97.Ar flags 98are implemented. 99.Sh SEE ALSO 100.Xr mmap 2 , 101.Xr munmap 2 102.Sh HISTORY 103The 104.Fn mremap 105system call appeared in 106.Nx 5.0 . 107It was based on the code that supports 108.Fn mremap 109compatibility for Linux binaries. 110