diff options
Diffstat (limited to 'sys/powerpc/include/endian.h')
-rw-r--r-- | sys/powerpc/include/endian.h | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/sys/powerpc/include/endian.h b/sys/powerpc/include/endian.h index 4acd586..4bccc4e 100644 --- a/sys/powerpc/include/endian.h +++ b/sys/powerpc/include/endian.h @@ -58,8 +58,38 @@ #define BYTE_ORDER BIG_ENDIAN #endif /* !_POSIX_SOURCE */ -#ifndef _KERNEL -#include <sys/cdefs.h> -#endif /* _KERNEL */ +#ifdef __GNUC__ + +static __inline __uint16_t +__bswap16(__uint16_t _x) +{ + + return ((_x >> 8) | ((_x << 8) & 0xff00)); +} + +static __inline __uint32_t +__bswap32(__uint32_t _x) +{ + + return ((_x >> 24) | ((_x >> 8) & 0xff00) | ((_x << 8) & 0xff0000) | + ((_x << 24) & 0xff000000)); +} + +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))); +} + +#endif /* __GNUC__ */ + +#define __htonl(x) ((__uint32_t)(x)) +#define __htons(x) ((__uint16_t)(x)) +#define __ntohl(x) ((__uint32_t)(x)) +#define __ntohs(x) ((__uint16_t)(x)) #endif /* !_MACHINE_ENDIAN_H_ */ |