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 -1
View File
@@ -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,
+2 -2
View File
@@ -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 */
+5 -5
View File
@@ -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;
+2 -4
View File
@@ -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 */
/*
+2 -2
View File
@@ -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))
+1 -1
View File
@@ -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