diff options
-rw-r--r-- | sys/alpha/include/endian.h | 14 | ||||
-rw-r--r-- | sys/arm/include/endian.h | 2 | ||||
-rw-r--r-- | sys/i386/include/endian.h | 1 | ||||
-rw-r--r-- | sys/ia64/include/endian.h | 17 |
4 files changed, 18 insertions, 16 deletions
diff --git a/sys/alpha/include/endian.h b/sys/alpha/include/endian.h index 7906ea1..8d957a6 100644 --- a/sys/alpha/include/endian.h +++ b/sys/alpha/include/endian.h @@ -44,8 +44,8 @@ /* * Define the order of 32-bit words in 64-bit words. */ -#define _QUAD_HIGHWORD 1 -#define _QUAD_LOWWORD 0 +#define _QUAD_HIGHWORD 1 +#define _QUAD_LOWWORD 0 /* * Definitions for byte order, according to byte significance from low @@ -81,7 +81,7 @@ __bswap64(__uint64_t _x) } static __inline __uint32_t -__bswap32(__uint32_t __x) +__bswap32(__uint32_t _x) { __uint32_t __r; @@ -95,12 +95,12 @@ __bswap32(__uint32_t __x) "or $4, $1, %0\n\t" "or $2, $3, $2\n\t" "or $2, %0, %0" - : "=r" (__r) : "r" (__x) : "$1", "$2", "$3", "$4"); + : "=r" (__r) : "r" (_x) : "$1", "$2", "$3", "$4"); return (__r); } -static __inline __uint16_t -__bswap16(__uint16_t __x) +static __inline __uint16_t +__bswap16(__uint16_t _x) { __uint16_t __r; @@ -108,7 +108,7 @@ __bswap16(__uint16_t __x) "insbl %1, 1, $1\n\t" "extbl %1, 1, $2\n\t" "or $1, $2, %0" - : "=r" (__r) : "r" (__x) : "$1", "$2"); + : "=r" (__r) : "r" (_x) : "$1", "$2"); return (__r); } diff --git a/sys/arm/include/endian.h b/sys/arm/include/endian.h index 163491f..126ee9b 100644 --- a/sys/arm/include/endian.h +++ b/sys/arm/include/endian.h @@ -33,6 +33,6 @@ #ifndef _ENDIAN_H_ #define _ENDIAN_H_ -#define BYTE_ORDER LITTLE_ENDIAN +#define BYTE_ORDER _LITTLE_ENDIAN #endif /* !_ENDIAN_H_ */ diff --git a/sys/i386/include/endian.h b/sys/i386/include/endian.h index d686532..3ee77f5 100644 --- a/sys/i386/include/endian.h +++ b/sys/i386/include/endian.h @@ -97,6 +97,7 @@ __extension__ ({ register __uint16_t __X = (x); \ 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)) | diff --git a/sys/ia64/include/endian.h b/sys/ia64/include/endian.h index c3d42cc..3418eb7 100644 --- a/sys/ia64/include/endian.h +++ b/sys/ia64/include/endian.h @@ -44,8 +44,8 @@ /* * Define the order of 32-bit words in 64-bit words. */ -#define _QUAD_HIGHWORD 1 -#define _QUAD_LOWWORD 0 +#define _QUAD_HIGHWORD 1 +#define _QUAD_LOWWORD 0 /* * Definitions for byte order, according to byte significance from low @@ -71,26 +71,27 @@ #ifdef __GNUC__ static __inline __uint64_t -__bswap64(__uint64_t __x) +__bswap64(__uint64_t _x) { __uint64_t __r; + __asm __volatile("mux1 %0=%1,@rev" - : "=r" (__r) : "r"(__x)); + : "=r" (__r) : "r"(_x)); return __r; } static __inline __uint32_t -__bswap32(__uint32_t __x) +__bswap32(__uint32_t _x) { - return (__bswap64(__x) >> 32); + return (__bswap64(_x) >> 32); } static __inline __uint16_t -__bswap16(__uint16_t __x) +__bswap16(__uint16_t _x) { - return (__bswap64(__x) >> 48); + return (__bswap64(_x) >> 48); } #define __htonl(x) __bswap32(x) |