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

Andrea Arcangeli
2004-07-12T19:36:48Z

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)