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

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Nov 27 11:03:05 UTC 2019


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

Update #3818.
---
 testsuites/psxtests/psxclassic01/init.c            | 4 ++--
 testsuites/psxtests/psxconfig01/init.c             | 4 ++--
 testsuites/psxtests/psxdevctl01/test.c             | 3 ++-
 testsuites/psxtests/psxgetattrnp01/init.c          | 3 ++-
 testsuites/psxtests/psxhdrs/devctl/posix_devctl.c  | 4 ++--
 testsuites/psxtests/psxhdrs/ftw/ftw.c              | 3 ++-
 testsuites/psxtests/psxhdrs/ftw/nftw.c             | 3 ++-
 testsuites/psxtests/psxhdrs/math/y0l.c             | 3 ++-
 testsuites/psxtests/psxhdrs/math/y1.c              | 3 ++-
 testsuites/psxtests/psxhdrs/math/y1l.c             | 3 ++-
 testsuites/psxtests/psxhdrs/stdio/getdelim.c       | 4 +++-
 testsuites/psxtests/psxhdrs/stdio/getline.c        | 3 ++-
 testsuites/psxtests/psxhdrs/stdio/renameat.c       | 3 ++-
 testsuites/psxtests/psxhdrs/stdlib/getsubopt.c     | 5 +++--
 testsuites/psxtests/psxhdrs/stdlib/grantpt.c       | 5 +++--
 testsuites/psxtests/psxhdrs/stdlib/posix_openpt.c  | 5 +++--
 testsuites/psxtests/psxhdrs/stdlib/ptsname.c       | 5 +++--
 testsuites/psxtests/psxhdrs/stdlib/setkey.c        | 5 +++--
 testsuites/psxtests/psxhdrs/stdlib/unlockpt.c      | 5 +++--
 testsuites/psxtests/psxhdrs/strings/strcasecmp_l.c | 4 ++--
 testsuites/psxtests/psxhdrs/sys/msg/msgctl.c       | 3 ++-
 testsuites/psxtests/psxhdrs/sys/msg/msgget.c       | 5 +++--
 testsuites/psxtests/psxhdrs/ucontext/makecontext.c | 9 +++++----
 testsuites/psxtests/psxhdrs/ucontext/setcontext.c  | 5 +++--
 testsuites/psxtests/psxhdrs/wchar/wcswidth.c       | 3 ++-
 testsuites/psxtests/psxhdrs/wchar/wcwidth.c        | 3 ++-
 testsuites/psxtests/psxthreadname01/init.c         | 5 +++--
 testsuites/sptests/spscheduler01/init.c            | 6 +++---
 28 files changed, 70 insertions(+), 46 deletions(-)

diff --git a/testsuites/psxtests/psxclassic01/init.c b/testsuites/psxtests/psxclassic01/init.c
index 4711732dc7..42ddf10bec 100644
--- a/testsuites/psxtests/psxclassic01/init.c
+++ b/testsuites/psxtests/psxclassic01/init.c
@@ -13,12 +13,12 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
+#define _GNU_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _GNU_SOURCE
-
 #include <stdio.h>
 #include <rtems.h>
 #include <pthread.h>
diff --git a/testsuites/psxtests/psxconfig01/init.c b/testsuites/psxtests/psxconfig01/init.c
index 2eeacbdbd4..dc90373248 100644
--- a/testsuites/psxtests/psxconfig01/init.c
+++ b/testsuites/psxtests/psxconfig01/init.c
@@ -21,12 +21,12 @@
  * http://www.rtems.org/license/LICENSE.
  */
 
+#define _GNU_SOURCE
+
 #ifdef HAVE_CONFIG_H
   #include "config.h"
 #endif
 
-#define _GNU_SOURCE
-
 #include <rtems/test.h>
 #include <tmacros.h>
 
diff --git a/testsuites/psxtests/psxdevctl01/test.c b/testsuites/psxtests/psxdevctl01/test.c
index 0fe9d9460b..ed22ba8410 100644
--- a/testsuites/psxtests/psxdevctl01/test.c
+++ b/testsuites/psxtests/psxdevctl01/test.c
@@ -13,11 +13,12 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
+#define _POSIX_26_C_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _POSIX_26_C_SOURCE
 #include "tmacros.h"
 #include <errno.h>
 #include <sys/ioctl.h>
diff --git a/testsuites/psxtests/psxgetattrnp01/init.c b/testsuites/psxtests/psxgetattrnp01/init.c
index 986c650b56..dca5a25dae 100644
--- a/testsuites/psxtests/psxgetattrnp01/init.c
+++ b/testsuites/psxtests/psxgetattrnp01/init.c
@@ -7,11 +7,12 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
+#define _GNU_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _GNU_SOURCE
 #include <tmacros.h>
 #include <errno.h>
 #include <sched.h>
