public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: "Robert P. J. Day" <rpjday@mindspring.com>
Cc: 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: Tue, 30 Jan 2007 23:25:56 +1100	[thread overview]
Message-ID: <45BF3954.8050106@yahoo.com.au> (raw)
In-Reply-To: <Pine.LNX.4.64.0701300543420.17991@CPE00045a9c397f-CM001225dbafb6>

Robert P. J. Day wrote:
>   Add the inline function "is_power_of_2()" to log2.h, where the value
> zero is *not* considered to be a power of two.

> 
> Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
> 
>  /*
> + *  Determine whether some value is a power of two, where zero is
> + * *not* considered a power of two.
> + */

Why the qualifier? Zero *is* not a power of 2, is it?

> +
> +static inline __attribute__((const))
> +bool is_power_of_2(unsigned long n)
> +{
> +	return (n != 0 && ((n & (n - 1)) == 0));
> +}
> +
> +/*
>   * round up to nearest power of two
>   */
>  static inline __attribute__((const))


-- 
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

  reply	other threads:[~2007-01-30 12:26 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 [this message]
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
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=45BF3954.8050106@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=akpm@osdl.org \
    --cc=dhowells@redhat.com \
    --cc=galak@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox