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 <ryan@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #10621
This commit is contained in:
Matthew Macy
2020-07-28 13:02:49 -07:00
committed by GitHub
parent 3eabed74c0
commit 5678d3f593
23 changed files with 99 additions and 240 deletions
-1
View File
@@ -14,7 +14,6 @@ KERNEL_H = \
dirent.h \
disp.h \
dkio.h \
endian.h \
extdirent.h \
file.h \
freebsd_rwlock.h \
+2 -2
View File
@@ -60,7 +60,7 @@
/*
* Macros to convert from a specific byte order to/from native byte order
*/
#if BYTE_ORDER == BIG_ENDIAN
#if BYTE_ORDER == _BIG_ENDIAN
#define BE_8(x) BMASK_8(x)
#define BE_16(x) BMASK_16(x)
#define BE_32(x) BMASK_32(x)
@@ -80,7 +80,7 @@
#define BE_64(x) BSWAP_64(x)
#endif
#if BYTE_ORDER == BIG_ENDIAN
#if BYTE_ORDER == _BIG_ENDIAN
#define htonll(x) BMASK_64(x)
#define ntohll(x) BMASK_64(x)
#else
-42
View File
@@ -1,42 +0,0 @@
/*
* Copyright (c) 2020 iXsystems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _SPL_SYS_ENDIAN_H_
#define _SPL_SYS_ENDIAN_H_
#undef _MACHINE_ENDIAN_H_
#include_next<sys/endian.h>
#if BYTE_ORDER == LITTLE_ENDIAN
#undef _BIG_ENDIAN
#undef BIG_ENDIAN
#define BIG_ENDIAN 4321
#endif
#endif /* _SPL_SYS_ENDIAN_H_ */
+9
View File
@@ -27,6 +27,7 @@
#ifndef _SYS_ISA_DEFS_H
#define _SYS_ISA_DEFS_H
#include <sys/endian.h>
/*
* This header file serves to group a set of well known defines and to
@@ -696,6 +697,14 @@ extern "C" {
#error "Both _ILP32 and _LP64 are defined"
#endif
#if BYTE_ORDER == _BIG_ENDIAN
#define _ZFS_BIG_ENDIAN
#elif BYTE_ORDER == _LITTLE_ENDIAN
#define _ZFS_LITTLE_ENDIAN
#else
#error "unknown byte order"
#endif
#ifdef __cplusplus
}
#endif