Re: [PATCH] abuse of macros in swab.h

From: Alexander Viro (viro@math.psu.edu)
Date: Tue Sep 19 2000 - 18:47:57 EST


On Wed, 20 Sep 2000, Andi Kleen wrote:

> On Tue, Sep 19, 2000 at 07:13:31PM -0400, Alexander Viro wrote:
> > Nice spotting, but bad fix, IMO. swab...() stuff is a perfect example of
> > the dangerous use of macros. BTW, 2.4 has the same problem.
>
> inlines usually generate worse code than macros (the gcc manual lies on that),
> e.g. the register allocation is usually worse and CSE doesn't work that well.
> Normally it makes not that much difference, but these macros are rather
> performance critical.
>
> Better would be to use statement blocks like
> #define bla(x) ({ __u32 tmp__ = (x); ....; tmp__; })

Fine with me.

> I would prefer to fix the callers anyways, because it is clearer this way.

... and grep for that sort of stuff after every new release? That's
exactly the sort of bug that _will_ come back to haunt us, again and
again.

If it looks like a function - it should act like one. Every exception
turned out to be a source of recurring bugs. And it _does_ look like
a function - not even all-caps in the names of derived macros.

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



This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 21:00:22 EST