summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorMatthew Macy <[email protected]>2020-07-28 13:02:49 -0700
committerGitHub <[email protected]>2020-07-28 13:02:49 -0700
commit5678d3f59389a241c8d9c032513c38209bb53e70 (patch)
treeb25aa376cb42cc0bb173ab1250e27dccc98b4de7 /module
parent3eabed74c0fca5dd9f96d2cca13c4a1a16d5c094 (diff)
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Matt Macy <[email protected]> Closes #10621
Diffstat (limited to 'module')
-rw-r--r--module/Makefile.bsd2
-rw-r--r--module/icp/algs/aes/aes_impl_generic.c2
-rw-r--r--module/icp/algs/edonr/edonr_byteorder.h4
-rw-r--r--module/icp/algs/modes/ccm.c10
-rw-r--r--module/icp/algs/sha1/sha1.c6
-rw-r--r--module/icp/algs/sha2/sha2.c4
-rw-r--r--module/icp/algs/skein/skein_port.h2
-rw-r--r--module/nvpair/nvpair.c8
-rw-r--r--module/unicode/uconv.c2
-rw-r--r--module/zfs/lz4.c2
-rw-r--r--module/zfs/vdev_raidz_math_powerpc_altivec.c2
11 files changed, 22 insertions, 22 deletions
diff --git a/module/Makefile.bsd b/module/Makefile.bsd
index 517054b0e..76889770c 100644
--- a/module/Makefile.bsd
+++ b/module/Makefile.bsd
@@ -29,7 +29,7 @@ CFLAGS+= -include ${INCDIR}/os/freebsd/spl/sys/ccompile.h
CFLAGS+= -D__KERNEL__ -DFREEBSD_NAMECACHE -DBUILDING_ZFS -D__BSD_VISIBLE=1
CFLAGS+= -DHAVE_UIO_ZEROCOPY -DWITHOUT_NETDUMP -D__KERNEL -D_SYS_CONDVAR_H_
-CFLAGS+= -D_SYS_VMEM_H_ -D_MACHINE_ENDIAN_H_ -DKDTRACE_HOOKS -DSMP
+CFLAGS+= -D_SYS_VMEM_H_ -DKDTRACE_HOOKS -DSMP
.if ${MACHINE_ARCH} == "amd64"
CFLAGS+= -DHAVE_AVX2 -DHAVE_AVX -D__x86_64 -DHAVE_SSE2 -DHAVE_AVX512F -DHAVE_SSSE3
diff --git a/module/icp/algs/aes/aes_impl_generic.c b/module/icp/algs/aes/aes_impl_generic.c
index a3b75dbf3..427c096c6 100644
--- a/module/icp/algs/aes/aes_impl_generic.c
+++ b/module/icp/algs/aes/aes_impl_generic.c
@@ -1233,7 +1233,7 @@ const aes_impl_ops_t aes_generic_impl = {
.encrypt = &aes_generic_encrypt,
.decrypt = &aes_generic_decrypt,
.is_supported = &aes_generic_will_work,
-#if defined(_LITTLE_ENDIAN)
+#if defined(_ZFS_LITTLE_ENDIAN)
.needs_byteswap = B_TRUE,
#else
.needs_byteswap = B_FALSE,
diff --git a/module/icp/algs/edonr/edonr_byteorder.h b/module/icp/algs/edonr/edonr_byteorder.h
index 532dfd743..2b5d48287 100644
--- a/module/icp/algs/edonr/edonr_byteorder.h
+++ b/module/icp/algs/edonr/edonr_byteorder.h
@@ -52,10 +52,10 @@
#endif /* __BYTE_ORDER || BYTE_ORDER */
#if !defined(MACHINE_IS_BIG_ENDIAN) && !defined(MACHINE_IS_LITTLE_ENDIAN)
-#if defined(_BIG_ENDIAN) || defined(_MIPSEB)
+#if defined(_ZFS_BIG_ENDIAN) || defined(_MIPSEB)
#define MACHINE_IS_BIG_ENDIAN
#endif
-#if defined(_LITTLE_ENDIAN) || defined(_MIPSEL)
+#if defined(_ZFS_LITTLE_ENDIAN) || defined(_MIPSEL)
#define MACHINE_IS_LITTLE_ENDIAN
#endif
#endif /* !MACHINE_IS_BIG_ENDIAN && !MACHINE_IS_LITTLE_ENDIAN */
diff --git a/module/icp/algs/modes/ccm.c b/module/icp/algs/modes/ccm.c
index c927f0897..5d6507c49 100644
--- a/module/icp/algs/modes/ccm.c
+++ b/module/icp/algs/modes/ccm.c
@@ -107,13 +107,13 @@ ccm_mode_encrypt_contiguous_blocks(ccm_ctx_t *ctx, char *data, size_t length,
* Increment counter. Counter bits are confined
* to the bottom 64 bits of the counter block.
*/
-#ifdef _LITTLE_ENDIAN
+#ifdef _ZFS_LITTLE_ENDIAN
counter = ntohll(ctx->ccm_cb[1] & ctx->ccm_counter_mask);
counter = htonll(counter + 1);
#else
counter = ctx->ccm_cb[1] & ctx->ccm_counter_mask;
counter++;
-#endif /* _LITTLE_ENDIAN */
+#endif /* _ZFS_LITTLE_ENDIAN */
counter &= ctx->ccm_counter_mask;
ctx->ccm_cb[1] =
(ctx->ccm_cb[1] & ~(ctx->ccm_counter_mask)) | counter;
@@ -458,13 +458,13 @@ ccm_mode_decrypt_contiguous_blocks(ccm_ctx_t *ctx, char *data, size_t length,
* Increment counter.
* Counter bits are confined to the bottom 64 bits
*/
-#ifdef _LITTLE_ENDIAN
+#ifdef _ZFS_LITTLE_ENDIAN
counter = ntohll(ctx->ccm_cb[1] & ctx->ccm_counter_mask);
counter = htonll(counter + 1);
#else
counter = ctx->ccm_cb[1] & ctx->ccm_counter_mask;
counter++;
-#endif /* _LITTLE_ENDIAN */
+#endif /* _ZFS_LITTLE_ENDIAN */
counter &= ctx->ccm_counter_mask;
ctx->ccm_cb[1] =
(ctx->ccm_cb[1] & ~(ctx->ccm_counter_mask)) | counter;
@@ -684,7 +684,7 @@ ccm_format_initial_blocks(uchar_t *nonce, ulong_t nonceSize,
mask |= (1ULL << q);
}
-#ifdef _LITTLE_ENDIAN
+#ifdef _ZFS_LITTLE_ENDIAN
mask = htonll(mask);
#endif
aes_ctx->ccm_counter_mask = mask;
diff --git a/module/icp/algs/sha1/sha1.c b/module/icp/algs/sha1/sha1.c
index e4b7a0c8c..da34222c8 100644
--- a/module/icp/algs/sha1/sha1.c
+++ b/module/icp/algs/sha1/sha1.c
@@ -226,16 +226,14 @@ typedef uint32_t sha1word;
* careful programming can guarantee this for us.
*/
-#if defined(_BIG_ENDIAN)
+#if defined(_ZFS_BIG_ENDIAN)
#define LOAD_BIG_32(addr) (*(uint32_t *)(addr))
#elif defined(HAVE_HTONL)
#define LOAD_BIG_32(addr) htonl(*((uint32_t *)(addr)))
#else
-/* little endian -- will work on big endian, but slowly */
-#define LOAD_BIG_32(addr) \
- (((addr)[0] << 24) | ((addr)[1] << 16) | ((addr)[2] << 8) | (addr)[3])
+#define LOAD_BIG_32(addr) BE_32(*((uint32_t *)(addr)))
#endif /* _BIG_ENDIAN */
/*
diff --git a/module/icp/algs/sha2/sha2.c b/module/icp/algs/sha2/sha2.c
index 05a2e6ad1..75f6a3c1a 100644
--- a/module/icp/algs/sha2/sha2.c
+++ b/module/icp/algs/sha2/sha2.c
@@ -43,7 +43,7 @@
#define _RESTRICT_KYWD
-#ifdef _LITTLE_ENDIAN
+#ifdef _ZFS_LITTLE_ENDIAN
#include <sys/byteorder.h>
#define HAVE_HTONL
#endif
@@ -123,7 +123,7 @@ static uint8_t PADDING[128] = { 0x80, /* all zeros */ };
* careful programming can guarantee this for us.
*/
-#if defined(_BIG_ENDIAN)
+#if defined(_ZFS_BIG_ENDIAN)
#define LOAD_BIG_32(addr) (*(uint32_t *)(addr))
#define LOAD_BIG_64(addr) (*(uint64_t *)(addr))
diff --git a/module/icp/algs/skein/skein_port.h b/module/icp/algs/skein/skein_port.h
index 417ed7c4b..ce4353082 100644
--- a/module/icp/algs/skein/skein_port.h
+++ b/module/icp/algs/skein/skein_port.h
@@ -44,7 +44,7 @@
#include <sys/isa_defs.h> /* get endianness selection */
-#if defined(_BIG_ENDIAN)
+#if defined(_ZFS_BIG_ENDIAN)
/* here for big-endian CPUs */
#define SKEIN_NEED_SWAP (1)
#else
diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c
index 6c0261f08..20a58802f 100644
--- a/module/nvpair/nvpair.c
+++ b/module/nvpair/nvpair.c
@@ -2555,11 +2555,13 @@ nvlist_common(nvlist_t *nvl, char *buf, size_t *buflen, int encoding,
int err = 0;
nvstream_t nvs;
int nvl_endian;
-#ifdef _LITTLE_ENDIAN
+#if defined(_ZFS_LITTLE_ENDIAN)
int host_endian = 1;
-#else
+#elif defined(_ZFS_BIG_ENDIAN)
int host_endian = 0;
-#endif /* _LITTLE_ENDIAN */
+#else
+#error "No endian defined!"
+#endif /* _ZFS_LITTLE_ENDIAN */
nvs_header_t *nvh;
if (buflen == NULL || nvl == NULL ||
diff --git a/module/unicode/uconv.c b/module/unicode/uconv.c
index d812d5f96..fe84979d0 100644
--- a/module/unicode/uconv.c
+++ b/module/unicode/uconv.c
@@ -69,7 +69,7 @@
#define UCONV_OUT_ENDIAN_MASKS (UCONV_OUT_BIG_ENDIAN | UCONV_OUT_LITTLE_ENDIAN)
/* Native and reversed endian macros. */
-#ifdef _BIG_ENDIAN
+#ifdef _ZFS_BIG_ENDIAN
#define UCONV_IN_NAT_ENDIAN UCONV_IN_BIG_ENDIAN
#define UCONV_IN_REV_ENDIAN UCONV_IN_LITTLE_ENDIAN
#define UCONV_OUT_NAT_ENDIAN UCONV_OUT_BIG_ENDIAN
diff --git a/module/zfs/lz4.c b/module/zfs/lz4.c
index 52e527b02..4b46e6948 100644
--- a/module/zfs/lz4.c
+++ b/module/zfs/lz4.c
@@ -208,7 +208,7 @@ lz4_decompress_zfs(void *s_start, void *d_start, size_t s_len,
* Little Endian or Big Endian?
* Note: overwrite the below #define if you know your architecture endianness.
*/
-#if defined(_BIG_ENDIAN)
+#if defined(_ZFS_BIG_ENDIAN)
#define LZ4_BIG_ENDIAN 1
#else
/*
diff --git a/module/zfs/vdev_raidz_math_powerpc_altivec.c b/module/zfs/vdev_raidz_math_powerpc_altivec.c
index 88f2646ae..1db2c4cd3 100644
--- a/module/zfs/vdev_raidz_math_powerpc_altivec.c
+++ b/module/zfs/vdev_raidz_math_powerpc_altivec.c
@@ -225,7 +225,7 @@ const raidz_impl_ops_t vdev_raidz_powerpc_altivec_impl = {
#if defined(__powerpc__)
-#if defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN
+#if defined(_ZFS_LITTLE_ENDIAN) && _LITTLE_ENDIAN
/* BEGIN CSTYLED */
const uint8_t
__attribute__((aligned(256))) gf_clmul_mod_lt[4*256][16] = {