diff options
| author | Mike Barcroft <mike@FreeBSD.org> | 2002-03-09 21:02:16 +0000 |
|---|---|---|
| committer | Mike Barcroft <mike@FreeBSD.org> | 2002-03-09 21:02:16 +0000 |
| commit | d846855da8c8142a2f647f7a4c6949b341261297 (patch) | |
| tree | 1d205aa43b36510bc014a26a35c058748d42812d /sys/alpha/include | |
| parent | 95651ec70e9de909fe21953e81fcd778e9bae3a2 (diff) | |
Notes
Diffstat (limited to 'sys/alpha/include')
| -rw-r--r-- | sys/alpha/include/endian.h | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sys/alpha/include/endian.h b/sys/alpha/include/endian.h index 28f7dd0bb846..6781cedaf360 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_ */ |
