From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1QUu-0005Dv-ED for qemu-devel@nongnu.org; Fri, 01 Feb 2013 18:58:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1QUt-000450-53 for qemu-devel@nongnu.org; Fri, 01 Feb 2013 18:58:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1QUs-00044g-U3 for qemu-devel@nongnu.org; Fri, 01 Feb 2013 18:58:19 -0500 Message-ID: <510C5696.2010305@redhat.com> Date: Fri, 01 Feb 2013 16:58:14 -0700 From: Eric Blake MIME-Version: 1.0 References: <1359756196-5588-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1359756196-5588-1-git-send-email-pbonzini@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2SCQJEBALRNAWOCAPRCHC" 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: Paolo Bonzini Cc: blauwirbel@gmail.com, peter.maydell@linaro.org, qemu-devel@nongnu.org, sw@weilnetz.de This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2SCQJEBALRNAWOCAPRCHC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/01/2013 03:03 PM, Paolo Bonzini wrote: > We had two copies of a ffs function for longs with subtly different > semantics and, for the one in bitops.h, a confusing name: the result > was off-by-one compared to the library function ffsl. >=20 > Unify the functions into one, and solve the name problem by calling > the 0-based functions "bitops_ctzl" and "bitops_ctol" respectively. >=20 > This also fixes the build on platforms with ffsl, including Mac OS X > and Windows. >=20 > Signed-off-by: Paolo Bonzini > --- > =20 > /** > - * bitops_ffs - find first bit in word. > + * bitops_ctzl - count trailing zeroes in word. > * @word: The word to search > * > - * 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. > */ > -static unsigned long bitops_ffsl(unsigned long word) > +static unsigned long bitops_ctzl(unsigned long word) The C library ffsl() returns 'int', not 'unsigned long'. Given that your bitops_ctzl returns -1, does it make sense to fix this to return a signed type? > =20 > /** > - * ffz - find first zero in word. > + * cto - count trailing ones in word. > * @word: The word to search > * > - * Undefined if no zero exists, so code should check against ~0UL firs= t. > + * Returns -1 if all bit are set. > */ > -static inline unsigned long ffz(unsigned long word) > +static inline unsigned long bitops_ctol(unsigned long word) Likewise; if we are changing this name, should we also change the return type to be signed? However, the wrong return type doesn't impact any of the callers, and this time around, your conversion looks correct. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2SCQJEBALRNAWOCAPRCHC 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/ iQEcBAEBCAAGBQJRDFaWAAoJEKeha0olJ0NqLD4IAIN57475KQbiIamlso7FOwH9 QedGItz7pd9HAZMqB1+Qev5z1XBMOkPFyoG5HsggWxgsVKnYb/Hpm+Hu/o8r7tnS RxtogFcwcu6oFmhY4V9pUtLO+sG+QW68ijS34haxDlDtaBwXsPkmQ+zNjMI7Cv1+ hwuilkVgSvT7rO6pxJoDwSxWz3a6KhziHBVja9EYEmKJ/9+ETl9v4WEpivJhrO1j ttGhGtcSOPziIQfjQvvdMZrpWMWLvcha7lKz7XaIaBSnQSyZDrejtL5G7PqXzk2A L5LuJhEfvjWKF6pxHMaM6EM0+dMNwusc5FsLYnW2Wf5S8oreCeLh85NDwWXmmoM= =g1o9 -----END PGP SIGNATURE----- ------enig2SCQJEBALRNAWOCAPRCHC--