From e28635396a8f7663aae83f66d187037f105b3d1d Mon Sep 17 00:00:00 2001 From: Alexander Richardson Date: Fri, 4 Sep 2020 04:06:03 +0100 Subject: [PATCH] Fixes for running FreeBSD buildworld on Linux/macOS hosts Adding an #ifdef __FreeBSD__ to a FreeBSD-specific header may seem odd, but these headers are used on non-FreeBSD systems during the bootstrap tools phase. Originally submitted downstream as https://reviews.freebsd.org/D26193 Reviewed-by: Ryan Moeller Reviewed-by: Brian Behlendorf Signed-off-by: Alex Richardson Closes #10863 --- include/os/freebsd/spl/sys/ccompile.h | 5 ++++- lib/libspl/include/os/freebsd/sys/stat.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/os/freebsd/spl/sys/ccompile.h b/include/os/freebsd/spl/sys/ccompile.h index 7268bd1d73..bffe6d21e3 100644 --- a/include/os/freebsd/spl/sys/ccompile.h +++ b/include/os/freebsd/spl/sys/ccompile.h @@ -206,8 +206,10 @@ typedef int enum_t; #define __XSI_VISIBLE 1000 #endif #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0])) -#define open64 open #define mmap64 mmap +/* Note: this file can be used on linux/macOS when bootstrapping tools. */ +#if defined(__FreeBSD__) +#define open64 open #define pwrite64 pwrite #define ftruncate64 ftruncate #define lseek64 lseek @@ -217,6 +219,7 @@ typedef int enum_t; #define statfs64 statfs #define readdir64 readdir #define dirent64 dirent +#endif #define P2ALIGN(x, align) ((x) & -(align)) #define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1) #define P2ROUNDUP(x, align) ((((x) - 1) | ((align) - 1)) + 1) diff --git a/lib/libspl/include/os/freebsd/sys/stat.h b/lib/libspl/include/os/freebsd/sys/stat.h index 82c86262ff..07f9762f09 100644 --- a/lib/libspl/include/os/freebsd/sys/stat.h +++ b/lib/libspl/include/os/freebsd/sys/stat.h @@ -28,6 +28,8 @@ #include_next +/* Note: this file can be used on linux/macOS when bootstrapping tools. */ +#if defined(__FreeBSD__) #include /* for BLKGETSIZE64 */ #define stat64 stat @@ -68,4 +70,5 @@ fstat64_blk(int fd, struct stat64 *st) return (0); } +#endif /* defined(__FreeBSD__) */ #endif /* _LIBSPL_SYS_STAT_H */