From: Eric Blake <eblake@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: blauwirbel@gmail.com, Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org, sw@weilnetz.de
Subject: Re: [Qemu-devel] [PATCH v3] bitops: unify bitops_ffsl with the one in host-utils.h, call it bitops_ctzl
Date: Sat, 02 Feb 2013 08:11:16 -0700 [thread overview]
Message-ID: <510D2C94.2010605@redhat.com> (raw)
In-Reply-To: <CAFEAcA-_=KWcRLZOGPTQaJsnimpk9oW43s6hDEGz-5btyhbJCw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]
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.
>> */
>
> 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==0 was a definite possibility, so we DO have code that depends
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) == bitops_ctzl(var)+1.
Extending the equivalency for var==0 makes the function usable in the
most places.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
next prev parent reply other threads:[~2013-02-02 15:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-01 22:03 [Qemu-devel] [PATCH v3] bitops: unify bitops_ffsl with the one in host-utils.h, call it bitops_ctzl Paolo Bonzini
2013-02-01 23:58 ` Eric Blake
2013-02-02 10:13 ` Andreas Färber
2013-02-02 13:30 ` Peter Maydell
2013-02-02 15:11 ` Eric Blake [this message]
2013-02-03 3:47 ` Paolo Bonzini
2013-02-03 10:32 ` Peter Maydell
2013-02-03 16:15 ` Blue Swirl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=510D2C94.2010605@redhat.com \
--to=eblake@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).