Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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].
  • Loading branch information
Joseph Myers committed Nov 5, 2015
1 parent 8fed865 commit f248238
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
15 changes: 15 additions & 0 deletions ChangeLog
@@ -1,5 +1,20 @@
2015-11-05 Joseph Myers <joseph@codesourcery.com>

[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].

[BZ #19209]
* math/bits/math-finite.h (ldexp): Remove declaration.
(ldexpf): Likewise.
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Expand Up @@ -22,7 +22,7 @@ Version 2.23
19003, 19007, 19012, 19016, 19018, 19032, 19046, 19048, 19049, 19050,
19059, 19071, 19074, 19076, 19077, 19078, 19079, 19085, 19086, 19088,
19094, 19095, 19124, 19125, 19129, 19134, 19137, 19156, 19174, 19181,
19189, 19201, 19205, 19209.
19189, 19201, 19205, 19209, 19212.

* A defect in the malloc implementation, present since glibc 2.15 (2012) or
glibc 2.10 via --enable-experimental-malloc (2009), could result in the
Expand Down
17 changes: 10 additions & 7 deletions include/features.h
Expand Up @@ -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
Expand All @@ -239,31 +240,33 @@
# 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

#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
# 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
# undef __USE_ISOC99
# 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
Expand Down

0 comments on commit f248238

Please sign in to comment.