summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2014-05-05 13:42:36 +0200
committerDavid Disseldorp <ddiss@samba.org>2014-05-06 18:14:13 +0200
commit5bf6ed5ebd0dc5ecdc5bcfb1d4720e9251849adc (patch)
tree4a106cb3089b1112b27211e80de8de360fc7627e
parent401f555c28aee861385b75c371b5f44cded1d391 (diff)
downloadsamba-5bf6ed5ebd0dc5ecdc5bcfb1d4720e9251849adc.tar.gz
samba-5bf6ed5ebd0dc5ecdc5bcfb1d4720e9251849adc.tar.xz
samba-5bf6ed5ebd0dc5ecdc5bcfb1d4720e9251849adc.zip
byteorder: do not assume PowerPC is big-endian
byteorder.h currently uses reverse-indexing ASM instructions for little endian multi-byte storage/retrieval on PowerPC. With Power8 this is an incorrect assumption, as it can be big or little endian. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10590 Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
-rw-r--r--lib/util/byteorder.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/util/byteorder.h b/lib/util/byteorder.h
index 58cd68abf90..297be52ec3b 100644
--- a/lib/util/byteorder.h
+++ b/lib/util/byteorder.h
@@ -89,10 +89,12 @@ it also defines lots of intermediate macros, just ignore those :-)
/*
- on powerpc we can use the magic instructions to load/store
- in little endian
-*/
-#if (defined(__powerpc__) && defined(__GNUC__))
+ * On powerpc we can use the magic instructions to load/store in little endian.
+ * The instructions are reverse-indexing, so assume a big endian Power
+ * processor. Power8 can be big or little endian, so we need to explicitly
+ * check.
+ */
+#if (defined(__powerpc__) && defined(__GNUC__) && HAVE_BIG_ENDIAN)
static __inline__ uint16_t ld_le16(const uint16_t *addr)
{
uint16_t val;