about summary refs log tree commit diff
path: root/manual/creature.texi
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-12-19 13:32:42 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-12-19 13:32:42 +0000
commitc688b4196014e0162a1ff11120f6c9516be0c6cb (patch)
treecbd05e278192c66c63f6d79b26bb0c1e19d805d4 /manual/creature.texi
parent9f6e964c3a951b6e19ed934aec1f0c101c295987 (diff)
downloadglibc-c688b4196014e0162a1ff11120f6c9516be0c6cb.tar.gz
glibc-c688b4196014e0162a1ff11120f6c9516be0c6cb.tar.xz
glibc-c688b4196014e0162a1ff11120f6c9516be0c6cb.zip
Add _DEFAULT_SOURCE feature test macro.
This patch adds a feature test macro _DEFAULT_SOURCE to enable the
default set of header declarations.

The intention is: if _DEFAULT_SOURCE is not used there is no change to
the set of __USE_* macros glibc defines; if it's used on its own, and
without compiler options such as -std=c99 that define __STRICT_ANSI__,
again, there is no change; if it's used together with the macros it
approximately (i.e., apart from __USE_POSIX_IMPLICITLY) implies
(-D_BSD_SOURCE -D_SVID_SOURCE -D_POSIX_C_SOURCE=200809L), again, there
is no change.  Otherwise, it causes the relevant features to be
enabled, even if __STRICT_ANSI__, or another feature test macro, would
cause them to be disabled.

This macro deliberately bundles the POSIX.1-2008 (non-X/Open)
functionality with the BSD/SVID/"misc" functionality, rather than
defining a macro that gives just the latter, as many of the header
cleanups resulting from removing _BSD_SOURCE and _SVID_SOURCE support
are only possible when BSD/SVID/"misc" is always bundled with
POSIX.1-2008.

Tested x86_64.

	* include/features.h: Update comment documenting feature test
	macros.  Mention _DEFAULT_SOURCE in comment.
	[_GNU_SOURCE] (_DEFAULT_SOURCE): Undefine and redefine.
	[_DEFAULT_SOURCE]: Undefine and redefine _DEFAULT_SOURCE,
	_BSD_SOURCE and _SVID_SOURCE.
	[!__STRICT_ANSI__ && !_ISOC99_SOURCE && !_POSIX_SOURCE &&
	!_POSIX_C_SOURCE && !_XOPEN_SOURCE && !_BSD_SOURCE &&
	!_SVID_SOURCE]: Likewise.
	[_DEFAULT_SOURCE && !_POSIX_SOURCE && !_POSIX_C_SOURCE]
	(__USE_POSIX_IMPLICITLY): Define.
	[_DEFAULT_SOURCE && !_POSIX_SOURCE && !_POSIX_C_SOURCE]
	(_POSIX_SOURCE): Undefine and redefine.
	[_DEFAULT_SOURCE && !_POSIX_SOURCE && !_POSIX_C_SOURCE]
	(_POSIX_C_SOURCE): Likewise.
	* manual/creature.texi (_DEFAULT_SOURCE): Document.
	(Feature Test Macros): Update documentation of default features.
Diffstat (limited to 'manual/creature.texi')
-rw-r--r--manual/creature.texi23
1 files changed, 19 insertions, 4 deletions
diff --git a/manual/creature.texi b/manual/creature.texi
index 3b7e77c78b..bbf16b7f27 100644
--- a/manual/creature.texi
+++ b/manual/creature.texi
@@ -190,6 +190,21 @@ precedence.
 
 @comment (none)
 @comment GNU
+@defvr Macro _DEFAULT_SOURCE
+If you define this macro, most features are included apart from
+X/Open, LFS and GNU extensions; the effect is similar to defining
+@code{_POSIX_C_SOURCE} to @code{200809L} and @code{_POSIX_SOURCE},
+@code{_SVID_SOURCE}, and @code{_BSD_SOURCE} to 1.  Defining this
+macro, on its own and without using compiler options such as
+@option{-ansi} or @option{-std=c99}, has the same effect as not
+defining any feature test macros; defining it together with other
+feature test macros, or when options such as @option{-ansi} are used,
+enables those features even when the other options would otherwise
+cause them to be disabled.
+@end defvr
+
+@comment (none)
+@comment GNU
 @defvr Macro _REENTRANT
 @defvrx Macro _THREAD_SAFE
 If you define one of these macros, reentrant versions of several functions get
@@ -204,10 +219,10 @@ it must have been specified to compile as thread safe.
 @end defvr
 
 We recommend you use @code{_GNU_SOURCE} in new programs.  If you don't
-specify the @samp{-ansi} option to GCC and don't define any of these
-macros explicitly, the effect is the same as defining
-@code{_POSIX_C_SOURCE} to 2 and @code{_POSIX_SOURCE},
-@code{_SVID_SOURCE}, and @code{_BSD_SOURCE} to 1.
+specify the @samp{-ansi} option to GCC, or other conformance options
+such as @option{-std=c99}, and don't define any of these macros
+explicitly, the effect is the same as defining @code{_DEFAULT_SOURCE}
+to 1.
 
 When you define a feature test macro to request a larger class of features,
 it is harmless to define in addition a feature test macro for a subset of