svn commit: r233684 - head/sys/x86/include
Andrey Chernov
ache at FreeBSD.ORG
Fri Mar 30 12:25:18 UTC 2012
On Fri, Mar 30, 2012 at 02:11:21PM +0200, Dimitry Andric wrote:
> In case of the __bswapXX() macros, you can see that the argument to
> __bswapXX_gen() is first explicitly cast to an unsigned type, for
> example with __bswap32():
>
> #define __bswap32(x) \
> (__builtin_constant_p(x) ? \
> __bswap32_gen((__uint32_t)(x)) : __bswap32_var(x))
>
> Therefore, right shifting will not give any problems. For the call to
> __bswap32_var(), such casting is not needed, since the argument will be
> implicitly converted to __uint32_t.
>
> As Bruce has mentioned, you could add more explicit casts and additional
> parentheses, but those would be superfluous.
I mention right shift just as potential problem. I really want to target
casting vs. masking problem (masking provide more instructions).
bde@ already suggest the same thing I generally mean in more details in
his recent answer with the patch:
% + __bswap16_gen((__uint16_t)(x)) : __bswap16_var((__uint16_t)(x))))
--
http://ache.vniz.net/
More information about the svn-src-all
mailing list