From eecdfc2510754abac62c15133f94a814bae34ad4 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 2 Aug 2017 10:12:39 -0700 Subject: [PATCH] linux: update header used for `major` macro Newer versions of glibc indicate that they intend to move the major macro from sys/types.h to sys/sysmacros.h. Add a check for the header and include that earlier to ensure that the macro is provided by the newer header when available/possible. This avoids an unnecessary warning from the system headers. Because `config_ac.h` is not available at the right location, we cannot include the header to check whether the header is available. Rely on the compiler provided `__has_include` instead of the configure check. Adjust the inclusion of `sys/cdefs.h` accordingly. --- CMakeLists.txt | 1 - cmake/config.h.in | 3 --- os/linux_base.h | 5 ++++- private/private.h | 8 +++++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d9e470fe..0b7e55ec0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,7 +156,6 @@ check_include_files("stdint.h" HAVE_STDINT_H) check_include_files("stdlib.h" HAVE_STDLIB_H) check_include_files("string.h" HAVE_STRING_H) check_include_files("strings.h" HAVE_STRINGS_H) -check_include_files("sys/cdefs.h" HAVE_SYS_CDEFS_H) check_include_files("sys/guarded.h" HAVE_SYS_GUARDED_H) check_include_files("sys/stat.h" HAVE_SYS_STAT_H) check_include_files("sys/types.h" HAVE_SYS_TYPES_H) diff --git a/cmake/config.h.in b/cmake/config.h.in index 6696e9863..97c94cc8e 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -176,9 +176,6 @@ /* Define to 1 if you have the `sysconf' function. */ #cmakedefine01 HAVE_SYSCONF -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_SYS_CDEFS_H - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_GUARDED_H diff --git a/os/linux_base.h b/os/linux_base.h index c8b9cad7c..58b497148 100644 --- a/os/linux_base.h +++ b/os/linux_base.h @@ -13,9 +13,12 @@ #ifndef __OS_LINUX_BASE__ #define __OS_LINUX_BASE__ +#if __has_include() +#include +#endif #include -#if HAVE_SYS_CDEFS_H +#if __has_include() #include #endif diff --git a/private/private.h b/private/private.h index ed9f876cc..228ce2c19 100644 --- a/private/private.h +++ b/private/private.h @@ -28,7 +28,12 @@ #define __DISPATCH_PRIVATE__ #ifdef __APPLE__ +#include +#include #include +#include +#elif defined(__linux__) +#include #endif #if TARGET_OS_MAC @@ -39,9 +44,6 @@ #if HAVE_UNISTD_H #include #endif -#if HAVE_SYS_CDEFS_H -#include -#endif #include #if TARGET_OS_MAC #include