From fc8974b7aabd2e7c9884e8d5e3d84395461396ff Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 4 Sep 2014 08:52:38 -0700 Subject: [PATCH] _GNU_SOURCE implies _BSD_SOURCE and the latest _POSIX_C_SOURCE. This showed up as open_memstream not being visible in if only _GNU_SOURCE was defined. Bug: 17361504 Change-Id: I38f9843f4e6ee770a6325ad50f779bda5495ffca --- libc/include/sys/cdefs.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h index b223afd05..5082327dc 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -362,13 +362,22 @@ * do it in instead because that's where our existing * _POSIX_C_SOURCE tests were, and we're already confident that * is included everywhere it should be. + * + * The _GNU_SOURCE test needs to come before any _BSD_SOURCE or _POSIX* tests + * because _GNU_SOURCE implies everything else. */ -#if defined(_BSD_SOURCE) -# define __USE_BSD 1 -#endif - #if defined(_GNU_SOURCE) # define __USE_GNU 1 +# undef _POSIX_SOURCE +# define _POSIX_SOURCE 1 +# undef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 200809L +# undef _BSD_SOURCE +# define _BSD_SOURCE 1 +#endif + +#if defined(_BSD_SOURCE) +# define __USE_BSD 1 #endif /*-