diff options
author | dfr <dfr@FreeBSD.org> | 2001-10-07 21:09:35 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 2001-10-07 21:09:35 +0000 |
commit | 0dc299a882ca014c8bbb02301d76215042fabb48 (patch) | |
tree | 3d0ac4033a918f7afada0558e1fa5e1d5d53e54f /sys/ia64/include | |
parent | 29c5c858fce0c57b6ec8d88ecac8c437e7eb7f31 (diff) | |
download | FreeBSD-src-0dc299a882ca014c8bbb02301d76215042fabb48.zip FreeBSD-src-0dc299a882ca014c8bbb02301d76215042fabb48.tar.gz |
Implement inline versions of ntohl etc.
Diffstat (limited to 'sys/ia64/include')
-rw-r--r-- | sys/ia64/include/endian.h | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/sys/ia64/include/endian.h b/sys/ia64/include/endian.h index 0ba53cd..b4b5a0b 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) |