diff options
author | Marius Strobl <marius@FreeBSD.org> | 2010-10-08 14:59:45 +0000 |
---|---|---|
committer | Marius Strobl <marius@FreeBSD.org> | 2010-10-08 14:59:45 +0000 |
commit | 1fe259cdd8a337c837505117e508c485900fe65c (patch) | |
tree | aa427e02bcaa3cb8046e44f3c12b18a61bf680cf /sys/sparc64/include/endian.h | |
parent | ba76c33501ddc9fbf4533f00a7f22d6e65e72374 (diff) | |
download | src-1fe259cdd8a337c837505117e508c485900fe65c.tar.gz src-1fe259cdd8a337c837505117e508c485900fe65c.zip |
In the replacement text of the __bswapN_const() macros cast the argument
to the expected type so they work like the corresponding __bswapN_var()
functions and the compiler doesn't complain when arguments of different
width are passed.
Notes
Notes:
svn path=/head/; revision=213578
Diffstat (limited to 'sys/sparc64/include/endian.h')
-rw-r--r-- | sys/sparc64/include/endian.h | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/sys/sparc64/include/endian.h b/sys/sparc64/include/endian.h index 17447844ac44..2ca467e409fb 100644 --- a/sys/sparc64/include/endian.h +++ b/sys/sparc64/include/endian.h @@ -69,18 +69,20 @@ #define __is_constant(x) 0 #endif -#define __bswap16_const(x) ((((x) >> 8) & 0xff) | \ - (((x) << 8) & 0xff00)) -#define __bswap32_const(x) ((((x) >> 24) & 0xff) | \ - (((x) >> 8) & 0xff00) | (((x) << 8) & 0xff0000) | \ - (((x) << 24) & 0xff000000)) -#define __bswap64_const(x) ((((x) >> 56) & 0xff) | \ - (((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) & ((__uint64_t)0xff << 56))) +#define __bswap16_const(x) ((((__uint16_t)(x) >> 8) & 0xff) | \ + (((__uint16_t)(x) << 8) & 0xff00)) +#define __bswap32_const(x) ((((__uint32_t)(x) >> 24) & 0xff) | \ + (((__uint32_t)(x) >> 8) & 0xff00) | \ + (((__uint32_t)(x)<< 8) & 0xff0000) | \ + (((__uint32_t)(x) << 24) & 0xff000000)) +#define __bswap64_const(x) ((((__uint64_t)(x) >> 56) & 0xff) | \ + (((__uint64_t)(x) >> 40) & 0xff00) | \ + (((__uint64_t)(x) >> 24) & 0xff0000) | \ + (((__uint64_t)(x) >> 8) & 0xff000000) | \ + (((__uint64_t)(x) << 8) & ((__uint64_t)0xff << 32)) | \ + (((__uint64_t)(x) << 24) & ((__uint64_t)0xff << 40)) | \ + (((__uint64_t)(x) << 40) & ((__uint64_t)0xff << 48)) | \ + (((__uint64_t)(x) << 56) & ((__uint64_t)0xff << 56))) static __inline __uint16_t __bswap16_var(__uint16_t _x) |