From owner-svn-src-all@FreeBSD.ORG Tue Feb 28 21:32:36 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 350E5106564A; Tue, 28 Feb 2012 21:32:36 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay012.isp.belgacom.be (mailrelay012.isp.belgacom.be [195.238.6.179]) by mx1.freebsd.org (Postfix) with ESMTP id 2559F8FC16; Tue, 28 Feb 2012 21:32:34 +0000 (UTC) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EAOhETU9bsWst/2dsb2JhbABDhSeuLIEIgXcBAQUjMxYKAxALDgYEKgICOR4GiB8Hpm2SGI0TDQ8CAj4UBgMChQgKPweCOoEWBKgw Received: from 45.107-177-91.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([91.177.107.45]) by relay.skynet.be with ESMTP; 28 Feb 2012 22:22:29 +0100 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.14.5/8.14.5) with ESMTP id q1SLMS6M006493; Tue, 28 Feb 2012 22:22:28 +0100 (CET) (envelope-from tijl@freebsd.org) From: Tijl Coosemans To: Dimitry Andric Date: Tue, 28 Feb 2012 22:22:20 +0100 User-Agent: KMail/1.13.7 (FreeBSD/10.0-CURRENT; KDE/4.7.3; i386; ; ) References: <201202281939.q1SJdtYr084858@svn.freebsd.org> <4F4D3F5D.70905@FreeBSD.org> In-Reply-To: <4F4D3F5D.70905@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1486186.v0UtTdUSRE"; protocol="application/pgp-signature"; micalg=pgp-sha256 Content-Transfer-Encoding: 7bit Message-Id: <201202282222.26343.tijl@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r232266 - in head/sys: amd64/include i386/include pc98/include x86/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Feb 2012 21:32:36 -0000 --nextPart1486186.v0UtTdUSRE Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Tuesday 28 February 2012 21:55:57 Dimitry Andric wrote: > On 2012-02-28 20:39, Tijl Coosemans wrote: >> Author: tijl >> Date: Tue Feb 28 19:39:54 2012 >> New Revision: 232266 >> URL: http://svn.freebsd.org/changeset/base/232266 >>=20 >> Log: >> Copy amd64 endian.h to x86 and merge with i386 endian.h. Replace >> amd64/i386/pc98 endian.h with stubs. >> =20 >> In __bswap64_const(x) the conflict between 0xffUL and 0xffULL has been >> resolved by reimplementing the macro in terms of __bswap32(x). As a si= de >> effect __bswap64_var(x) is now implemented using two bswap instruction= s on >> i386 and should be much faster. __bswap32_const(x) has been reimplemen= ted >> in terms of __bswap16(x) for consistency. > ... >> +#define __bswap32_const(_x) \ >> + (((__uint32_t)__bswap16(_x) << 16) | __bswap16((_x) >> 16)) >> + >> +#define __bswap32(_x) \ >> + (__builtin_constant_p(_x) ? \ >> + __bswap32_const((__uint32_t)(_x)) : __bswap32_var(_x)) >> + >> +#define __bswap64_const(_x) \ >> + (((__uint64_t)__bswap32(_x) << 32) | __bswap32((_x) >> 32)) >=20 > Hmm, shouldn't __bswap32_const() be implemented in terms of > __bswap16_const(), and similarly for __bswap64_const(), which should be > implemented in terms of __bswap32_const()? >=20 > The whole reason for the difficult dance with __builtin_constant_p is to > allow for compile-time resolving of bswap'd constants. Invoking the > regular __bswap() macros doesn't gain you anything here. __bswap64_const is also used in __bswap64_var, so its argument isn't always a compile time constant and then __bswap32 becomes __bswap32_var. If it is a constant __bswap32 becomes __bswap32_const (even at -O0). --nextPart1486186.v0UtTdUSRE Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iF4EABEIAAYFAk9NRZIACgkQfoCS2CCgtitN6AD8DQEnzXs8/yF/R0V/q8r/QqKT 4LPpT2qnabaPO9u4XPkA/2THbeoN9I7c1DAty5t4EBlZw31uf8dThiNUkl1d5HIq =XmI7 -----END PGP SIGNATURE----- --nextPart1486186.v0UtTdUSRE--