Re: [PATCH] Remove some divide instructions

From: Linus Torvalds
Date: Wed Oct 27 2004 - 19:58:33 EST




On Wed, 27 Oct 2004, Linus Torvalds wrote:
>
> I could add a sparse check for "no side effects", if anybody cares (so
> that you could do
>
> __builtin_warning(
> !__builtin_nosideeffects(base),
> "expression has side effects");
>
> in macros like these.. Sparse already has the logic internally..

Done. Except I called it __builtin_safe_p().

The kernel sources already know about "__builtin_warning()" (and
pre-process it away on gcc), so if you have a new sparse setup (as of two
minutes ago ;), you can use this thing to check that arguments to macros
do not have side effects.

Useful? You be the judge. But it was just a couple of lines in sparse, and
doing so also made it obvious how to clean up __builtin_constant_p() a lot
at the same time by just re-organizing things a bit.

My inliner and statement simplificator isn't perfect, so inline functions
sadly are not considered constant (or safe) even if they _do_ end up
returning a constant value (or be safe internally).

Linus
-
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/