Re: [announce] [patch] Voluntary Kernel Preemption Patch

From: Takashi Iwai
Date: Tue Jul 13 2004 - 02:46:44 EST


At Mon, 12 Jul 2004 21:36:06 +0200,
Andrea Arcangeli wrote:
>
> On Mon, Jul 12, 2004 at 12:17:05PM +0200, Takashi Iwai wrote:
> > Couldn't it be simply written like below?
> >
> > #define BUILD_BUG_ON(condition) do { if (unlikely(condition)) BUILD_BUG(); } while(0)
>
> BUILD_BUG_ON is a different thing. the "condition" is meant to be
> evaluated at _compile_ time, not at runtime (so the unlikely is useless
> since the compiler knows the result before it generates the bytecode).
> This is why BUILD_BUG() isn't implemented anywhere, so you get a linker
> error during the compilation.
>
> For example with it you can do things like:
>
> BUILD_BUG_ON(offsetof(struct task_struct, thread.i387.fxsave) & 15);
>
> (see asm-i386/bugs.h, it's doing the BUILD_BUG_ON by hand right now)

Yes, sorry for confusing, copy & paste from a wrong place.

I'm just wondering whether '!=0' is needed inside unlikely() as
defined in asm-i386/bug.h:

#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)

Without '!= 0', it's expanded identically as you wrote.
Well, the compiler may get rid of it after optimization...


BTW, BUG_ON(a||b) is a different story, of course :)

Takashi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/