summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2014-07-06 16:20:37 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2014-07-06 16:20:37 +0000
commit02cefe6a6a1bd9c0f80f48072215e2ba332b1a1c (patch)
treea908b6180608fde31e1d224b0d0c70920ac40ff7
parent399c1f5289953163a21f638fc464196d5317e96a (diff)
downloadFreeBSD-src-02cefe6a6a1bd9c0f80f48072215e2ba332b1a1c.zip
FreeBSD-src-02cefe6a6a1bd9c0f80f48072215e2ba332b1a1c.tar.gz
In case we ever support little-endian PowerPC (probably userland only),
avoid hardcoding endianness here.
-rw-r--r--sys/powerpc/include/endian.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/powerpc/include/endian.h b/sys/powerpc/include/endian.h
index bfca169..1ce1d31 100644
--- a/sys/powerpc/include/endian.h
+++ b/sys/powerpc/include/endian.h
@@ -39,8 +39,13 @@
/*
* Define the order of 32-bit words in 64-bit words.
*/
+#ifdef __LITTLE_ENDIAN__
+#define _QUAD_HIGHWORD 1
+#define _QUAD_LOWWORD 0
+#else
#define _QUAD_HIGHWORD 0
#define _QUAD_LOWWORD 1
+#endif
/*
* GCC defines _BIG_ENDIAN and _LITTLE_ENDIAN equal to __BIG_ENDIAN__
@@ -131,9 +136,16 @@ __bswap64_var(__uint64_t _x)
#define __bswap64(x) (__is_constant(x) ? __bswap64_const(x) : \
__bswap64_var(x))
+#ifdef __LITTLE_ENDIAN__
+#define __htonl(x) (__bswap32((__uint32_t)(x)))
+#define __htons(x) (__bswap16((__uint16_t)(x)))
+#define __ntohl(x) (__bswap32((__uint32_t)(x)))
+#define __ntohs(x) (__bswap16((__uint16_t)(x)))
+#else
#define __htonl(x) ((__uint32_t)(x))
#define __htons(x) ((__uint16_t)(x))
#define __ntohl(x) ((__uint32_t)(x))
#define __ntohs(x) ((__uint16_t)(x))
+#endif
#endif /* !_MACHINE_ENDIAN_H_ */
OpenPOWER on IntegriCloud