From 4b60aafc1185164cf48a0627bc3b092c6a79b3bc Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 8 Nov 2018 08:18:12 -0400 Subject: Check for before including it Fixes #38. --- mtab.c | 7 +++++-- stat.h | 6 +++++- util.c | 10 +++++++--- util.h | 10 +++++++--- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/mtab.c b/mtab.c index a35641d..19c8331 100644 --- a/mtab.c +++ b/mtab.c @@ -20,11 +20,14 @@ #include #include #include -#include #include #include -#if __GLIBC__ || BFS_HAS_INCLUDE() +#if BFS_HAS_SYS_PARAM +# include +#endif + +#if BFS_HAS_MNTENT # define BFS_MNTENT 1 #elif BSD # define BFS_MNTINFO 1 diff --git a/stat.h b/stat.h index 2519ff3..dc24cb4 100644 --- a/stat.h +++ b/stat.h @@ -17,11 +17,15 @@ #ifndef BFS_STAT_H #define BFS_STAT_H -#include +#include "util.h" #include #include #include +#if BFS_HAS_SYS_PARAM +# include +#endif + /** * bfs_stat field bitmask. */ diff --git a/util.c b/util.c index 74f9d55..93f86ca 100644 --- a/util.c +++ b/util.c @@ -22,17 +22,21 @@ #include #include #include +#include #include #include #include -#include #include #include #include -#if __GLIBC__ || BFS_HAS_INCLUDE() +#if BFS_HAS_SYS_PARAM +# include +#endif + +#if BFS_HAS_SYS_SYSMACROS # include -#elif BFS_HAS_INCLUDE() +#elif BFS_HAS_SYS_MKDEV # include #endif diff --git a/util.h b/util.h index 920d6e9..413d289 100644 --- a/util.h +++ b/util.h @@ -17,7 +17,6 @@ #ifndef BFS_UTIL_H #define BFS_UTIL_H -#include "bftw.h" #include #include #include @@ -29,11 +28,16 @@ // Some portability concerns #ifdef __has_include -# define BFS_HAS_INCLUDE(header) __has_include(header) +# define BFS_HAS_INCLUDE(header, fallback) __has_include(header) #else -# define BFS_HAS_INCLUDE(header) false +# define BFS_HAS_INCLUDE(header, fallback) fallback #endif +#define BFS_HAS_MNTENT BFS_HAS_INCLUDE(, __GLIBC__) +#define BFS_HAS_SYS_MKDEV BFS_HAS_INCLUDE(, false) +#define BFS_HAS_SYS_PARAM BFS_HAS_INCLUDE(, true) +#define BFS_HAS_SYS_SYSMACROS BFS_HAS_INCLUDE(, __GLIBC__) + #if !defined(FNM_CASEFOLD) && defined(FNM_IGNORECASE) # define FNM_CASEFOLD FNM_IGNORECASE #endif -- cgit v1.2.3