Various improvements.

This commit is contained in:
Michael Kerrisk 2007-07-03 21:49:06 +00:00
parent e9600b209a
commit 4769db2436
1 changed files with 87 additions and 31 deletions

View File

@ -112,12 +112,23 @@ feature test macro requirements (this example from
.fi .fi
.RE .RE
.PP .PP
This syntax is used in cases where only a single This format is employed in cases where only a single
feature test macro can be used to expose the function feature test macro can be used to expose the function
declaration, and that macro is not defined by default. declaration, and that macro is not defined by default.
.SS Feature test macros understood by glibc .SS Feature test macros understood by glibc
Linux/glibc understands the following feature test macros: Linux/glibc understands the following feature test macros:
.\" FIXME ? add _ATFILE_SOURCE to this list .\" FIXME ? add _ATFILE_SOURCE to this list
.TP
.B __STRICT_ANSI__
ISO Standard C.
This macro is implicitly defined by
.BR gcc (1)
when invoked with, for example, the
.I -std=c99
or
.I -ansi
flag.
.TP .TP
.B _POSIX_C_SOURCE .B _POSIX_C_SOURCE
Defining this macro with the value 1 causes header files to expose Defining this macro with the value 1 causes header files to expose
@ -139,24 +150,12 @@ with the value 1.
.B _XOPEN_SOURCE .B _XOPEN_SOURCE
Defining this macro with any value causes header files to expose Defining this macro with any value causes header files to expose
definitions conforming to POSIX.1, POSIX.2, and XPG4. definitions conforming to POSIX.1, POSIX.2, and XPG4.
Defining with the value 500 or greater additionally exposes Defining this macro with the value 500 or greater additionally exposes
definitions for SUSv2 (UNIX 98). definitions for SUSv2 (UNIX 98).
Defining with the value 600 or greater additionally exposes Since glibc 2.2, defining this macro with the value 600
or greater additionally exposes
definitions for SUSv3 (UNIX 03; i.e., the POSIX.1-2001 base specification definitions for SUSv3 (UNIX 03; i.e., the POSIX.1-2001 base specification
plus the XSI extension) and C 99 definitions. plus the XSI extension) and C 99 definitions.
.IP
Defining
.B _XOPEN_SOURCE
also implicitly defines
.BR _POSIX_C_SOURCE :
with the value 2, if
.B _XOPEN_SOURCE
is less than 500;
with the value 199506L, if 500 <=
.B _XOPEN_SOURCE
< 600; or with the value 200112L if
.B _XOPEN_SOURCE
>= 600.
.TP .TP
.B _XOPEN_SOURCE_EXTENDED .B _XOPEN_SOURCE_EXTENDED
If this macro is defined with the value 1, and the If this macro is defined with the value 1, and the
@ -221,16 +220,25 @@ System V-derived definitions.
(SVID == System V Interface Definition; see (SVID == System V Interface Definition; see
.BR standards (7).) .BR standards (7).)
.TP .TP
.B _ATFILE_SOURCE
Defining this macro with any value cause header files to expose
declarations of a range of functions with the suffix "at";
see
.BR openat (2).
.TP
.B _GNU_SOURCE .B _GNU_SOURCE
Defining this macro (with any value) is equivalent to defining Defining this macro (with any value) is equivalent to defining
.BR _BSD_SOURCE , .BR _BSD_SOURCE ,
.BR _SVID_SOURCE , .BR _SVID_SOURCE ,
.BR _ATFILE_SOURCE ,
.BR _LARGEFILE64_SOURCE , .BR _LARGEFILE64_SOURCE ,
.BR _ISOC99_SOURCE .BR _ISOC99_SOURCE ,
.BR _XOPEN_SOURCE_EXTENDED ,
.BR _POSIX_SOURCE ,
.BR _POSIX_C_SOURCE .BR _POSIX_C_SOURCE
with the value 200112L, and with the value 200112L (199506L in glibc versions before 2.5), and
.BR _XOPEN_SOURCE .BR _XOPEN_SOURCE
with the value 600. with the value 600 (500 in glibc versions before 2.2).
In addition, various GNU-specific extensions are also exposed. In addition, various GNU-specific extensions are also exposed.
Where standards conflict, BSD definitions are disfavored. Where standards conflict, BSD definitions are disfavored.
.TP .TP
@ -290,24 +298,70 @@ and result in a run-time error if the check fails.
Use of this macro requires compiler support, available with Use of this macro requires compiler support, available with
.BR gcc (1) .BR gcc (1)
since version 4.0. since version 4.0.
.SS Feature test macros defined by default .SS Default definitions, implicit definitions, and combining definitions
.PP .PP
The following macros are defined by default: The following feature test macros are defined by default:
.BR _BSD_SOURCE , .BR _BSD_SOURCE ,
.BR _SVID_SOURCE , .BR _SVID_SOURCE ,
.BR _POSIX_SOURCE , .BR _POSIX_SOURCE ,
and and
.BR _POSIX_C_SOURCE =199506L. .BR _POSIX_C_SOURCE =200112L
If individual macros are defined, then other macros are disabled (199506L in glibc versions before 2.5).
unless they are also explicitly defined. .PP
(Exception: if If any of
.BR __STRICT_ANSI__ ,
.BR _ISOC99_SOURCE ,
.BR _POSIX_SOURCE ,
.BR _POSIX_C_SOURCE ,
.BR _XOPEN_SOURCE ,
.BR _XOPEN_SOURCE_EXTENDED ,
.BR _BSD_SOURCE ,
or
.BR _SVID_SOURCE
is explicitly defined, then
.BR _BSD_SOURCE ,
and
.BR _SVID_SOURCE
are not defined by default.
If
.BR _POSIX_SOURCE
and
.BR _POSIX_C_SOURCE .BR _POSIX_C_SOURCE
is not otherwise defined, are not explicitly defined,
then it is always defined with the value 200112L and either
(199506L in glibc versions before 2.4), .BR __STRICT_ANSI__
unless the compiler is invoked in one of its standard modes, for example, the is not defined or
.I -std=c99 .BR _XOPEN_SOURCE
flag.) is defined with a value of 500 or more, then
.RS 6
.IP * 3
.B _POSIX_SOURCE
is defined with the value 1; and
.IP *
.B _POSIX_C_SOURCE
is defined with one of the following values:
.RS 6
.IP \(bu 3
2,
if
.BR XOPEN_SOURCE
is defined with a value less than 500;
.IP \(bu
199506L,
if
.BR XOPEN_SOURCE
is defined with a value greater than or equal to 500 and less than 600;
or
.IP \(bu
200112L (199506L in glibc versions before 2.5),
if
.BR XOPEN_SOURCE
is undefined, or
is defined with a value greater than or equal to 600.
.RE
.RE
.PP
Multiple macros can be defined; the results are additive. Multiple macros can be defined; the results are additive.
.SH CONFORMING TO .SH CONFORMING TO
POSIX.1 specifies POSIX.1 specifies
@ -317,9 +371,11 @@ and
.BR _XOPEN_SOURCE . .BR _XOPEN_SOURCE .
.BR _XOPEN_SOURCE_EXTENDED .BR _XOPEN_SOURCE_EXTENDED
was specified by XPG4v2 (aka SUSv1). was specified by XPG4v2 (aka SUSv1).
.BR _FILE_OFFSET_BITS .BR _FILE_OFFSET_BITS
is not specified by any standard, is not specified by any standard,
but is employed on some other implementations. but is employed on some other implementations.
.BR _BSD_SOURCE , .BR _BSD_SOURCE ,
.BR _SVID_SOURCE , .BR _SVID_SOURCE ,
.BR _GNU_SOURCE , .BR _GNU_SOURCE ,