From 319563bf31bacc6d97ccc054b07b792c15f60c99 Mon Sep 17 00:00:00 2001 From: David Engraf Date: Thu, 18 Nov 2021 14:08:35 +0100 Subject: [PATCH] Do not include sys/syscall.h if not available Some platforms do not provide sys/syscall.h. The configure script already checks for the existance of the file. Include sys/syscall.h only in case HAVE_SYS_SYSCALL_H has been set. --- include/fileutils.h | 4 ++-- include/pidfd-utils.h | 4 ++-- lib/cpuset.c | 2 ++ lib/randutils.c | 2 +- schedutils/ionice.c | 2 ++ schedutils/sched_attr.h | 2 +- sys-utils/hwclock.c | 2 ++ 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/fileutils.h b/include/fileutils.h index 17ad429385..c36ce63537 100644 --- a/include/fileutils.h +++ b/include/fileutils.h @@ -77,7 +77,7 @@ static inline struct dirent *xreaddir(DIR *dp) return d; } -#if defined(__linux__) +#ifdef HAVE_SYS_SYSCALL_H # include # if defined(SYS_close_range) # include @@ -89,7 +89,7 @@ static inline int close_range(unsigned int first, unsigned int last, int flags) # endif # define HAVE_CLOSE_RANGE 1 # endif /* SYS_close_range */ -#endif /* __linux__ */ +#endif /* HAVE_SYS_SYSCALL_H */ extern void ul_close_all_fds(unsigned int first, unsigned int last); diff --git a/include/pidfd-utils.h b/include/pidfd-utils.h index 4a6c3a6044..eddede9767 100644 --- a/include/pidfd-utils.h +++ b/include/pidfd-utils.h @@ -1,7 +1,7 @@ #ifndef UTIL_LINUX_PIDFD_UTILS #define UTIL_LINUX_PIDFD_UTILS -#if defined(__linux__) +#ifdef HAVE_SYS_SYSCALL_H # include # if defined(SYS_pidfd_send_signal) && defined(SYS_pidfd_open) # include @@ -24,5 +24,5 @@ static inline int pidfd_open(pid_t pid, unsigned int flags) # define UL_HAVE_PIDFD 1 # endif /* SYS_pidfd_send_signal */ -#endif /* __linux__ */ +#endif /* HAVE_SYS_SYSCALL_H */ #endif /* UTIL_LINUX_PIDFD_UTILS */ diff --git a/lib/cpuset.c b/lib/cpuset.c index 2847db8530..9c3284c650 100644 --- a/lib/cpuset.c +++ b/lib/cpuset.c @@ -20,7 +20,9 @@ #include #include #include +#ifdef HAVE_SYS_SYSCALL_H #include +#endif #include "cpuset.h" #include "c.h" diff --git a/lib/randutils.c b/lib/randutils.c index 39edf4e789..2ffe9b4f06 100644 --- a/lib/randutils.c +++ b/lib/randutils.c @@ -13,7 +13,7 @@ #include #include #include -#ifdef __linux__ +#ifdef HAVE_SYS_SYSCALL_H #include #endif #include "c.h" diff --git a/schedutils/ionice.c b/schedutils/ionice.c index ae2c73ea5b..8be83dfe89 100644 --- a/schedutils/ionice.c +++ b/schedutils/ionice.c @@ -11,7 +11,9 @@ #include #include #include +#ifdef HAVE_SYS_SYSCALL_H #include +#endif #include #include "nls.h" diff --git a/schedutils/sched_attr.h b/schedutils/sched_attr.h index 39d8532a35..b7559434cc 100644 --- a/schedutils/sched_attr.h +++ b/schedutils/sched_attr.h @@ -68,7 +68,7 @@ # define SCHED_FLAG_UTIL_CLAMP_MAX 0x40 #endif -#if defined (__linux__) +#ifdef HAVE_SYS_SYSCALL_H # include #endif diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index 3609814723..ff148f62ac 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -71,7 +71,9 @@ #include #include #include +#ifdef HAVE_SYS_SYSCALL_H #include +#endif #include #include #include -- 2.47.3