about summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2015-11-05 21:19:37 +0000
committerJoseph Myers <joseph@codesourcery.com>2015-11-05 21:19:37 +0000
commitf248238cf43bd751db29e6f151d6da7645337ff5 (patch)
treea27ff09a2c76a490ee7642b03ddb39aa60e121bf /include
parent8fed86556b7e162d2926f0ba6a573ed193ff882f (diff)
downloadglibc-f248238cf43bd751db29e6f151d6da7645337ff5.tar.gz
glibc-f248238cf43bd751db29e6f151d6da7645337ff5.tar.xz
glibc-f248238cf43bd751db29e6f151d6da7645337ff5.zip
Fix features.h for -Wundef (bug 19212).
features.h is not clean with -Wundef (for the installed header, of
course this only appears with -Wsystem-headers).  In ISO C standards
modes, you get a series of warnings / errors relating to
_POSIX_C_SOURCE and _XOPEN_SOURCE not being defined when tested in
standards mode and uses #undef _GNU_SOURCE to avoid the default
_GNU_SOURCE from libc-symbols.h.  This patch changes the relevant #if
conditionals to avoid these warnings / errors.

Tested for x86_64 and x86 (testsuite, and that installed shared
libraries are unchanged by the patch).

	[BZ #19212]
	* include/features.h [(_XOPEN_SOURCE - 0) >= 500]: Change
	conditional to [defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >=
	500].
	[_POSIX_C_SOURCE >= 1]: Change conditional to [defined
	_POSIX_C_SOURCE && _POSIX_C_SOURCE >= 1].
	[(_POSIX_C_SOURCE - 0) >= 199309L]: Change conditional to [defined
	_POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L].
	[(_POSIX_C_SOURCE - 0) >= 199506L]: Change conditional to [defined
	_POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199506L].
	[(_POSIX_C_SOURCE - 0) >= 200112L]: Change conditional to [defined
	_POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200112L].
	[(_POSIX_C_SOURCE - 0) >= 200809L]: Change conditional to [defined
	_POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L].
Diffstat (limited to 'include')
-rw-r--r--include/features.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/include/features.h b/include/features.h
index bb8061073e..774afdd2fe 100644
--- a/include/features.h
+++ b/include/features.h
@@ -224,8 +224,9 @@
 # undef  _POSIX_C_SOURCE
 # define _POSIX_C_SOURCE	200809L
 #endif
-#if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \
-     !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
+#if ((!defined __STRICT_ANSI__					\
+      || (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500))	\
+     && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
 # define _POSIX_SOURCE	1
 # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
 #  define _POSIX_C_SOURCE	2
@@ -239,7 +240,9 @@
 # define __USE_POSIX_IMPLICITLY	1
 #endif
 
-#if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
+#if (defined _POSIX_SOURCE					\
+     || (defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 1)	\
+     || defined _XOPEN_SOURCE)
 # define __USE_POSIX	1
 #endif
 
@@ -247,15 +250,15 @@
 # define __USE_POSIX2	1
 #endif
 
-#if (_POSIX_C_SOURCE - 0) >= 199309L
+#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L
 # define __USE_POSIX199309	1
 #endif
 
-#if (_POSIX_C_SOURCE - 0) >= 199506L
+#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199506L
 # define __USE_POSIX199506	1
 #endif
 
-#if (_POSIX_C_SOURCE - 0) >= 200112L
+#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200112L
 # define __USE_XOPEN2K		1
 # undef __USE_ISOC95
 # define __USE_ISOC95		1
@@ -263,7 +266,7 @@
 # define __USE_ISOC99		1
 #endif
 
-#if (_POSIX_C_SOURCE - 0) >= 200809L
+#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L
 # define __USE_XOPEN2K8		1
 # undef  _ATFILE_SOURCE
 # define _ATFILE_SOURCE	1