summaryrefslogtreecommitdiffstats
path: root/sys/alpha/include/endian.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/alpha/include/endian.h')
-rw-r--r--sys/alpha/include/endian.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/sys/alpha/include/endian.h b/sys/alpha/include/endian.h
index 28f7dd0..6781ceda 100644
--- a/sys/alpha/include/endian.h
+++ b/sys/alpha/include/endian.h
@@ -46,11 +46,11 @@
#define _QUAD_HIGHWORD 1
#define _QUAD_LOWWORD 0
+#ifndef _POSIX_SOURCE
/*
* Definitions for byte order, according to byte significance from low
* address to high.
*/
-#ifndef _POSIX_SOURCE
#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
@@ -58,10 +58,18 @@
#define BYTE_ORDER LITTLE_ENDIAN
#endif /* !_POSIX_SOURCE */
-#ifdef _KERNEL
#ifdef __GNUC__
-#define _BSWAP32_DEFINED
+static __inline __uint64_t
+__bswap64(__uint64_t _x)
+{
+
+ return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
+ ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
+ ((_x << 24) & ((__uint64_t)0xff << 40)) |
+ ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
+}
+
static __inline __uint32_t
__bswap32(__uint32_t __x)
{
@@ -81,7 +89,6 @@ __bswap32(__uint32_t __x)
return (__r);
}
-#define _BSWAP16_DEFINED
static __inline __uint16_t
__bswap16(__uint16_t __x)
{
@@ -95,8 +102,11 @@ __bswap16(__uint16_t __x)
return (__r);
}
-#endif /* _KERNEL */
-
#endif /* __GNUC__ */
+#define __htonl(x) __bswap32(x)
+#define __htons(x) __bswap16(x)
+#define __ntohl(x) __bswap32(x)
+#define __ntohs(x) __bswap16(x)
+
#endif /* !_MACHINE_ENDIAN_H_ */
OpenPOWER on IntegriCloud