aboutsummaryrefslogtreecommitdiff
path: root/sys/ia64/include/endian.h
diff options
context:
space:
mode:
authorDoug Rabson <dfr@FreeBSD.org>2001-10-07 21:09:35 +0000
committerDoug Rabson <dfr@FreeBSD.org>2001-10-07 21:09:35 +0000
commite4ef1eb79740a770d92e7f98c3a061c87da3c392 (patch)
tree3d0ac4033a918f7afada0558e1fa5e1d5d53e54f /sys/ia64/include/endian.h
parent3da32491065c484d29934fb36794ae721201b992 (diff)
downloadsrc-e4ef1eb79740a770d92e7f98c3a061c87da3c392.tar.gz
src-e4ef1eb79740a770d92e7f98c3a061c87da3c392.zip
Implement inline versions of ntohl etc.
Notes
Notes: svn path=/head/; revision=84638
Diffstat (limited to 'sys/ia64/include/endian.h')
-rw-r--r--sys/ia64/include/endian.h36
1 files changed, 33 insertions, 3 deletions
diff --git a/sys/ia64/include/endian.h b/sys/ia64/include/endian.h
index 0ba53cd0e986..b4b5a0be3bf5 100644
--- a/sys/ia64/include/endian.h
+++ b/sys/ia64/include/endian.h
@@ -66,9 +66,6 @@ __uint32_t htonl __P((__uint32_t));
__uint16_t htons __P((__uint16_t));
__uint32_t ntohl __P((__uint32_t));
__uint16_t ntohs __P((__uint16_t));
-__uint16_t bswap16 __P((__uint16_t));
-__uint32_t bswap32 __P((__uint32_t));
-__uint64_t bswap64 __P((__uint64_t));
__END_DECLS
/*
@@ -87,6 +84,39 @@ __END_DECLS
#else
+#ifdef __GNUC__
+
+static __inline __uint64_t
+__uint8_swap_uint64(__uint64_t __x)
+{
+ __uint64_t __r;
+ __asm __volatile("mux1 %0=%1,@rev"
+ : "=r" (__r) : "r"(__x));
+ return __r;
+}
+
+static __inline __uint32_t
+__uint8_swap_uint32(__uint32_t __x)
+{
+ return __uint8_swap_uint64(__x) >> 32;
+}
+
+static __inline __uint16_t
+__uint8_swap_uint16(__uint16_t __x)
+{
+ return __uint8_swap_uint64(__x) >> 48;
+}
+
+/*
+ * Macros for network/external number representation conversion.
+ */
+#define ntohl __uint8_swap_uint32
+#define ntohs __uint8_swap_uint16
+#define htonl __uint8_swap_uint32
+#define htons __uint8_swap_uint16
+
+#endif /* __GNUC__ */
+
#define NTOHL(x) (x) = ntohl((__uint32_t)x)
#define NTOHS(x) (x) = ntohs((__uint16_t)x)
#define HTONL(x) (x) = htonl((__uint32_t)x)