Manual Pages for UNIX Darwin command on man mmap
MyWebUniversity

Manual Pages for UNIX Darwin command on man mmap

MMAP(2) BSD System Calls Manual MMAP(2)

NAME

mmmmaapp - map files or devices into memory

SYNOPSIS

##iinncclluuddee <>

void * mmmmaapp(void *addr, sizet len, int prot, int flags, int fildes, offt offset);

DESCRIPTION

The mmmmaapp function causes the pages starting at addr and continuing for at most len bytes to be mapped from the object described by fildes, starting

at byte offset offset. If offset or len is not a multiple of the page-

size, the mapped region may extend past the specified range.

If addr is non-zero, it is used as a hint to the system. (As a conve-

nience to the system, the actual address of the region may differ from the address supplied.) If addr is zero, an address will be selected by the system. The actual starting address of the region is returned. A

successful mmap deletes any previous mapping in the allocated address

range. The protections (region accessibility) are specified in the prot argument by or'ing the following values: PROTEXEC Pages may be executed. PROTREAD Pages may be read. PROTWRITE Pages may be written. The flags parameter specifies the type of the mapped object, mapping options, and whether modifications made to the mapped copy of the page

are private to the process (copy-on-write) or are to be shared with other

references. Sharing, mapping type, and options are specified in the flags argument by or'ing the following values: MAPANON Map anonymous memory not associated with any specific file. Mac OS X specific: the file descriptor used for creating MAPANON regions can be used to pass some

Mach VM flags, and can be specified as -1 if no such

flags are associated with the region. Mach VM flags are defined in and the ones that currently apply to mmmmaapp are: VMFLAGSPURGABLE to create Mach purgable (i.e. volatile) memory VMMAKETAG(tag) to associate an

8-bit tag with the region

defines some preset tags (with a VMMEMORY prefix). Users are encouraged to use tags between 240 and 255. Tags are used by tools such

as vmmap(1) to help identify specific memory regions.

MAPFILE Mapped from a regular file or character-special device

memory. (This is the default mapping type, and need not be specified.) MAPFIXED Do not permit the system to select a different address

than the one specified. If the specified address can-

not be used, mmmmaapp will fail. If MAPFIXED is speci-

fied, addr must be a multiple of the pagesize. Use of this option is discouraged.

MAPHASSEMAPHORE Notify the kernel that the region may contain sema-

phores and that special handling may be necessary.

MAPPRIVATE Modifications are private (copy-on-write).

MAPSHARED Modifications are shared. MAPNOCACHE Pages in this mapping are not retained in the kernel's memory cache. If the system runs low on memory, pages in MAPNOCACHE mappings will be among the first to be reclaimed. This flag is intended for mappings that have little locality and provides a hint to the kernel that pages in this mapping are unlikely to be needed again in the near future. Conforming applications must specify either MAPPRIVATE or MAPSHARED. The close(2) function does not unmap pages, see munmap(2) for further information. The current design does not allow a process to specify the location of swap space. In the future we may define an additional mapping type, MAPSWAP, in which the file descriptor argument specifies a file or device to which swapping should be done.

RETURN VALUES

Upon successful completion, mmmmaapp returns a pointer to the mapped region.

Otherwise, a value of -1 is returned and errno is set to indicate the

error. EERRRROORRSS MMmmaapp() will fail if: [EACCES] Fildes is not open for reading. [EACCES] The flags PROTWRITE and MAPSHARED are specified as part of the flags and prot parameters and fildes is not open for writing. [EBADF] fildes is not a valid file descriptor for an open file. [EINVAL] MAPFIXED is specified and the parameter is not page aligned.

[EINVAL] fildes does not reference a regular or character spe-

cial file. [EINVAL] flags does not include either MAPPRIVATE or MAPSHARED. [EINVAL] len is not greater than zero. [EINVAL] offset is not a multiple of the page size, as returned by sysconf(3). [EMFILE] The limit on mapped regions (per process or system) is exceeded. [ENODEV] The file type for fildes is not supported for mapping. [ENOMEM] MAPFIXED is specified and the address range specified exceeds the address space limit for the process. [ENOMEM] MAPFIXED is specified and the address specified by the addr parameter isn't available. [ENOMEM] MAPANON is specified and insufficient memory is available. [ENXIO] Addresses in the specified range are invalid for fildes. [EOVERFLOW] Addresses in the specified range exceed the maximum offset set for fildes.

LEGACY SYNOPSIS

##iinncclluuddee <>

##iinncclluuddee <>

The include file is necessary. CCOOMMPPAATTIIBBIILLIITTYY mmmmaapp() now returns with errno set to EINVAL in places that historically succeeded. The rules have changed as follows: ++oo The flags parameter must specify either MAPPRIVATE or MAPSHARED. ++oo The size parameter must not be 0. ++oo The off parameter must be a multiple of pagesize, as returned by ssyyssccoonnff().

SEE ALSO

getpagesize(2), madvise(2), mincore(2), mlock(2), mprotect(2), msync(2), munmap(2), sysconf(3), compat(5) 4th Berkeley Distribution June 4, 1993 4th Berkeley Distribution




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™