HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)
m
mmap(2) mmap(2)
HP-UX EXTENSIONS
NAME
mmap - map pages of memory
SYNOPSIS
#include <sys/mman.h>
caddr_t mmap(
caddr_t addr,
size_t len,
int prot,
int flags,
int fildes,
off_t off);
DESCRIPTION
MAP_FILE Create a mapped file region.
MAP_ANONYMOUS Create an unnamed memory region.
MAP_VARIABLE Place region at implementation-computed address.
MAP_NORESERVE Lazily evaluate swap space reservation.
MAP_LOCAL Allocate physical memory from the current locality domain.
MAP_IO Create a virtual mapping for a physical I/O address range.
The MAP_FILE, MAP_ANONYMOUS
, and MAP_IO flags control whether the region to be mapped is a
mapped file region, an anonymous shared memory region, or a region representing I/O device memory.
Exactly one of these flags must be selected.
If
MAP_FILE is set in flags:
• A new mapped file region is created, mapping the file associated with fildes.
• off specifies the file byte offset at which the mapping starts. This offset must be a multiple of the
page size returned by
sysconf(_SC_PAGE_SIZE)
.
• If the end of the mapped file region is beyond the end of the file, any reference to an address in
the mapped file region corresponding to an offset beyond the end of the file results in the delivery
of a
SIGBUS signal to the process, unless the address lies in the last partial page corresponding
to the range beyond the end of the file. The last partial page mapping the range beyond the end
of the file is always initialized to zeros, and any modified portions of the last page of a file which
are beyond its end are not written back to the file.
If MAP_ANONYMOUS is set in flags:
• A new memory region is created and initialized to all zeros. This memory region can be shared
only with descendants of the current process.
• If the fildes argument is not −1, an [EINVAL] error is generated. This is not enforced in the
current release, but will be enforced in the next release.
• The value of off is meaningless because there is no underlying file object for the memory region.
The
MAP_VARIABLE and MAP_FIXED flags control the placement of the region as described below.
Exactly one of these flags must be selected.
If MAP_VARIABLE is set in flags:
• If the requested address is NULL, or if it is not possible for the system to place the region at the
requested address, the region is placed at an address selected by the system. If the requested
address is not a multiple of the page size returned by sysconf(_SC_PAGE_SIZE), the sys-
tem treats the address as if it were rounded up to the next larger page size multiple.
If
MAP_FIXED is set in flags:
Section 2−−156 Hewlett-Packard Company − 1 − HP-UX 11i Version 1: September 2005