From: Eric Sandeen <sandeen@redhat.com>
To: xfs-oss <xfs@oss.sgi.com>
Subject: [PATCH] xfsprogs: fix crc32 build on big endian
Date: Fri, 04 Oct 2013 21:20:03 -0500 [thread overview]
Message-ID: <524F7753.8050801@redhat.com> (raw)
While kernelspace can test #ifdef __LITTLE_ENDIAN, this
doesn't work in userspace. __LITTLE_ENDIAN is defined -
as is __BIG_ENDIAN.
So we build on all boxes as __LITTLE_ENDIAN, and the
self-test (thankfully!) fails on big endian boxes.
Fix this by testing __BYTE_ORDER values.
And add an else which should never be hit, but just in case...
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/libxfs/crc32.c b/libxfs/crc32.c
index 1c0d958..0f847d2 100644
--- a/libxfs/crc32.c
+++ b/libxfs/crc32.c
@@ -63,18 +63,20 @@ typedef __u32 u64;
static inline u32
crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256])
{
-# ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
# define DO_CRC(x) crc = t0[(crc ^ (x)) & 255] ^ (crc >> 8)
# define DO_CRC4 (t3[(q) & 255] ^ t2[(q >> 8) & 255] ^ \
t1[(q >> 16) & 255] ^ t0[(q >> 24) & 255])
# define DO_CRC8 (t7[(q) & 255] ^ t6[(q >> 8) & 255] ^ \
t5[(q >> 16) & 255] ^ t4[(q >> 24) & 255])
-# else
+# elif __BYTE_ORDER == __BIG_ENDIAN
# define DO_CRC(x) crc = t0[((crc >> 24) ^ (x)) & 255] ^ (crc << 8)
# define DO_CRC4 (t0[(q) & 255] ^ t1[(q >> 8) & 255] ^ \
t2[(q >> 16) & 255] ^ t3[(q >> 24) & 255])
# define DO_CRC8 (t4[(q) & 255] ^ t5[(q >> 8) & 255] ^ \
t6[(q >> 16) & 255] ^ t7[(q >> 24) & 255])
+# else
+# error What endian are you?
# endif
const u32 *b;
size_t rem_len;
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2013-10-05 3:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-05 2:20 Eric Sandeen [this message]
2013-10-05 3:54 ` [PATCH] xfsprogs: fix crc32 build on big endian Dave Chinner
2013-10-18 17:19 ` Rich Johnston
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=524F7753.8050801@redhat.com \
--to=sandeen@redhat.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox