diff options
author | Alex Richardson <arichardson@FreeBSD.org> | 2020-08-07 16:03:55 +0000 |
---|---|---|
committer | Alex Richardson <arichardson@FreeBSD.org> | 2020-08-07 16:03:55 +0000 |
commit | ec4deee4e4f2aef1b97d9424f25d04e91fd7dc10 (patch) | |
tree | 3febc852497d63cfd3b5951bb9df06bc36cc6c6d | |
parent | 88d241831d991f7c79242bf0bfe034541d373951 (diff) | |
download | src-ec4deee4e4f2aef1b97d9424f25d04e91fd7dc10.tar.gz src-ec4deee4e4f2aef1b97d9424f25d04e91fd7dc10.zip |
Fix cddl tools bootstrapping on macOS and Linux
Reviewed By: brooks
Differential Revision: https://reviews.freebsd.org/D25979
Notes
Notes:
svn path=/head/; revision=364022
-rw-r--r-- | cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c | 1 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h | 10 | ||||
-rw-r--r-- | sys/cddl/compat/opensolaris/sys/stat.h | 13 | ||||
-rw-r--r-- | sys/cddl/compat/opensolaris/sys/time.h | 1 | ||||
-rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h | 9 |
5 files changed, 31 insertions, 3 deletions
diff --git a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c index c35b1a526d21..f48c09cce0e2 100644 --- a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c +++ b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <sys/types.h> +#include <sys/endian.h> #include <sys/stat.h> #include <sys/mman.h> #include <sys/zmod.h> diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h b/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h index c8d272faa419..b7da16ac3ddd 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h @@ -38,6 +38,7 @@ #include <pthread.h> #include <sys/ccompile.h> +#include <sys/endian.h> #ifdef __cplusplus extern "C" { @@ -65,6 +66,15 @@ extern "C" { #define MIN(a, b) ((a) > (b) ? (b) : (a)) #endif +/* Sanity check for cross-build bootstrap tools */ +#if !defined(BYTE_ORDER) +#error "Missing BYTE_ORDER defines" +#elif !defined(_LITTLE_ENDIAN) +#error "Missing _LITTLE_ENDIAN defines" +#elif !defined(_BIG_ENDIAN) +#error "Missing _BIG_ENDIAN defines" +#endif + #define TRUE 1 #define FALSE 0 diff --git a/sys/cddl/compat/opensolaris/sys/stat.h b/sys/cddl/compat/opensolaris/sys/stat.h index d7301841d08b..05b9671789dd 100644 --- a/sys/cddl/compat/opensolaris/sys/stat.h +++ b/sys/cddl/compat/opensolaris/sys/stat.h @@ -32,11 +32,19 @@ #include_next <sys/stat.h> +/* + * When bootstrapping on Linux a stat64/fstat64 functions exists in both + * glibc and musl libc. To avoid compilation errors, use those functions instead + * of redefining them to stat/fstat. + * Similarly, macOS provides (deprecated) stat64 functions that we can use + * for now. + */ +#if !defined(__linux__) && !defined(__APPLE__) #define stat64 stat #define MAXOFFSET_T OFF_MAX -#ifndef _KERNEL +#if !defined(_KERNEL) #include <sys/disk.h> static __inline int @@ -51,6 +59,7 @@ fstat64(int fd, struct stat *sb) } return (ret); } -#endif +#endif /* !defined(_KERNEL) */ +#endif /* !defined(__linux__) && !defined(__APPLE__) */ #endif /* !_COMPAT_OPENSOLARIS_SYS_STAT_H_ */ diff --git a/sys/cddl/compat/opensolaris/sys/time.h b/sys/cddl/compat/opensolaris/sys/time.h index 64dd9bb9f918..5f51d08550f4 100644 --- a/sys/cddl/compat/opensolaris/sys/time.h +++ b/sys/cddl/compat/opensolaris/sys/time.h @@ -29,6 +29,7 @@ #ifndef _OPENSOLARIS_SYS_TIME_H_ #define _OPENSOLARIS_SYS_TIME_H_ +#include <sys/types.h> #include_next <sys/time.h> #define SEC 1 diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h b/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h index 675e4893aa1d..7b738c8b0d13 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h +++ b/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h @@ -46,8 +46,12 @@ extern "C" { /* * Disk blocks (sectors) and bytes. */ +#ifndef dtob #define dtob(DD) ((DD) << DEV_BSHIFT) +#endif +#ifndef btod #define btod(BB) (((BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) +#endif #define btodt(BB) ((BB) >> DEV_BSHIFT) #define lbtod(BB) (((offset_t)(BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) @@ -220,9 +224,12 @@ extern unsigned char bcd_to_byte[256]; /* * Macros for counting and rounding. */ +#ifndef howmany #define howmany(x, y) (((x)+((y)-1))/(y)) +#endif +#ifndef roundup #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) - +#endif /* * Macro to determine if value is a power of 2 */ |