summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fsade.c8
-rw-r--r--src/fsade.h6
-rw-r--r--src/mtab.c4
-rw-r--r--src/stat.c2
-rw-r--r--src/stat.h2
-rw-r--r--src/util.c8
-rw-r--r--src/util.h97
-rw-r--r--src/xspawn.c2
8 files changed, 81 insertions, 48 deletions
diff --git a/src/fsade.c b/src/fsade.c
index 9e5374f..7a7201e 100644
--- a/src/fsade.c
+++ b/src/fsade.c
@@ -32,9 +32,9 @@
# include <sys/capability.h>
#endif
-#if BFS_HAS_SYS_EXTATTR
+#if BFS_USE_SYS_EXTATTR_H
# include <sys/extattr.h>
-#elif BFS_HAS_SYS_XATTR
+#elif BFS_USE_SYS_XATTR_H
# include <sys/xattr.h>
#endif
@@ -303,7 +303,7 @@ int bfs_check_xattrs(const struct BFTW *ftwbuf) {
const char *path = fake_at(ftwbuf);
ssize_t len;
-#if BFS_HAS_SYS_EXTATTR
+#if BFS_USE_SYS_EXTATTR_H
ssize_t (*extattr_list)(const char *, int, void*, size_t) =
ftwbuf->type == BFS_LNK ? extattr_list_link : extattr_list_file;
@@ -342,7 +342,7 @@ int bfs_check_xattr_named(const struct BFTW *ftwbuf, const char *name) {
const char *path = fake_at(ftwbuf);
ssize_t len;
-#if BFS_HAS_SYS_EXTATTR
+#if BFS_USE_SYS_EXTATTR_H
ssize_t (*extattr_get)(const char *, int, const char *, void*, size_t) =
ftwbuf->type == BFS_LNK ? extattr_get_link : extattr_get_file;
diff --git a/src/fsade.h b/src/fsade.h
index e964112..bd7fc5b 100644
--- a/src/fsade.h
+++ b/src/fsade.h
@@ -25,16 +25,16 @@
#include "util.h"
#include <stdbool.h>
-#define BFS_CAN_CHECK_ACL BFS_HAS_SYS_ACL
+#define BFS_CAN_CHECK_ACL BFS_USE_SYS_ACL_H
-#if !defined(BFS_CAN_CHECK_CAPABILITIES) && BFS_HAS_SYS_CAPABILITY && !__FreeBSD__
+#if !defined(BFS_CAN_CHECK_CAPABILITIES) && BFS_USE_SYS_CAPABILITY_H && !__FreeBSD__
# include <sys/capability.h>
# ifdef CAP_CHOWN
# define BFS_CAN_CHECK_CAPABILITIES true
# endif
#endif
-#define BFS_CAN_CHECK_XATTRS (BFS_HAS_SYS_EXTATTR || BFS_HAS_SYS_XATTR)
+#define BFS_CAN_CHECK_XATTRS (BFS_USE_SYS_EXTATTR_H || BFS_USE_SYS_XATTR_H)
struct BFTW;
diff --git a/src/mtab.c b/src/mtab.c
index adc3f58..a9f5b41 100644
--- a/src/mtab.c
+++ b/src/mtab.c
@@ -26,11 +26,11 @@
#include <string.h>
#include <sys/types.h>
-#if BFS_HAS_SYS_PARAM
+#if BFS_USE_SYS_PARAM_H
# include <sys/param.h>
#endif
-#if BFS_HAS_MNTENT
+#if BFS_USE_MNTENT_H
# define BFS_MNTENT 1
#elif BSD
# define BFS_MNTINFO 1
diff --git a/src/stat.c b/src/stat.c
index ab3282a..cc20697 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -24,7 +24,7 @@
#include <sys/types.h>
#include <sys/stat.h>
-#if BFS_HAS_SYS_PARAM
+#if BFS_USE_SYS_PARAM_H
# include <sys/param.h>
#endif
diff --git a/src/stat.h b/src/stat.h
index 55c75e9..f45302a 100644
--- a/src/stat.h
+++ b/src/stat.h
@@ -29,7 +29,7 @@
#include <sys/types.h>
#include <time.h>
-#if BFS_HAS_SYS_PARAM
+#if BFS_USE_SYS_PARAM_H
# include <sys/param.h>
#endif
diff --git a/src/util.c b/src/util.c
index b1a038a..bb2e1cc 100644
--- a/src/util.c
+++ b/src/util.c
@@ -31,17 +31,17 @@
#include <unistd.h>
#include <wchar.h>
-#if BFS_HAS_SYS_PARAM
+#if BFS_USE_SYS_PARAM_H
# include <sys/param.h>
#endif
-#if BFS_HAS_SYS_SYSMACROS
+#if BFS_USE_SYS_SYSMACROS_H
# include <sys/sysmacros.h>
-#elif BFS_HAS_SYS_MKDEV
+#elif BFS_USE_SYS_MKDEV_H
# include <sys/mkdev.h>
#endif
-#if BFS_HAS_UTIL
+#if BFS_USE_UTIL_H
# include <util.h>
#endif
diff --git a/src/util.h b/src/util.h
index ffa5bcc..0fbcdaa 100644
--- a/src/util.h
+++ b/src/util.h
@@ -43,49 +43,82 @@
#endif
#ifdef __has_include
-# define BFS_HAS_INCLUDE(header, fallback) __has_include(header)
-#else
-# define BFS_HAS_INCLUDE(header, fallback) fallback
-#endif
-#ifndef BFS_HAS_MNTENT
-# define BFS_HAS_MNTENT BFS_HAS_INCLUDE(<mntent.h>, __GLIBC__)
+#if __has_include(<mntent.h>)
+# define BFS_HAS_MNTENT_H true
#endif
-
-#ifndef BFS_HAS_PATHS
-# define BFS_HAS_PATHS BFS_HAS_INCLUDE(<paths.h>, true)
+#if __has_include(<paths.h>)
+# define BFS_HAS_PATHS_H true
#endif
-
-#ifndef BFS_HAS_SYS_ACL
-# define BFS_HAS_SYS_ACL BFS_HAS_INCLUDE(<sys/acl.h>, true)
+#if __has_include(<sys/acl.h>)
+# define BFS_HAS_SYS_ACL_H true
#endif
-
-#ifndef BFS_HAS_SYS_CAPABILITY
-# define BFS_HAS_SYS_CAPABILITY BFS_HAS_INCLUDE(<sys/capability.h>, __linux__)
+#if __has_include(<sys/capability.h>)
+# define BFS_HAS_SYS_CAPABILITY_H true
#endif
-
-#ifndef BFS_HAS_SYS_EXTATTR
-# define BFS_HAS_SYS_EXTATTR BFS_HAS_INCLUDE(<sys/extattr.h>, __FreeBSD__)
+#if __has_include(<sys/extattr.h>)
+# define BFS_HAS_SYS_EXTATTR_H true
#endif
-
-#ifndef BFS_HAS_SYS_MKDEV
-# define BFS_HAS_SYS_MKDEV BFS_HAS_INCLUDE(<sys/mkdev.h>, false)
+#if __has_include(<sys/mkdev.h>)
+# define BFS_HAS_SYS_MKDEV_H true
#endif
-
-#ifndef BFS_HAS_SYS_PARAM
-# define BFS_HAS_SYS_PARAM BFS_HAS_INCLUDE(<sys/param.h>, true)
+#if __has_include(<sys/param.h>)
+# define BFS_HAS_SYS_PARAM_H true
#endif
-
-#ifndef BFS_HAS_SYS_SYSMACROS
-# define BFS_HAS_SYS_SYSMACROS BFS_HAS_INCLUDE(<sys/sysmacros.h>, __GLIBC__)
+#if __has_include(<sys/sysmacros.h>)
+# define BFS_HAS_SYS_SYSMACROS_H true
#endif
-
-#ifndef BFS_HAS_SYS_XATTR
-# define BFS_HAS_SYS_XATTR BFS_HAS_INCLUDE(<sys/xattr.h>, __linux__)
+#if __has_include(<sys/xattr.h>)
+# define BFS_HAS_SYS_XATTR_H true
+#endif
+#if __has_include(<util.h>)
+# define BFS_HAS_UTIL_H true
#endif
-#ifndef BFS_HAS_UTIL
-# define BFS_HAS_UTIL BFS_HAS_INCLUDE(<util.h>, __NetBSD__)
+#else // !__has_include
+
+#define BFS_HAS_MNTENT_H __GLIBC__
+#define BFS_HAS_PATHS_H true
+#define BFS_HAS_SYS_ACL_H true
+#define BFS_HAS_SYS_CAPABILITY_H __linux__
+#define BFS_HAS_SYS_EXTATTR_H __FreeBSD__
+#define BFS_HAS_SYS_MKDEV_H false
+#define BFS_HAS_SYS_PARAM_H true
+#define BFS_HAS_SYS_SYSMACROS_H __GLIBC__
+#define BFS_HAS_SYS_XATTR_H __linux__
+#define BFS_HAS_UTIL_H __NetBSD__
+
+#endif // !__has_include
+
+#ifndef BFS_USE_MNTENT_H
+# define BFS_USE_MNTENT_H BFS_HAS_MNTENT_H
+#endif
+#ifndef BFS_USE_PATHS_H
+# define BFS_USE_PATHS_H BFS_HAS_PATHS_H
+#endif
+#ifndef BFS_USE_SYS_ACL_H
+# define BFS_USE_SYS_ACL_H BFS_HAS_SYS_ACL_H
+#endif
+#ifndef BFS_USE_SYS_CAPABILITY_H
+# define BFS_USE_SYS_CAPABILITY_H BFS_HAS_SYS_CAPABILITY_H
+#endif
+#ifndef BFS_USE_SYS_EXTATTR_H
+# define BFS_USE_SYS_EXTATTR_H BFS_HAS_SYS_EXTATTR_H
+#endif
+#ifndef BFS_USE_SYS_MKDEV_H
+# define BFS_USE_SYS_MKDEV_H BFS_HAS_SYS_MKDEV_H
+#endif
+#ifndef BFS_USE_SYS_PARAM_H
+# define BFS_USE_SYS_PARAM_H BFS_HAS_SYS_PARAM_H
+#endif
+#ifndef BFS_USE_SYS_SYSMACROS_H
+# define BFS_USE_SYS_SYSMACROS_H BFS_HAS_SYS_SYSMACROS_H
+#endif
+#ifndef BFS_USE_SYS_XATTR_H
+# define BFS_USE_SYS_XATTR_H BFS_HAS_SYS_XATTR_H
+#endif
+#ifndef BFS_USE_UTIL_H
+# define BFS_USE_UTIL_H BFS_HAS_UTIL_H
#endif
#ifndef __GLIBC_PREREQ
diff --git a/src/xspawn.c b/src/xspawn.c
index 43a6f1c..bcaeb35 100644
--- a/src/xspawn.c
+++ b/src/xspawn.c
@@ -24,7 +24,7 @@
#include <sys/wait.h>
#include <unistd.h>
-#if BFS_HAS_PATHS
+#if BFS_USE_PATHS_H
# include <paths.h>
#endif