From: "H. Peter Anvin" <hpa@zytor.com>
To: "Robert P. J. Day" <rpjday@mindspring.com>
Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>,
Nick Piggin <nickpiggin@yahoo.com.au>,
Linux kernel mailing list <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>, Paul Mackerras <paulus@samba.org>,
dhowells@redhat.com, galak@kernel.crashing.org
Subject: Re: [PATCH] Add "is_power_of_2" checking to log2.h.
Date: Mon, 11 Jun 2007 16:11:18 -0700 [thread overview]
Message-ID: <466DD696.8080901@zytor.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0701300938580.24147@CPE00045a9c397f-CM001225dbafb6>
Robert P. J. Day wrote:
>
> seriously, though, there is the potential of breaking something with
> this change since you can see how there is some inconsistency in how
> it's done *now* just for powerpc which, in some places, defines its
> own versions of this:
>
> ./arch/ppc/mm/pgtable.c:
> #define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0))
> ./arch/ppc/syslib/ppc85xx_rio.c:
> #define is_power_of_2(x) (((x) & ((x) - 1)) == 0)
> ./arch/powerpc/mm/pgtable_32.c:
> #define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0))
>
> note how the first and third macros *won't* consider zero a power of
> two, while the second one *will*. hence the need for a single
> standard for all of this, just to play it safe.
>
I suspect the reason the test for zero was omitted is because the author
didn't want the extra cost (the test for zero needs an extra branch on a
lot of architectures.)
-hpa
next prev parent reply other threads:[~2007-06-11 23:15 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-30 11:06 [PATCH] Add "is_power_of_2" checking to log2.h Robert P. J. Day
2007-01-30 12:25 ` Nick Piggin
2007-01-30 12:56 ` Robert P. J. Day
2007-01-30 14:12 ` Jan Engelhardt
2007-01-30 14:45 ` Robert P. J. Day
2007-01-30 15:50 ` Jan Engelhardt
2007-01-30 16:00 ` Robert P. J. Day
2007-06-11 23:11 ` H. Peter Anvin [this message]
2007-01-31 10:13 ` Vegard Nossum
2007-01-31 10:47 ` Robert P. J. Day
2007-01-31 1:21 ` Nick Piggin
2007-01-31 7:20 ` Robert P. J. Day
2007-02-01 10:41 ` David Howells
2007-02-01 10:43 ` David Howells
2007-02-01 10:49 ` Robert P. J. Day
2007-02-01 12:39 ` Tim Schmielau
2007-02-01 20:17 ` Valdis.Kletnieks
2007-02-01 21:55 ` Tim Schmielau
2007-02-20 15:29 ` Mariusz Kozlowski
2007-02-20 15:56 ` Kumar Gala
2007-02-20 16:14 ` Mariusz Kozlowski
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=466DD696.8080901@zytor.com \
--to=hpa@zytor.com \
--cc=akpm@osdl.org \
--cc=dhowells@redhat.com \
--cc=galak@kernel.crashing.org \
--cc=jengelh@linux01.gwdg.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
--cc=paulus@samba.org \
--cc=rpjday@mindspring.com \
/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.