public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Randy Dunlap <randy.dunlap@oracle.com>
To: "Robert P. J. Day" <rpjday@crashcourse.ca>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH] log2.h: Define order_base_2() macro for convenience.
Date: Sun, 11 Nov 2007 10:28:37 -0800	[thread overview]
Message-ID: <20071111102837.e934544d.randy.dunlap@oracle.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0711102249110.7449@localhost.localdomain>

On Sat, 10 Nov 2007 22:53:36 -0500 (EST) Robert P. J. Day wrote:

> 
> Given a number of places in the tree that need to calculate this value
> explicitly, might as well just create a macro for it.
> 
> Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
> 
> ---
> 
>   run-time tested for the first several values.  note that this macro
> is defined strictly in terms of rounding *up* -- i've seen no places
> in the tree that require this expression to be rounded down, so i'm
> not drawing that distinction.
> 
> diff --git a/include/linux/log2.h b/include/linux/log2.h
> index c8cf5e8..ed121c0 100644
> --- a/include/linux/log2.h
> +++ b/include/linux/log2.h
> @@ -190,4 +190,20 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
>  	__rounddown_pow_of_two(n)		\
>   )
> 
> +/**
> + * order_base_2 - calculate the (rounded up) base 2 order of the argument
> + * @n - parameter

 * @n: argument

(mostly changing - to :)

> + *
> + * The first few values calculated by this routine:
> + *  ob2(0) = 0
> + *  ob2(1) = 0
> + *  ob2(2) = 1
> + *  ob2(3) = 2
> + *  ob2(4) = 2
> + *  ob2(5) = 3
> + *  ... and so on.
> + */
> +
> +#define order_base_2(n) ilog2(roundup_pow_of_two(n))
> +
>  #endif /* _LINUX_LOG2_H */
> 
> -- 

---
~Randy

  reply	other threads:[~2007-11-11 18:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-11  3:53 [PATCH] log2.h: Define order_base_2() macro for convenience Robert P. J. Day
2007-11-11 18:28 ` Randy Dunlap [this message]
2007-11-12  7:27   ` Robert P. J. Day
  -- strict thread matches above, loose matches on Subject: below --
2007-11-12  7:32 Robert P. J. Day

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=20071111102837.e934544d.randy.dunlap@oracle.com \
    --to=randy.dunlap@oracle.com \
    --cc=akpm@osdl.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox