A small issue with _GNU_SOURCE

Jon TURNEY jon.turney@dronecode.org.uk
Tue Feb 24 13:28:00 GMT 2015


On 19/02/2015 14:33, Corinna Vinschen wrote:
> Maybe by changing the evaluation order in sys/cdefs.h.
>
> _GNU_SOURCE implies "everything and the kitchen sink" as the comment
> says,
>
>    #define __POSIX_VISIBLE         200809
>    #define __XSI_VISIBLE           700
>    #define __BSD_VISIBLE           1
>    #define __ISO_C_VISIBLE         2011
>    #define __GNU_VISIBLE           1
>
> so it might be prudent to check for _GNU_SOURCE before checking for
> _XOPEN_SOURCE, instead of checking only if _POSIX_SOURCE/_POSIX_C_SOURCE
> is not set.

Yes.  I'm a bit reluctant to touch this maze of conditionals, but that 
seems the right approach.  Patch is attached.


-------------- next part --------------
2015-02-24  Jon TURNEY  <jon.turney@dronecode.org.uk>

	* libc/include/sys/cdefs.h (_GNU_SOURCE): Move check so it has an
	effect when _XOPEN_SOURCE is also defined.

Index: libc/include/sys/cdefs.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/cdefs.h,v
retrieving revision 1.9
diff -u -u -p -r1.9 cdefs.h
--- libc/include/sys/cdefs.h	3 Dec 2013 16:04:41 -0000	1.9
+++ libc/include/sys/cdefs.h	24 Feb 2015 12:43:29 -0000
@@ -606,6 +606,13 @@
  * Our macros begin with two underscores to avoid namespace screwage.
  */
 
+/* Deal with _GNU_SOURCE, which implies everything and the kitchen sink */
+#ifdef _GNU_SOURCE
+#define	_XOPEN_SOURCE		700
+#define	__BSD_VISIBLE		1
+#define	__GNU_VISIBLE		1
+#endif
+
 /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
 #undef _POSIX_C_SOURCE		/* Probably illegal, but beyond caring now. */
@@ -693,12 +700,6 @@
 #define	__XSI_VISIBLE		0
 #define	__BSD_VISIBLE		0
 #define	__ISO_C_VISIBLE		2011
-#elif defined(_GNU_SOURCE)	/* Everything and the kitchen sink. */
-#define	__POSIX_VISIBLE		200809
-#define	__XSI_VISIBLE		700
-#define	__BSD_VISIBLE		1
-#define	__ISO_C_VISIBLE		2011
-#define	__GNU_VISIBLE		1
 #else				/* Default: everything except __GNU_VISIBLE. */
 #define	__POSIX_VISIBLE		200809
 #define	__XSI_VISIBLE		700


More information about the Newlib mailing list