Skip to content

Commit 2122e1d

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. 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.
1 parent 8cd5324 commit 2122e1d

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ check_include_files("stdint.h" HAVE_STDINT_H)
156156
check_include_files("stdlib.h" HAVE_STDLIB_H)
157157
check_include_files("string.h" HAVE_STRING_H)
158158
check_include_files("strings.h" HAVE_STRINGS_H)
159-
check_include_files("sys/cdefs.h" HAVE_SYS_CDEFS_H)
160159
check_include_files("sys/guarded.h" HAVE_SYS_GUARDED_H)
161160
check_include_files("sys/stat.h" HAVE_SYS_STAT_H)
162161
check_include_files("sys/types.h" HAVE_SYS_TYPES_H)

cmake/config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@
176176
/* Define to 1 if you have the `sysconf' function. */
177177
#cmakedefine01 HAVE_SYSCONF
178178

179-
/* Define to 1 if you have the <sys/cdefs.h> header file. */
180-
#cmakedefine01 HAVE_SYS_CDEFS_H
181-
182179
/* Define to 1 if you have the <sys/guarded.h> header file. */
183180
#cmakedefine HAVE_SYS_GUARDED_H
184181

os/linux_base.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
#ifndef __OS_LINUX_BASE__
1414
#define __OS_LINUX_BASE__
1515

16+
#if __has_include(<sys/sysmacros.h>)
17+
#include <sys/sysmacros.h>
18+
#endif
1619
#include <sys/param.h>
1720

18-
#if HAVE_SYS_CDEFS_H
21+
#if __has_include(<sys/cdefs.h>)
1922
#include <sys/cdefs.h>
2023
#endif
2124

private/private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#if HAVE_UNISTD_H
4040
#include <unistd.h>
4141
#endif
42-
#if HAVE_SYS_CDEFS_H
42+
#if __has_include(<sys/cdefs.h>)
4343
#include <sys/cdefs.h>
4444
#endif
4545
#include <pthread.h>

0 commit comments

Comments
 (0)