HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)
__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
m
mmap(2) mmap(2)
[EINVAL] The mapping already exists in 64-bit address space, but the application performing the
current mmap() request has been compiled as a 32-bit executable.
[EINVAL] The mapping already exists in 32-bit address space, but the application performing the
current mmap() request has been compiled as a 64-bit executable and did not specify
MAP_ADDR32 in the flags argument.
[EMFILE] The number of mapped regions would exceed an implementation-dependent limit (per
process or per system).
[ENODEV] The fildes argument refers to a file whose type is not supported by mmap().
[ENOMEM] MAP_FIXED was specified, and the range [addr, addr+len] exceeds that allowed for
the address space of a process; or if MAP_FIXED was not specified and there is
insufficient room in the address space to effect the mapping.
APPLICATION USAGE
Use of mmap() may reduce the amount of memory available to other memory allocation functions.
Use of MAP_FIXED may result in unspecified behavior in further use of brk(), sbrk(), malloc(),
and shmat(). The use of MAP_FIXED is discouraged, as it may prevent an implementation from making
the most effective use of resources.
The application must ensure correct synchronization when using
mmap() in conjunction with any other file
access method, such as
read() and write(), standard input/output, and
shmat().
The
mmap() function allows access to resources via address space manipulations, instead of
read()/write(). Once a file is mapped, all a process has to do to access it is use the data at the
address to which the file was mapped. So, using pseudo-code to illustrate the way in which an existing pro-
gram might be changed to use mmap(), the following:
fildes = open(...)
lseek(fildes, some_offset)
read(fildes, buf, len)
/* use data in buf */
becomes:
fildes = open(...)
address = mmap(0, len, PROT_READ, MAP_PRIVATE, fildes, some_offset)
/* use data at address */
SEE ALSO
exec(2), fcntl(2), fork(2), lockf(2), msync(2), munmap(2), mprotect(2), shmop(2), sysconf(2).
HP-UX Release 11i: December 2000 − 3 − Section 2−−151
___
___