[PATCH 1/3] Move feature macro before "config.h" include

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Nov 18 07:10:46 UTC 2019


This allows to use header includes in "config.h" to reduce the build
configuration checks.

Update #3818.
---
 cpukit/libmisc/shell/hexdump-conv.c         |  7 ++++---
 cpukit/libmisc/shell/hexdump-odsyntax.c     |  8 ++++----
 cpukit/libmisc/shell/main_date.c            |  3 ++-
 cpukit/libmisc/shell/main_dd.c              |  3 ++-
 cpukit/posix/src/pthreadattrgetaffinitynp.c |  3 ++-
 cpukit/posix/src/pthreadattrsetaffinitynp.c | 11 ++++++-----
 cpukit/posix/src/pthreadgetaffinitynp.c     |  2 +-
 cpukit/posix/src/pthreadgetattrnp.c         |  3 ++-
 cpukit/posix/src/pthreadgetnamenp.c         |  3 ++-
 cpukit/posix/src/pthreadsetaffinitynp.c     |  3 ++-
 cpukit/posix/src/pthreadsetnamenp.c         |  3 ++-
 11 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/cpukit/libmisc/shell/hexdump-conv.c b/cpukit/libmisc/shell/hexdump-conv.c
index d37c6d988a..aa16f9b169 100644
--- a/cpukit/libmisc/shell/hexdump-conv.c
+++ b/cpukit/libmisc/shell/hexdump-conv.c
@@ -31,6 +31,10 @@
  * SUCH DAMAGE.
  */
 
+#ifdef __rtems__
+/* For wcwidth() visibility */
+#define _GNU_SOURCE
+#endif /* __rtems__ */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -39,9 +43,6 @@
 #ifndef lint
 static const char sccsid[] = "@(#)conv.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
-#else /* __rtems__ */
-/* For wcwidth() visibility */
-#define _GNU_SOURCE
 #endif /* __rtems__ */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/usr.bin/hexdump/conv.c,v 1.9 2006/07/31 14:17:04 jkoshy Exp $");
diff --git a/cpukit/libmisc/shell/hexdump-odsyntax.c b/cpukit/libmisc/shell/hexdump-odsyntax.c
index 8da2a34794..e3c4f3cf64 100644
--- a/cpukit/libmisc/shell/hexdump-odsyntax.c
+++ b/cpukit/libmisc/shell/hexdump-odsyntax.c
@@ -31,6 +31,10 @@
  * SUCH DAMAGE.
  */
 
+#ifdef __rtems__
+/* For asprintf() visibility */
+#define _GNU_SOURCE
+#endif /* __rtems__ */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -39,10 +43,6 @@
 #if 0
 static char sccsid[] = "@(#)odsyntax.c	8.2 (Berkeley) 5/4/95";
 #endif /* not lint */
-#ifdef __rtems__
-/* For asprintf() visibility */
-#define _GNU_SOURCE
-#endif /* __rtems__ */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/usr.bin/hexdump/odsyntax.c,v 1.17 2004/07/22 13:14:42 johan Exp $");
 #endif
diff --git a/cpukit/libmisc/shell/main_date.c b/cpukit/libmisc/shell/main_date.c
index 6070ff065f..f93e5df016 100644
--- a/cpukit/libmisc/shell/main_date.c
+++ b/cpukit/libmisc/shell/main_date.c
@@ -12,11 +12,12 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
+#define _XOPEN_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _GNU_SOURCE
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
diff --git a/cpukit/libmisc/shell/main_dd.c b/cpukit/libmisc/shell/main_dd.c
index cff70ce020..1a715303ef 100644
--- a/cpukit/libmisc/shell/main_dd.c
+++ b/cpukit/libmisc/shell/main_dd.c
@@ -31,6 +31,8 @@
  * SUCH DAMAGE.
  */
 
+#define _GNU_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -49,7 +51,6 @@ static char sccsid[] = "@(#)dd.c	8.5 (Berkeley) 4/2/94";
 __FBSDID("$FreeBSD: src/bin/dd/dd.c,v 1.43 2004/08/15 19:10:05 rwatson Exp $");
 #endif
 
-#define _GNU_SOURCE
 #include <rtems.h>
 #include <rtems/shell.h>
 #include <rtems/shellconfig.h>
