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 <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Closes #10863
This commit is contained in:
Alexander Richardson 2020-09-04 04:06:03 +01:00 committed by GitHub
parent ac6e5fb202
commit f3064162ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -206,8 +206,10 @@ typedef int enum_t;
#define __XSI_VISIBLE 1000 #define __XSI_VISIBLE 1000
#endif #endif
#define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0])) #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0]))
#define open64 open
#define mmap64 mmap #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 pwrite64 pwrite
#define ftruncate64 ftruncate #define ftruncate64 ftruncate
#define lseek64 lseek #define lseek64 lseek
@ -217,6 +219,7 @@ typedef int enum_t;
#define statfs64 statfs #define statfs64 statfs
#define readdir64 readdir #define readdir64 readdir
#define dirent64 dirent #define dirent64 dirent
#endif
#define P2ALIGN(x, align) ((x) & -(align)) #define P2ALIGN(x, align) ((x) & -(align))
#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1) #define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1)
#define P2ROUNDUP(x, align) ((((x) - 1) | ((align) - 1)) + 1) #define P2ROUNDUP(x, align) ((((x) - 1) | ((align) - 1)) + 1)

View File

@ -28,6 +28,8 @@
#include_next <sys/stat.h> #include_next <sys/stat.h>
/* Note: this file can be used on linux/macOS when bootstrapping tools. */
#if defined(__FreeBSD__)
#include <sys/mount.h> /* for BLKGETSIZE64 */ #include <sys/mount.h> /* for BLKGETSIZE64 */
#define stat64 stat #define stat64 stat
@ -68,4 +70,5 @@ fstat64_blk(int fd, struct stat64 *st)
return (0); return (0);
} }
#endif /* defined(__FreeBSD__) */
#endif /* _LIBSPL_SYS_STAT_H */ #endif /* _LIBSPL_SYS_STAT_H */