From f4c948a9e9b616c4f133f9495dacb105e51b3e49 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 19 Aug 2014 11:16:41 -0700 Subject: [PATCH] Move the meat of into . This way it's a lot harder for us to screw up (since we should always be including anyway). Bug: 14659579 Change-Id: I23070fff3296b0d1c683bb5e3a6e214146327d53 --- libc/include/features.h | 9 ++------- libc/include/sched.h | 1 - libc/include/sys/cdefs.h | 18 ++++++++++++++++-- libc/include/sys/stat.h | 1 - libc/include/unistd.h | 2 +- libm/include/math.h | 1 - tests/getauxval_test.cpp | 1 - tests/time_test.cpp | 1 - tests/uchar_test.cpp | 1 - 9 files changed, 19 insertions(+), 16 deletions(-) diff --git a/libc/include/features.h b/libc/include/features.h index 52184a881..a279c7f0e 100644 --- a/libc/include/features.h +++ b/libc/include/features.h @@ -29,12 +29,7 @@ #ifndef _FEATURES_H_ #define _FEATURES_H_ -#if defined(_BSD_SOURCE) -# define __USE_BSD 1 -#endif - -#if defined(_GNU_SOURCE) -# define __USE_GNU 1 -#endif +/* Our macro fun is all in . */ +#include #endif /* _FEATURES_H_ */ diff --git a/libc/include/sched.h b/libc/include/sched.h index 76249506e..6155ab7ca 100644 --- a/libc/include/sched.h +++ b/libc/include/sched.h @@ -28,7 +28,6 @@ #ifndef _SCHED_H_ #define _SCHED_H_ -#include #include #include diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h index c3338234b..79d8bcad8 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -355,9 +355,23 @@ #define __RCSID(_s) /* nothing */ #define __SCCSID(_s) /* nothing */ +/* + * _BSD_SOURCE and _GNU_SOURCE are expected to be defined by callers before + * any standard header file is included. In those header files we test + * against __USE_BSD and __USE_GNU. glibc does this in but we + * 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. + */ +#if defined(_BSD_SOURCE) +# define __USE_BSD 1 +#endif + +#if defined(_GNU_SOURCE) +# define __USE_GNU 1 +#endif + /*- - * The following definitions are an extension of the behavior originally - * implemented in , but with a different level of granularity. * POSIX.1 requires that the macros we test be defined before any standard * header file is included. * diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index d6044aedc..b56ffa423 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -29,7 +29,6 @@ #ifndef _SYS_STAT_H_ #define _SYS_STAT_H_ -#include #include #include #include diff --git a/libc/include/unistd.h b/libc/include/unistd.h index c3e655e09..34ae2bcd1 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -25,10 +25,10 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + #ifndef _UNISTD_H_ #define _UNISTD_H_ -#include #include #include #include diff --git a/libm/include/math.h b/libm/include/math.h index a808d8d41..c51f3afa8 100644 --- a/libm/include/math.h +++ b/libm/include/math.h @@ -17,7 +17,6 @@ #ifndef _MATH_H_ #define _MATH_H_ -#include #include #include diff --git a/tests/getauxval_test.cpp b/tests/getauxval_test.cpp index 51c9db84e..b33115007 100644 --- a/tests/getauxval_test.cpp +++ b/tests/getauxval_test.cpp @@ -15,7 +15,6 @@ */ #include -#include #include // getauxval() was only added as of glibc version 2.16. diff --git a/tests/time_test.cpp b/tests/time_test.cpp index 241c4a0c4..c9ead8dbb 100644 --- a/tests/time_test.cpp +++ b/tests/time_test.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include diff --git a/tests/uchar_test.cpp b/tests/uchar_test.cpp index eca3c5ea4..c887f8abd 100644 --- a/tests/uchar_test.cpp +++ b/tests/uchar_test.cpp @@ -19,7 +19,6 @@ #if defined(__BIONIC__) #define HAVE_UCHAR 1 #elif defined(__GLIBC__) -#include #define HAVE_UCHAR __GLIBC_PREREQ(2, 16) #endif