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

2000-09-23 Thread Giuliano Pochini
> +static inline __u64 ___swab16(__u64 x) > +{ > + return (__u64)((x & (__u64)0x00ffULL) << 56) | > + (__u64)((x & (__u64)0xff00ULL) << 40) | > + (__u64)((x & (__u64)0x00ffULL) << 24) | > + (__u64)((x & (__u64)0x

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

2000-09-20 Thread Horst von Brand
Martin Dalecki <[EMAIL PROTECTED]> said: > Andrea Arcangeli wrote: > > On Wed, Sep 20, 2000 at 01:22:50AM +0200, Andi Kleen wrote: > > > Better would be to use statement blocks like > > > #define bla(x) ({ __u32 tmp__ = (x); ; tmp__; }) > > Agreed. > Not agreed. In this case older version of

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

2000-09-20 Thread Andrzej Krzysztofowicz
> +static inline __u64 ___swab16(__u64 x) > +{ > + return (__u64)((x & (__u64)0x00ffULL) << 56) | > + (__u64)((x & (__u64)0xff00ULL) << 40) | > + (__u64)((x & (__u64)0x00ffULL) << 24) | > + (__u64)((x & (__u64)0xf

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

2000-09-20 Thread Trond Myklebust
> " " == Alexander Viro <[EMAIL PROTECTED]> writes: > 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. > +static inline __u16 ___swab16(__u16 x) +{ Don't forget that htonl(), ntohl(),

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

2000-09-19 Thread Olivier Galibert
On Tue, Sep 19, 2000 at 04:11:30PM -0700, David S. Miller wrote: > Unfortunately, gcc does not make inline functions as cheap as "macros > with type checking". There are extra costs and often the register > allocator cannot cope and stuff starts getting spilled to the stack. It is supposedly on

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

2000-09-19 Thread Andi Kleen
On Wed, Sep 20, 2000 at 01:58:32AM +0200, Martin Dalecki wrote: > Andrea Arcangeli wrote: > > > > On Wed, Sep 20, 2000 at 01:22:50AM +0200, Andi Kleen wrote: > > > Better would be to use statement blocks like > > > #define bla(x) ({ __u32 tmp__ = (x); ; tmp__; }) > > > > Agreed. > > Not agr

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

2000-09-19 Thread Andi Kleen
On Wed, Sep 20, 2000 at 01:55:58AM +0200, Martin Dalecki wrote: > The GCC manual doesn't lie on that ANY LONGER with respect to EGCS. > And we should adpat for the modern versions of the compiler instead > of dragging the *ugly* code with us until the earth stops spinning, iff > the only concern i

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

2000-09-19 Thread Andrea Arcangeli
On Wed, Sep 20, 2000 at 01:58:32AM +0200, Martin Dalecki wrote: > Not agreed. In this case older version of GCC will have > almost exactly the same provlems as with functions. I guess the object was to remove the mistake-prone side effects anyway... Andrea - To unsubscribe from this list: send t

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

2000-09-19 Thread David S. Miller
Date: Wed, 20 Sep 2000 01:58:32 +0200 From: Martin Dalecki <[EMAIL PROTECTED]> Andrea Arcangeli wrote: > Agreed. Not agreed. In this case older version of GCC will have almost exactly the same provlems as with functions. Care to show an example? I do not believe this is true.

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

2000-09-19 Thread Martin Dalecki
Andrea Arcangeli wrote: > > On Wed, Sep 20, 2000 at 01:22:50AM +0200, Andi Kleen wrote: > > Better would be to use statement blocks like > > #define bla(x) ({ __u32 tmp__ = (x); ; tmp__; }) > > Agreed. Not agreed. In this case older version of GCC will have almost exactly the same provlems

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

2000-09-19 Thread Alexander Viro
On Tue, 19 Sep 2000, Linus Torvalds wrote: > > > On Tue, 19 Sep 2000, David S. Miller wrote: > > > > Would you mind taking a look at the difference in code output when > > register pressure in a given function is moderate to high? :-) > > Immaterial. > > If somebody cares about performanc

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

2000-09-19 Thread Martin Dalecki
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 l

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

2000-09-19 Thread Alexander Viro
On Wed, 20 Sep 2000, Andrea Arcangeli wrote: > On Tue, Sep 19, 2000 at 07:13:31PM -0400, Alexander Viro wrote: > > +static inline __u16 ___swab16(__u16 x) > > +{ > > + return ((x & (__u16)0x00ffU) << 8) | ((x & (__u16)0xff00U) >> 8); > > +} > > +static inline __u32 ___swab16(__u32 x) >

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

2000-09-19 Thread Alexander Viro
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 mac

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

2000-09-19 Thread Andrea Arcangeli
On Wed, Sep 20, 2000 at 01:22:50AM +0200, Andi Kleen wrote: > Better would be to use statement blocks like > #define bla(x) ({ __u32 tmp__ = (x); ; tmp__; }) Agreed. Andrea - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED

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

2000-09-19 Thread Andrea Arcangeli
On Tue, Sep 19, 2000 at 07:13:31PM -0400, Alexander Viro wrote: > +static inline __u16 ___swab16(__u16 x) > +{ > + return ((x & (__u16)0x00ffU) << 8) | ((x & (__u16)0xff00U) >> 8); > +} > +static inline __u32 ___swab16(__u32 x) ^ > +{ > + return ((x & (__u32

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

2000-09-19 Thread Linus Torvalds
On Tue, 19 Sep 2000, David S. Miller wrote: > > Would you mind taking a look at the difference in code output when > register pressure in a given function is moderate to high? :-) Immaterial. If somebody cares about performance, they'd just better create the proper architecture-specific macr

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

2000-09-19 Thread David S. Miller
Date:Tue, 19 Sep 2000 19:13:31 -0400 (EDT) From: Alexander Viro <[EMAIL PROTECTED]> 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. Would you mind taking a look at the difference in code o

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

2000-09-19 Thread Andi Kleen
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

[PATCH] abuse of macros in swab.h

2000-09-19 Thread Alexander Viro
On Tue, 19 Sep 2000, David S. Miller wrote: >Date: Wed, 20 Sep 2000 00:50:06 +0200 >From: "Andi Kleen" <[EMAIL PROTECTED]> > >This patch fixes an obvious bug introduced with the ext2 changes in >2.2.18pre (look up the definition of le32_to_cpu on BE machines >without a