diff --git a/testsuites/psxtests/psxhdrs/devctl/posix_devctl.c b/testsuites/psxtests/psxhdrs/devctl/posix_devctl.c
index 3a40c7869a..db034599de 100644
--- a/testsuites/psxtests/psxhdrs/devctl/posix_devctl.c
+++ b/testsuites/psxtests/psxhdrs/devctl/posix_devctl.c
@@ -7,12 +7,12 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
+#define _POSIX_26_C_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _POSIX_26_C_SOURCE
-
 #include <devctl.h>
 
 int test( void );
diff --git a/testsuites/psxtests/psxhdrs/ftw/ftw.c b/testsuites/psxtests/psxhdrs/ftw/ftw.c
index 2578d3af44..41757165a8 100644
--- a/testsuites/psxtests/psxhdrs/ftw/ftw.c
+++ b/testsuites/psxtests/psxhdrs/ftw/ftw.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE 500
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE 500
 #include <ftw.h>
 
 int test( void );
diff --git a/testsuites/psxtests/psxhdrs/ftw/nftw.c b/testsuites/psxtests/psxhdrs/ftw/nftw.c
index 092851a047..e55763ce68 100644
--- a/testsuites/psxtests/psxhdrs/ftw/nftw.c
+++ b/testsuites/psxtests/psxhdrs/ftw/nftw.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE 500
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE 500
 #include <ftw.h>
 
 int test( void );
diff --git a/testsuites/psxtests/psxhdrs/math/y0l.c b/testsuites/psxtests/psxhdrs/math/y0l.c
index c036bcd591..4384ada48a 100644
--- a/testsuites/psxtests/psxhdrs/math/y0l.c
+++ b/testsuites/psxtests/psxhdrs/math/y0l.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _POSIX_C_SOURCE 200809L
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _POSIX_C_SOURCE 200809L
 #include <math.h>
 
 int test( void );
diff --git a/testsuites/psxtests/psxhdrs/math/y1.c b/testsuites/psxtests/psxhdrs/math/y1.c
index ea973297f8..d880728c1b 100644
--- a/testsuites/psxtests/psxhdrs/math/y1.c
+++ b/testsuites/psxtests/psxhdrs/math/y1.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE 500
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE 500
 #include <math.h>
 
 int test( void );
diff --git a/testsuites/psxtests/psxhdrs/math/y1l.c b/testsuites/psxtests/psxhdrs/math/y1l.c
index d50925cf46..48dbaab940 100644
--- a/testsuites/psxtests/psxhdrs/math/y1l.c
+++ b/testsuites/psxtests/psxhdrs/math/y1l.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _POSIX_C_SOURCE 200809L
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _POSIX_C_SOURCE 200809L
 #include <math.h>
 
 int test( void );
diff --git a/testsuites/psxtests/psxhdrs/stdio/getdelim.c b/testsuites/psxtests/psxhdrs/stdio/getdelim.c
index c4368f947e..e1b91492f6 100644
--- a/testsuites/psxtests/psxhdrs/stdio/getdelim.c
+++ b/testsuites/psxtests/psxhdrs/stdio/getdelim.c
@@ -29,11 +29,13 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+
+#define _POSIX_C_SOURCE 200809L
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _POSIX_C_SOURCE 200809L
 #include <stdio.h>
 
 int test( void );
diff --git a/testsuites/psxtests/psxhdrs/stdio/getline.c b/testsuites/psxtests/psxhdrs/stdio/getline.c
index 9427d258e9..bbbc389a46 100644
--- a/testsuites/psxtests/psxhdrs/stdio/getline.c
+++ b/testsuites/psxtests/psxhdrs/stdio/getline.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _POSIX_C_SOURCE 200809L
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _POSIX_C_SOURCE 200809L
 #include <stdio.h>
 
 int test( void );
diff --git a/testsuites/psxtests/psxhdrs/stdio/renameat.c b/testsuites/psxtests/psxhdrs/stdio/renameat.c
index 8de1381984..ef62a54580 100644
--- a/testsuites/psxtests/psxhdrs/stdio/renameat.c
+++ b/testsuites/psxtests/psxhdrs/stdio/renameat.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _POSIX_C_SOURCE 200809L
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _POSIX_C_SOURCE 200809L
 #include <stdio.h>
 
 int test( void );
