mmap.2: Some 'flags' values require a feature test macro to be defined

Add text to NOTES noting that some MAP_* constants are
defined only if a suitable feature test macro is defined.
See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=542601

Reported-by: Török Edwin <edwintorok@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2013-02-12 21:38:36 +01:00
parent 0c56d91757
commit 45e97e2ac5
1 changed files with 33 additions and 1 deletions

View File

@ -37,7 +37,7 @@
.\" 2007-07-10, mtk, Added an example program.
.\" 2008-11-18, mtk, document MAP_STACK
.\"
.TH MMAP 2 2012-04-16 "Linux" "Linux Programmer's Manual"
.TH MMAP 2 2013-02-13 "Linux" "Linux Programmer's Manual"
.SH NAME
mmap, munmap \- map or unmap files or devices into memory
.SH SYNOPSIS
@ -49,6 +49,8 @@ mmap, munmap \- map or unmap files or devices into memory
.BI " int " fd ", off_t " offset );
.BI "int munmap(void *" addr ", size_t " length );
.fi
See NOTES for information on feature test macro requirements.
.SH DESCRIPTION
.BR mmap ()
creates a new mapping in the virtual address space of
@ -541,6 +543,36 @@ If the
flag is specified, and
.I addr
is 0 (NULL), then the mapped address will be 0 (NULL).
Certain
.I flags
constants are defined only if either
.BR _BSD_SOURCE
or
.BR _SVID_SOURCE
is defined.
(Requiring
.BR _GNU_SOURCE
also suffices,
and requiring that macro specifically would have been more logical,
since these flags are all Linux specific.)
The relevant flags are:
.BR MAP_32BIT ,
.BR MAP_ANONYMOUS
(and the synonym
.BR MAP_ANON ),
.BR MAP_DENYWRITE ,
.BR MAP_EXECUTABLE ,
.BR MAP_FILE ,
.BR MAP_GROWSDOWN ,
.BR MAP_HUGETLB ,
.BR MAP_LOCKED ,
.BR MAP_NONBLOCK ,
.BR MAP_NORESERVE ,
.BR MAP_POPULATE ,
and
.BR MAP_STACK .
.SH BUGS
On Linux there are no guarantees like those suggested above under
.BR MAP_NORESERVE .