lkml.org 
[lkml]   [2010]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] log2.h: Macro-ize is_power_of_2() for use in BUILD_BUG_ON
Date

> We've had recurring struggles with various versions of gcc screwing up
> constructs of this form and trying to emit the non-constant code when
> the arg was clearly a compile-time constant. One episode which comes
> to mind was when we made changes to kmalloc().
>
> Of course, that might not bite us in this case - it would need a lot of
> coverage testing to find out.

Actually, after thinking about this a bit more I don't think this is
much of a risk in this case. The bad case is where gcc gets the wrong
answer for __builtin_constant_p(), and in that case, we're left with the
status quo ante, ie a call to the original inline function implementation.

This will break a call to BUILD_BUG_ON() but that's visible at compile
time. It's hard to think of a silent failure case that actually hurts
anything -- the macro and inline implementation are identical, except
that the macro implementation will work when gcc really needs a compile
time constant.

- R.


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