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.
This commit is contained in:
Marius Strobl 2010-10-08 14:59:45 +00:00
parent ba76c33501
commit 1fe259cdd8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=213578

View file

@ -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)