posix_memalign.3: Improve discussion of feature test macros and header files for valloc(3)

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2012-03-23 05:20:12 +13:00
parent a87607d4ff
commit 287cdf88dc
1 changed files with 11 additions and 14 deletions

View File

@ -23,7 +23,7 @@
.\" License.
.\"
.\" 2001-10-11, 2003-08-22, aeb, added some details
.TH POSIX_MEMALIGN 3 2010-09-20 "GNU" "Linux Programmer's Manual"
.TH POSIX_MEMALIGN 3 2012-03-23 "GNU" "Linux Programmer's Manual"
.SH NAME
posix_memalign, memalign, valloc \- Allocate aligned memory
.SH SYNOPSIS
@ -31,10 +31,10 @@ posix_memalign, memalign, valloc \- Allocate aligned memory
.B #include <stdlib.h>
.sp
.BI "int posix_memalign(void **" memptr ", size_t " alignment ", size_t " size );
.BI "void *valloc(size_t " size );
.sp
.B #include <malloc.h>
.sp
.BI "void *valloc(size_t " size );
.BI "void *memalign(size_t " boundary ", size_t " size );
.fi
.sp
@ -64,9 +64,15 @@ _BSD_SOURCE ||
Before glibc 2.12:
_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
.ad b
.br
(The (nonstandard) header file
.I <malloc.h>
also exposes the declaration of
.BR valloc ();
no feature test macros are required.)
.RE
.PD
.ad b
.SH DESCRIPTION
The function
.BR posix_memalign ()
@ -164,18 +170,9 @@ is declared in \fI<stdlib.h>\fP instead of \fI<malloc.h>\fP.
According to SUSv2,
.BR valloc ()
is declared in \fI<stdlib.h>\fP.
Libc4,5 and glibc declare it in \fI<malloc.h>\fP and perhaps also in
Libc4,5 and glibc declare it in \fI<malloc.h>\fP, and also in
\fI<stdlib.h>\fP
(namely, if
.B _GNU_SOURCE
is defined, or
.B _BSD_SOURCE
is defined, or,
for glibc, if
.B _XOPEN_SOURCE_EXTENDED
is defined, or, equivalently,
.B _XOPEN_SOURCE
is defined to a value not less than 500).
if suitable feature test macros are defined (see above).
.SH NOTES
On many systems there are alignment restrictions, for example, on buffers
used for direct block device I/O.