From: Andrew Morton <akpm@linux-foundation.org>
To: "Robert P. J. Day" <rpjday@crashcourse.ca>
Cc: David Daney <ddaney@caviumnetworks.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Introduce a boolean "single_bit_set" function.
Date: Fri, 24 Apr 2009 10:46:51 -0700 [thread overview]
Message-ID: <20090424104651.7c751735.akpm@linux-foundation.org> (raw)
In-Reply-To: <alpine.LFD.2.00.0904240632240.16107@localhost.localdomain>
On Fri, 24 Apr 2009 06:40:39 -0400 (EDT) "Robert P. J. Day" <rpjday@crashcourse.ca> wrote:
> so it would be a simple matter to define the bit set boolean in
> terms of hweight_long(), yes? so what about, in bitops.h:
>
> static inline bool
> exactly_one_bit_set(unsigned long w)
> {
> return hweight_long(w) == 1;
> }
>
> static inline bool
> more_than_one_bit_set(unsigned long w)
> {
> return hweight_long(w) > 1;
> }
>
> or something to that effect, *if* people think it's worth it.
> obviously, none of the above is strictly necessary, but it would make
> a lot of code semantically cleaner.
>
Doing plain old
if (hweight32(foo) == 1)
(say) at the call sites quite clearly expresses what the code is trying
to do.
> rday
>
> p.s. i notice that, even in a single header file like bitops.h, there
> is a mixture of both "inline" and "__inline__". what's the
> recommended choice these days?
`inline'. Or uninline the function ;)
next prev parent reply other threads:[~2009-04-24 17:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-23 17:43 [PATCH] Introduce a boolean "single_bit_set" function Robert P. J. Day
2009-04-23 19:57 ` David Daney
2009-04-23 20:11 ` Robert P. J. Day
2009-04-23 23:57 ` Andrew Morton
2009-04-24 10:40 ` Robert P. J. Day
2009-04-24 17:46 ` Andrew Morton [this message]
2009-04-25 22:09 ` Robert P. J. Day
2009-06-29 18:15 ` Petr Tesarik
2009-06-29 18:50 ` Robert P. J. Day
2009-06-30 6:12 ` Petr Tesarik
2009-06-30 10:18 ` Robert P. J. Day
2009-04-24 13:51 ` Robert P. J. Day
2009-05-28 12:21 ` Petr Tesarik
2009-05-28 12:27 ` Robert P. J. Day
2009-05-28 12:32 ` Robert P. J. Day
2009-05-28 13:12 ` Petr Tesarik
2009-06-29 18:50 ` H. Peter Anvin
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=20090424104651.7c751735.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=ddaney@caviumnetworks.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rpjday@crashcourse.ca \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.