Fix cddl tools bootstrapping on macOS and Linux

Reviewed By:	brooks
Differential Revision: https://reviews.freebsd.org/D25979
This commit is contained in:
Alex Richardson 2020-08-07 16:03:55 +00:00
parent 88d241831d
commit ec4deee4e4
5 changed files with 31 additions and 3 deletions

View File

@ -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>

View File

@ -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

View File

@ -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_ */

View File

@ -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

View File

@ -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
*/