lkml.org 
[lkml]   [2010]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] log2.h: Macro-ize is_power_of_2() for use in BUILD_BUG_ON
On Wed, 2010-01-06 at 12:44 -0800, Roland Dreier wrote:
> > Perhaps we can avoid worrying about that via
>
> > #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
> > BUILD_BUG_ON((n != 0 && ((n & (n - 1)) == 0)))
>
> Having something so specific to this particular case makes me feel like
> maybe it's just not worth it. At least in the case I'm looking at, we
> could just have:
>
> /*
> * The code relies on FOO being a power of 2. If you break this,
> * you're dumb.
> */
> #define FOO_SHIFT 6
> #define FOO (1 << FOO_SHIFT)
>
> Your thoughts?

I'm fine with that, but now I'll probably be the dumb one to break it
some day in the future.


\
 
 \ /
  Last update: 2010-01-06 23:03    [W:2.088 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site