From 5678d3f59389a241c8d9c032513c38209bb53e70 Mon Sep 17 00:00:00 2001 From: Matthew Macy Date: Tue, 28 Jul 2020 13:02:49 -0700 Subject: Prefix zfs internal endian checks with _ZFS FreeBSD defines _BIG_ENDIAN BIG_ENDIAN _LITTLE_ENDIAN LITTLE_ENDIAN on every architecture. Trying to do cross builds whilst hiding this from ZFS has proven extremely cumbersome. Reviewed-by: Ryan Moeller Reviewed-by: Brian Behlendorf Signed-off-by: Matt Macy Closes #10621 --- lib/libspl/include/sys/isa_defs.h | 50 ++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 16 deletions(-) (limited to 'lib/libspl/include/sys') diff --git a/lib/libspl/include/sys/isa_defs.h b/lib/libspl/include/sys/isa_defs.h index 4d2d909f3..6f242ea77 100644 --- a/lib/libspl/include/sys/isa_defs.h +++ b/lib/libspl/include/sys/isa_defs.h @@ -54,8 +54,8 @@ extern "C" { #endif #endif -#if !defined(_LITTLE_ENDIAN) -#define _LITTLE_ENDIAN +#if !defined(_ZFS_LITTLE_ENDIAN) +#define _ZFS_LITTLE_ENDIAN #endif #define _SUNOS_VTOC_16 @@ -76,8 +76,8 @@ extern "C" { #define _ILP32 #endif -#if !defined(_LITTLE_ENDIAN) -#define _LITTLE_ENDIAN +#if !defined(_ZFS_LITTLE_ENDIAN) +#define _ZFS_LITTLE_ENDIAN #endif #define _SUNOS_VTOC_16 @@ -107,6 +107,24 @@ extern "C" { #define _SUNOS_VTOC_16 #define HAVE_EFFICIENT_UNALIGNED_ACCESS +#if defined(__BYTE_ORDER) +#if defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN +#define _ZFS_BIG_ENDIAN +#elif defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN +#define _ZFS_LITTLE_ENDIAN +#endif +#elif defined(_BYTE_ORDER) +#if defined(_BIG_ENDIAN) && _BYTE_ORDER == _BIG_ENDIAN +#define _ZFS_BIG_ENDIAN +#elif defined(_LITTLE_ENDIAN) && _BYTE_ORDER == _LITTLE_ENDIAN +#define _ZFS_LITTLE_ENDIAN +#endif +#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) +#define _ZFS_BIG_ENDIAN +#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) +#define _ZFS_LITTLE_ENDIAN +#endif + /* arm arch specific defines */ #elif defined(__arm) || defined(__arm__) || defined(__aarch64__) @@ -129,9 +147,9 @@ extern "C" { #endif #if defined(__ARMEL__) || defined(__AARCH64EL__) -#define _LITTLE_ENDIAN +#define _ZFS_LITTLE_ENDIAN #else -#define _BIG_ENDIAN +#define _ZFS_BIG_ENDIAN #endif #define _SUNOS_VTOC_16 @@ -151,7 +169,7 @@ extern "C" { #define __sparc__ #endif -#define _BIG_ENDIAN +#define _ZFS_BIG_ENDIAN #define _SUNOS_VTOC_16 #if defined(__arch64__) @@ -176,16 +194,16 @@ extern "C" { #endif #endif -#define _BIG_ENDIAN +#define _ZFS_BIG_ENDIAN #define _SUNOS_VTOC_16 /* MIPS arch specific defines */ #elif defined(__mips__) #if defined(__MIPSEB__) -#define _BIG_ENDIAN +#define _ZFS_BIG_ENDIAN #elif defined(__MIPSEL__) -#define _LITTLE_ENDIAN +#define _ZFS_LITTLE_ENDIAN #else #error MIPS no endian specified #endif @@ -198,7 +216,7 @@ extern "C" { /* * RISC-V arch specific defines - * only RV64G (including atomic) LP64 is supported yetxi + * only RV64G (including atomic) LP64 is supported yet */ #elif defined(__riscv) && defined(_LP64) && _LP64 && \ defined(__riscv_atomic) && __riscv_atomic @@ -211,7 +229,7 @@ extern "C" { #define __rv64g__ #endif -#define _LITTLE_ENDIAN +#define _ZFS_LITTLE_ENDIAN #define _SUNOS_VTOC_16 @@ -231,12 +249,12 @@ extern "C" { #error "Neither _ILP32 or _LP64 are defined" #endif -#if defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN) -#error "Both _LITTLE_ENDIAN and _BIG_ENDIAN are defined" +#if defined(_ZFS_LITTLE_ENDIAN) && defined(_ZFS_BIG_ENDIAN) +#error "Both _ZFS_LITTLE_ENDIAN and _ZFS_BIG_ENDIAN are defined" #endif -#if !defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) -#error "Neither _LITTLE_ENDIAN nor _BIG_ENDIAN are defined" +#if !defined(_ZFS_LITTLE_ENDIAN) && !defined(_ZFS_BIG_ENDIAN) +#error "Neither _ZFS_LITTLE_ENDIAN nor _ZFS_BIG_ENDIAN are defined" #endif #ifdef __cplusplus -- cgit v1.2.3