diff --git a/testsuites/psxtests/psxhdrs/stdlib/getsubopt.c b/testsuites/psxtests/psxhdrs/stdlib/getsubopt.c
index 3d6c09fd0e..172c50533e 100755
--- a/testsuites/psxtests/psxhdrs/stdlib/getsubopt.c
+++ b/testsuites/psxtests/psxhdrs/stdlib/getsubopt.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE 500
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE 500
 #include <stdlib.h>
 
 int test( void );
@@ -47,4 +48,4 @@ int test( void )
     char *valuep;
     return_value = getsubopt(&optionp, tokens, &valuep);
     return return_value;
-}
\ No newline at end of file
+}
diff --git a/testsuites/psxtests/psxhdrs/stdlib/grantpt.c b/testsuites/psxtests/psxhdrs/stdlib/grantpt.c
index 01c4a195c4..2ba0ad7787 100755
--- a/testsuites/psxtests/psxhdrs/stdlib/grantpt.c
+++ b/testsuites/psxtests/psxhdrs/stdlib/grantpt.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE 500
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE 500
 #include <stdlib.h>
 
 int test( void );
@@ -46,4 +47,4 @@ int test( void )
 
 	return_value = grantpt(fildes);
 	return return_value;
-}
\ No newline at end of file
+}
diff --git a/testsuites/psxtests/psxhdrs/stdlib/posix_openpt.c b/testsuites/psxtests/psxhdrs/stdlib/posix_openpt.c
index acdcc7f056..83201aa7a1 100755
--- a/testsuites/psxtests/psxhdrs/stdlib/posix_openpt.c
+++ b/testsuites/psxtests/psxhdrs/stdlib/posix_openpt.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE 600
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE 600
 #include <stdlib.h>
 
 int test( void );
@@ -45,4 +46,4 @@ int test( void )
 
 	return_value = posix_openpt(1);
 	return (return_value != -1);
-}
\ No newline at end of file
+}
diff --git a/testsuites/psxtests/psxhdrs/stdlib/ptsname.c b/testsuites/psxtests/psxhdrs/stdlib/ptsname.c
index cefdae0fe6..e94ce64f0d 100755
--- a/testsuites/psxtests/psxhdrs/stdlib/ptsname.c
+++ b/testsuites/psxtests/psxhdrs/stdlib/ptsname.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE 500
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE 500
 #include <stdlib.h>
 
 int test( void );
@@ -45,4 +46,4 @@ int test( void )
 
 	return_value = (char *)ptsname(1);
 	return (return_value != NULL);
-}
\ No newline at end of file
+}
diff --git a/testsuites/psxtests/psxhdrs/stdlib/setkey.c b/testsuites/psxtests/psxhdrs/stdlib/setkey.c
index f7fce847e6..f7142a0544 100755
--- a/testsuites/psxtests/psxhdrs/stdlib/setkey.c
+++ b/testsuites/psxtests/psxhdrs/stdlib/setkey.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE
 #include <stdlib.h>
 
 int test( void );
@@ -45,4 +46,4 @@ int main( void )
 
 	setkey(array);
 	return 1;
-}
\ No newline at end of file
+}
diff --git a/testsuites/psxtests/psxhdrs/stdlib/unlockpt.c b/testsuites/psxtests/psxhdrs/stdlib/unlockpt.c
index c2cf2a7c7d..f60f659773 100755
--- a/testsuites/psxtests/psxhdrs/stdlib/unlockpt.c
+++ b/testsuites/psxtests/psxhdrs/stdlib/unlockpt.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE 500
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE 500
 #include <stdlib.h>
 
 int test( void );
@@ -46,4 +47,4 @@ int test( void )
 
 	return_value = unlockpt(fd);
 	return (return_value != -1);
-}
\ No newline at end of file
+}
diff --git a/testsuites/psxtests/psxhdrs/strings/strcasecmp_l.c b/testsuites/psxtests/psxhdrs/strings/strcasecmp_l.c
index 01342d3f3b..b9d094d8c0 100644
--- a/testsuites/psxtests/psxhdrs/strings/strcasecmp_l.c
+++ b/testsuites/psxtests/psxhdrs/strings/strcasecmp_l.c
@@ -30,12 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _POSIX_C_SOURCE 200809L
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _POSIX_C_SOURCE 200809L
-
 #include <strings.h>
 #include <locale.h>
 
diff --git a/testsuites/psxtests/psxhdrs/sys/msg/msgctl.c b/testsuites/psxtests/psxhdrs/sys/msg/msgctl.c
index 5904df70aa..6ddd60dba3 100644
--- a/testsuites/psxtests/psxhdrs/sys/msg/msgctl.c
+++ b/testsuites/psxtests/psxhdrs/sys/msg/msgctl.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE
 #include <sys/msg.h> 
 
 int test( void );
