cyrus-imapd/patch-cyrus-fix-endianness-checks
Jason Tibbitts c6a7c0199c Fix enianness issues, enable more tests.
Both test suites are now run on all architectures.  A few Cassandane
tests need to be excluded on 32-bit and big-endian architectures, but
the built-in test suite passes in its entirety and the vast majority of
Cassandane runs just fine.
2017-06-02 16:50:48 -05:00

67 lines
2.2 KiB
Plaintext

diff --git a/lib/crc32.c b/lib/crc32.c
index c42e7d6..4193f0f 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -611,7 +611,7 @@ static const uint32_t crc32_lookup[16][256] =
}
};
-#ifndef LITTLE_ENDIAN
+#if BYTE_ORDER != LITTLE_ENDIAN
/* swap endianness */
static uint32_t swap(uint32_t x)
{
@@ -634,7 +634,7 @@ static uint32_t crc32_slice8(uint32_t prev, const void *data, size_t length)
/* process eight bytes at once (Slicing-by-8) */
while (length >= 8) {
-#ifdef LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
uint32_t one = *current++ ^ crc;
uint32_t two = *current++;
crc = crc32_lookup[0][(two>>24) & 0xFF] ^
@@ -682,7 +682,7 @@ static uint32_t crc32_slice16(uint32_t prev, const void *data, size_t length)
while (length >= bytes_at_once) {
size_t unrolling;
for (unrolling = 0; unrolling < unroll; unrolling++) {
-#ifdef LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
uint32_t one = *current++ ^ crc;
uint32_t two = *current++;
uint32_t three = *current++;
diff --git a/lib/crc32c.c b/lib/crc32c.c
index e33e793..66fc16e 100644
--- a/lib/crc32c.c
+++ b/lib/crc32c.c
@@ -591,7 +591,7 @@ static const uint32_t crc32c_lookup[4][256] = {
},
};
-#ifndef LITTLE_ENDIAN
+#if BYTE_ORDER != LITTLE_ENDIAN
/* swap endianness */
static uint32_t swap(uint32_t x)
{
@@ -615,7 +615,7 @@ static uint32_t crc32c_sw(uint32_t crc, const void *buf, size_t len) {
/* process four bytes at once (slicing-by-4) */
while (len >= 4) {
-#ifdef LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
crc1 = *cur++ ^ crc0;
crc0 = crc32c_lookup[0][(crc1>>24) & 0xff] ^
crc32c_lookup[1][(crc1>>16) & 0xff] ^
diff --git a/lib/xsha1.c b/lib/xsha1.c
index 1c4547e..6e41eee 100644
--- a/lib/xsha1.c
+++ b/lib/xsha1.c
@@ -89,7 +89,7 @@ struct _SHA_CTX {
/* blk0() and blk() perform the initial expand. */
/* I got the idea of expanding during the round function from SSLeay */
-#ifdef LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
#define blk0(i) (block->l[i] = (rol(block->l[i],24)&(sha1_quadbyte)0xFF00FF00) \
|(rol(block->l[i],8)&(sha1_quadbyte)0x00FF00FF))
#else