Received: from eggs.gnu.org ([208.118.235.92]:52567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1ekU-00039l-EY for qemu-devel@nongnu.org; Sat, 02 Feb 2013 10:11:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1ekS-0007cH-Fs for qemu-devel@nongnu.org; Sat, 02 Feb 2013 10:11:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50113) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1ekS-0007cB-7O for qemu-devel@nongnu.org; Sat, 02 Feb 2013 10:11:20 -0500 Message-ID: <510D2C94.2010605@redhat.com> Date: Sat, 02 Feb 2013 08:11:16 -0700 From: Eric Blake MIME-Version: 1.0 References: <1359756196-5588-1-git-send-email-pbonzini@redhat.com> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2LMITLKMRMLKOPPAGWSOJ" Subject: Re: [Qemu-devel] [PATCH v3] bitops: unify bitops_ffsl with the one in host-utils.h, call it bitops_ctzl List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: blauwirbel@gmail.com, Paolo Bonzini , qemu-devel@nongnu.org, sw@weilnetz.de This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2LMITLKMRMLKOPPAGWSOJ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/02/2013 06:30 AM, Peter Maydell wrote: >> - * Undefined if no bit exists, so code should check against 0 first. >> + * Returns -1 if no bit exists. Note that compared to the C library >> + * routine ffsl, this one returns one less. >> */ >=20 > Do any of our callers actually use the "-1 on 0 input" semantics? > (I guess that means "your new code you added" since the previous > callers all were happy with the undefined-on-zero semantics). Yes, Paolo's code was replacing: ffsl(var) - 1 with bitops_ctzl(var) where var=3D=3D0 was a definite possibility, so we DO have code that depe= nds on this semantic of returning -1. > It seems an odd choice, since I can see a justification for: > (a) "return number of bits in word" [every bit in the word is > a trailing zero in some sense] > (b) "undefined" [matches gcc builtin_ctz semantics] For all non-zero values of var, ffsl(var) =3D=3D bitops_ctzl(var)+1. Extending the equivalency for var=3D=3D0 makes the function usable in the= most places. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2LMITLKMRMLKOPPAGWSOJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRDSyUAAoJEKeha0olJ0NqEEEH/2YOBAs2shu71GwTOjBzRnZ1 9f4VM/duymaIzVRJX2vR32eu6W0bGzMhmAD1mjvRyMfT8G3CBAGZ7vvr11FAPCLH Bcl3h2dM/hBrnAz3WQVghpbGNX0rrjaI3lfWu1aUMrrQUXJffrGc1brpnGMuobFn dBuR+miUS4d1vrpV8pFpnZldixT+2q1qaYQ//ghP/Y58Fyj7sq67OGd/gX11WX2H oGXb5eSAFjp5hZ4i0TAu10fqLI6MC1h3zw88XZTrzWIcrt6q22cz3Po3bmmKipHE 87FTEL6aNaAWJ0RaEHTvsmtr5iUIFouBIdzrVFyv9IM2GEg5+YRQNQz56+MBUG0= =59FT -----END PGP SIGNATURE----- ------enig2LMITLKMRMLKOPPAGWSOJ--