diff --git a/testsuites/psxtests/psxhdrs/sys/msg/msgget.c b/testsuites/psxtests/psxhdrs/sys/msg/msgget.c
index 688002c75c..e8617987de 100644
--- a/testsuites/psxtests/psxhdrs/sys/msg/msgget.c
+++ b/testsuites/psxtests/psxhdrs/sys/msg/msgget.c
@@ -30,12 +30,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE
-#include <sys/msg.h> 
+#include <sys/msg.h>
 
 int test( void );
 
diff --git a/testsuites/psxtests/psxhdrs/ucontext/makecontext.c b/testsuites/psxtests/psxhdrs/ucontext/makecontext.c
index 1149a2c52b..b180a8e55c 100755
--- a/testsuites/psxtests/psxhdrs/ucontext/makecontext.c
+++ b/testsuites/psxtests/psxhdrs/ucontext/makecontext.c
@@ -30,16 +30,17 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE_EXTENDED 1
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define STACK_SIZE (1<<15) // 32KiB
-
-#define _XOPEN_SOURCE_EXTENDED 1
 #include <ucontext.h>
 #include <stdlib.h>
 
+#define STACK_SIZE (1<<15) // 32KiB
+
 int test( void );
 void func( void );
 
@@ -63,4 +64,4 @@ int test( void )
 void func( void )
 {
 	return;
-}
\ No newline at end of file
+}
diff --git a/testsuites/psxtests/psxhdrs/ucontext/setcontext.c b/testsuites/psxtests/psxhdrs/ucontext/setcontext.c
index d2f2848d96..3f8cd6328f 100755
--- a/testsuites/psxtests/psxhdrs/ucontext/setcontext.c
+++ b/testsuites/psxtests/psxhdrs/ucontext/setcontext.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE_EXTENDED 1
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE_EXTENDED 1
 #include <ucontext.h>
 
 int return_value = 0;
@@ -54,4 +55,4 @@ void func( void )
 {
     setcontext(ucp);
     return_value = 1;
-}
\ No newline at end of file
+}
diff --git a/testsuites/psxtests/psxhdrs/wchar/wcswidth.c b/testsuites/psxtests/psxhdrs/wchar/wcswidth.c
index 2f122d5084..1657687b88 100644
--- a/testsuites/psxtests/psxhdrs/wchar/wcswidth.c
+++ b/testsuites/psxtests/psxhdrs/wchar/wcswidth.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE
 #include <wchar.h>
 
 int test(void);
diff --git a/testsuites/psxtests/psxhdrs/wchar/wcwidth.c b/testsuites/psxtests/psxhdrs/wchar/wcwidth.c
index 9805b97844..75c215717d 100644
--- a/testsuites/psxtests/psxhdrs/wchar/wcwidth.c
+++ b/testsuites/psxtests/psxhdrs/wchar/wcwidth.c
@@ -30,11 +30,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _XOPEN_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#define _XOPEN_SOURCE
 #include <wchar.h>
 
 int test(void);
diff --git a/testsuites/psxtests/psxthreadname01/init.c b/testsuites/psxtests/psxthreadname01/init.c
index 0269e971cd..ccc2ea1031 100644
--- a/testsuites/psxtests/psxthreadname01/init.c
+++ b/testsuites/psxtests/psxthreadname01/init.c
@@ -12,11 +12,12 @@
  * http://www.rtems.org/license/LICENSE.
  */
 
+#define _GNU_SOURCE
+
 #ifdef HAVE_CONFIG_H
-  #include "config.h"
+#include "config.h"
 #endif
 
-#define _GNU_SOURCE
 #include <errno.h>
 #include <pthread.h>
 #include <string.h>
diff --git a/testsuites/sptests/spscheduler01/init.c b/testsuites/sptests/spscheduler01/init.c
index 04d65fcdd0..f42e60c593 100644
--- a/testsuites/sptests/spscheduler01/init.c
+++ b/testsuites/sptests/spscheduler01/init.c
@@ -12,12 +12,12 @@
  * http://www.rtems.org/license/LICENSE.
  */
 
+#define _GNU_SOURCE
+
 #ifdef HAVE_CONFIG_H
-  #include "config.h"
+#include "config.h"
 #endif
 
-#define _GNU_SOURCE
-
 #include <rtems.h>
 #include <rtems/libcsupport.h>
 
-- 
2.16.4



More information about the devel mailing list