Skip to content

Commit 65b3158

Browse files
committed
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.
1 parent 291f34d commit 65b3158

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ check_include_files("sys/cdefs.h" HAVE_SYS_CDEFS_H)
159159
check_include_files("sys/guarded.h" HAVE_SYS_GUARDED_H)
160160
check_include_files("sys/stat.h" HAVE_SYS_STAT_H)
161161
check_include_files("sys/types.h" HAVE_SYS_TYPES_H)
162+
check_include_files("sys/sysmacros.h" HAVE_SYS_SYSMACROS_H)
162163
check_include_files("unistd.h" HAVE_UNISTD_H)
163164
check_include_files("objc/objc-internal.h" HAVE_OBJC)
164165

cmake/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@
188188
/* Define to 1 if you have the <sys/types.h> header file. */
189189
#cmakedefine01 HAVE_SYS_TYPES_H
190190

191+
/* Define to 1 if you have the <sys/sysmacros.h> header file. */
192+
#cmakedefine01 HAVE_SYS_SYSMACROS_H
193+
191194
/* Define to 1 if you have the <TargetConditionals.h> header file. */
192195
#cmakedefine HAVE_TARGETCONDITIONALS_H
193196

os/linux_base.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
#ifndef __OS_LINUX_BASE__
1414
#define __OS_LINUX_BASE__
1515

16+
#if __has_include(<config/config_ac.h>)
17+
#include <config/config_ac.h>
18+
#else
19+
#include <config/config.h>
20+
#endif
21+
22+
#if HAVE_SYS_SYSMACROS_H
23+
#include <sys/sysmacros.h>
24+
#endif
1625
#include <sys/param.h>
1726

1827
#if HAVE_SYS_CDEFS_H

0 commit comments

Comments
 (0)