diff --git a/cpukit/posix/src/pthreadattrgetaffinitynp.c b/cpukit/posix/src/pthreadattrgetaffinitynp.c
index b281b11e5f..19acfa85aa 100644
--- a/cpukit/posix/src/pthreadattrgetaffinitynp.c
+++ b/cpukit/posix/src/pthreadattrgetaffinitynp.c
@@ -14,13 +14,14 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
+#define  _GNU_SOURCE
+
 #if HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #if HAVE_DECL_PTHREAD_ATTR_GETAFFINITY_NP
 
-#define  _GNU_SOURCE
 #include <pthread.h>
 #include <errno.h>
 
diff --git a/cpukit/posix/src/pthreadattrsetaffinitynp.c b/cpukit/posix/src/pthreadattrsetaffinitynp.c
index 0e3c828c38..a05b74e4de 100644
--- a/cpukit/posix/src/pthreadattrsetaffinitynp.c
+++ b/cpukit/posix/src/pthreadattrsetaffinitynp.c
@@ -1,7 +1,3 @@
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 /**
  * @file
  *
@@ -18,9 +14,14 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
+#define  _GNU_SOURCE
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #if HAVE_DECL_PTHREAD_ATTR_SETAFFINITY_NP
 
-#define  _GNU_SOURCE
 #include <pthread.h>
 #include <errno.h>
 
diff --git a/cpukit/posix/src/pthreadgetaffinitynp.c b/cpukit/posix/src/pthreadgetaffinitynp.c
index dab6b63aa0..c9595a45f5 100644
--- a/cpukit/posix/src/pthreadgetaffinitynp.c
+++ b/cpukit/posix/src/pthreadgetaffinitynp.c
@@ -14,6 +14,7 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
+#define  _GNU_SOURCE
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -21,7 +22,6 @@
 
 #if HAVE_DECL_PTHREAD_GETAFFINITY_NP
 
-#define  _GNU_SOURCE
 #include <pthread.h>
 #include <errno.h>
 
diff --git a/cpukit/posix/src/pthreadgetattrnp.c b/cpukit/posix/src/pthreadgetattrnp.c
index 5cc47c6901..d84383c204 100644
--- a/cpukit/posix/src/pthreadgetattrnp.c
+++ b/cpukit/posix/src/pthreadgetattrnp.c
@@ -14,11 +14,12 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
+#define  _GNU_SOURCE
+
 #if HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define  _GNU_SOURCE
 #include <pthread.h>
 #include <errno.h>
 #include <string.h>
diff --git a/cpukit/posix/src/pthreadgetnamenp.c b/cpukit/posix/src/pthreadgetnamenp.c
index e753823976..502f051b81 100644
--- a/cpukit/posix/src/pthreadgetnamenp.c
+++ b/cpukit/posix/src/pthreadgetnamenp.c
@@ -6,11 +6,12 @@
  * http://www.rtems.org/license/LICENSE.
  */
 
+#define _GNU_SOURCE
+
 #if HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _GNU_SOURCE
 #include <pthread.h>
 #include <errno.h>
 #include <string.h>
diff --git a/cpukit/posix/src/pthreadsetaffinitynp.c b/cpukit/posix/src/pthreadsetaffinitynp.c
index 0d3fec4482..7c8ac8c605 100644
--- a/cpukit/posix/src/pthreadsetaffinitynp.c
+++ b/cpukit/posix/src/pthreadsetaffinitynp.c
@@ -14,13 +14,14 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
+#define  _GNU_SOURCE
+
 #if HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #if HAVE_DECL_PTHREAD_SETAFFINITY_NP
 
-#define  _GNU_SOURCE
 #include <pthread.h>
 #include <errno.h>
 
diff --git a/cpukit/posix/src/pthreadsetnamenp.c b/cpukit/posix/src/pthreadsetnamenp.c
index cb0e47ce94..cbb2e43311 100644
--- a/cpukit/posix/src/pthreadsetnamenp.c
+++ b/cpukit/posix/src/pthreadsetnamenp.c
@@ -6,11 +6,12 @@
  * http://www.rtems.org/license/LICENSE.
  */
 
+#define _GNU_SOURCE
+
 #if HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _GNU_SOURCE
 #include <pthread.h>
 #include <errno.h>
 
-- 
2.16.4



More information about the devel mailing list