Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Mar 2012 16:25:14 +0400
From:      Andrey Chernov <ache@FreeBSD.ORG>
To:        Dimitry Andric <dim@FreeBSD.ORG>
Cc:        svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG
Subject:   Re: svn commit: r233684 - head/sys/x86/include
Message-ID:  <20120330122514.GA48762@vniz.net>
In-Reply-To: <4F75A2E9.4040108@FreeBSD.org>
References:  <201203292331.q2TNVmwN014920@svn.freebsd.org> <20120330082528.GA47173@vniz.net> <4F75A2E9.4040108@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120330122514.GA48762>