From owner-svn-src-head@FreeBSD.ORG Fri Mar 30 12:25:17 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C4A9C1065770; Fri, 30 Mar 2012 12:25:17 +0000 (UTC) (envelope-from ache@vniz.net) Received: from vniz.net (vniz.net [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 30DA78FC34; Fri, 30 Mar 2012 12:25:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vniz.net (8.14.5/8.14.5) with ESMTP id q2UCPFO8048826; Fri, 30 Mar 2012 16:25:15 +0400 (MSK) (envelope-from ache@vniz.net) Received: (from ache@localhost) by localhost (8.14.5/8.14.5/Submit) id q2UCPFo6048825; Fri, 30 Mar 2012 16:25:15 +0400 (MSK) (envelope-from ache) Date: Fri, 30 Mar 2012 16:25:14 +0400 From: Andrey Chernov To: Dimitry Andric Message-ID: <20120330122514.GA48762@vniz.net> Mail-Followup-To: Andrey Chernov , Dimitry Andric , src-committers@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, svn-src-head@FreeBSD.ORG References: <201203292331.q2TNVmwN014920@svn.freebsd.org> <20120330082528.GA47173@vniz.net> <4F75A2E9.4040108@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F75A2E9.4040108@FreeBSD.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG Subject: Re: svn commit: r233684 - head/sys/x86/include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Mar 2012 12:25:18 -0000 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/