public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Chinner <dgc@sgi.com>
To: "Robert P. J. Day" <rpjday@crashcourse.ca>
Cc: xfs@oss.sgi.com
Subject: Re: use is_power_of_2() macro?
Date: Wed, 7 Nov 2007 16:18:48 +1100	[thread overview]
Message-ID: <20071107051848.GI995458@sgi.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0711061026210.9329@localhost.localdomain>

On Tue, Nov 06, 2007 at 10:28:44AM -0500, Robert P. J. Day wrote:
> 
>   given this in fs/xfs/xfs_inode.c:
> 
> /*
>  * xfs_iroundup: round up argument to next power of two
>  */
> uint
> xfs_iroundup(
>         uint    v)
> {
>         int i;
>         uint m;
> 
>         if ((v & (v - 1)) == 0)
>                 return v;
>         ASSERT((v & 0x80000000) == 0);
>         if ((v & (v + 1)) == 0)
>                 return v + 1;
>         for (i = 0, m = 1; i < 31; i++, m <<= 1) {
>                 if (v & m)
>                         continue;
>                 v |= m;
>                 if ((v & (v + 1)) == 0)
>                         return v + 1;
>         }
>         ASSERT(0);
>         return( 0 );
> }
> 
>   is there any reason that can't be rewritten with simply
> roundup_pow_of_two() as defined in include/linux/log2.h?
> 
> #define roundup_pow_of_two(n)                   \
> (                                               \
>         __builtin_constant_p(n) ? (             \
>                 (n == 1) ? 1 :                  \
>                 (1UL << (ilog2((n) - 1) + 1))   \
>                                    ) :          \
>         __roundup_pow_of_two(n)                 \
>  )
> 
>   just curious.

No - patch please.

Cheers,

Dave.
-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group

      reply	other threads:[~2007-11-07  5:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-06 15:28 use is_power_of_2() macro? Robert P. J. Day
2007-11-07  5:18 ` David Chinner [this message]

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=20071107051848.GI995458@sgi.com \
    --to=dgc@sgi.com \
    --cc=rpjday@crashcourse.ca \
    --cc=xfs@oss.sgi.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