mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
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:
@@ -14,7 +14,6 @@ KERNEL_H = \
|
||||
dirent.h \
|
||||
disp.h \
|
||||
dkio.h \
|
||||
endian.h \
|
||||
extdirent.h \
|
||||
file.h \
|
||||
freebsd_rwlock.h \
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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_ */
|
||||
@@ -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
|
||||
|
||||
@@ -26,6 +26,15 @@
|
||||
#define _SPL_BYTEORDER_H
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#if defined(__BIG_ENDIAN) && !defined(_ZFS_BIG_ENDIAN)
|
||||
#define _ZFS_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#if defined(__LITTLE_ENDIAN) && !defined(_ZFS_LITTLE_ENDIAN)
|
||||
#define _ZFS_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#include <sys/isa_defs.h>
|
||||
|
||||
#define BSWAP_8(x) ((x) & 0xff)
|
||||
@@ -49,7 +58,7 @@
|
||||
#define BE_IN32(xa) \
|
||||
(((uint32_t)BE_IN16(xa) << 16) | BE_IN16((uint8_t *)(xa)+2))
|
||||
|
||||
#ifdef _BIG_ENDIAN
|
||||
#ifdef _ZFS_BIG_ENDIAN
|
||||
static __inline__ uint64_t
|
||||
htonll(uint64_t n)
|
||||
{
|
||||
|
||||
@@ -117,9 +117,9 @@
|
||||
#endif
|
||||
|
||||
#if defined(__ARMEL__) || defined(__AARCH64EL__)
|
||||
#define _LITTLE_ENDIAN
|
||||
#define _ZFS_LITTLE_ENDIAN
|
||||
#else
|
||||
#define _BIG_ENDIAN
|
||||
#define _ZFS_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -149,7 +149,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _BIG_ENDIAN
|
||||
#define _ZFS_BIG_ENDIAN
|
||||
#define _SUNOS_VTOC_16
|
||||
#define _ALIGNMENT_REQUIRED 1
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _BIG_ENDIAN
|
||||
#define _ZFS_BIG_ENDIAN
|
||||
|
||||
/*
|
||||
* Illumos doesn't define _ALIGNMENT_REQUIRED for s390, so default to 1
|
||||
@@ -177,9 +177,9 @@
|
||||
#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
|
||||
@@ -211,7 +211,7 @@
|
||||
#define __rv64g__
|
||||
#endif
|
||||
|
||||
#define _LITTLE_ENDIAN
|
||||
#define _ZFS_LITTLE_ENDIAN
|
||||
|
||||
#define _SUNOS_VTOC_16
|
||||
|
||||
@@ -243,20 +243,12 @@
|
||||
#define HAVE_EFFICIENT_UNALIGNED_ACCESS
|
||||
#endif
|
||||
|
||||
#if defined(__LITTLE_ENDIAN) && !defined(_LITTLE_ENDIAN)
|
||||
#define _LITTLE_ENDIAN __LITTLE_ENDIAN
|
||||
#if defined(_ZFS_LITTLE_ENDIAN) && defined(_ZFS_BIG_ENDIAN)
|
||||
#error "Both _ZFS_LITTLE_ENDIAN and _ZFS_BIG_ENDIAN are defined"
|
||||
#endif
|
||||
|
||||
#if defined(__BIG_ENDIAN) && !defined(_BIG_ENDIAN)
|
||||
#define _BIG_ENDIAN __BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#if defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN)
|
||||
#error "Both _LITTLE_ENDIAN and _BIG_ENDIAN are defined"
|
||||
#endif
|
||||
|
||||
#if !defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
|
||||
#error "Neither _LITTLE_ENDIAN or _BIG_ENDIAN are defined"
|
||||
#if !defined(_ZFS_LITTLE_ENDIAN) && !defined(_ZFS_BIG_ENDIAN)
|
||||
#error "Neither _ZFS_LITTLE_ENDIAN or _ZFS_BIG_ENDIAN are defined"
|
||||
#endif
|
||||
|
||||
#endif /* _SPL_ISA_DEFS_H */
|
||||
|
||||
Reference in New Issue
Block a user