| To: | "Robert P. J. Day" <rpjday@xxxxxxxxxxxxxx> |
|---|---|
| Subject: | Re: use is_power_of_2() macro? |
| From: | David Chinner <dgc@xxxxxxx> |
| Date: | Wed, 7 Nov 2007 16:18:48 +1100 |
| Cc: | xfs@xxxxxxxxxxx |
| In-reply-to: | <Pine.LNX.4.64.0711061026210.9329@xxxxxxxxxxxxxxxxxxxxx> |
| References: | <Pine.LNX.4.64.0711061026210.9329@xxxxxxxxxxxxxxxxxxxxx> |
| Sender: | xfs-bounce@xxxxxxxxxxx |
| User-agent: | Mutt/1.4.2.1i |
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
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Deviation from XSDM in DM_EVENT_XXX, Manoj Kumar Pradhan |
|---|---|
| Next by Date: | Re: TAKE 972756 - Implement fallocate., Bhagi rathi |
| Previous by Thread: | use is_power_of_2() macro?, Robert P. J. Day |
| Next by Thread: | Re: Delivery reports about your e-mail, cji |
| Indexes: | [Date] [Thread] [Top] [All Lists] |