Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-20 Thread Pavel Machek
Hi! > > > hm. So if I have > > > > > > struct bar { > > > unsigned long b; > > > } __attribute__((packed)); > > > > > > struct foo { > > > unsigned long u; > > > struct bar b; > > > }; > > > > > > then the compiler can see that foo.b.b is well-aligned,

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-20 Thread Pavel Machek
Hi! hm. So if I have struct bar { unsigned long b; } __attribute__((packed)); struct foo { unsigned long u; struct bar b; }; then the compiler can see that foo.b.b is well-aligned, regardless of the packedness.

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Ralf Baechle
On Thu, Feb 15, 2007 at 05:27:20PM -0800, Andrew Morton wrote: > No, icc surely supports attribute(packed). My point is that we shouldn't > rely upon the gcc info file for this, because other compilers can (or > could) be used to build the kernel. > > So it would be safer if the C spec said (or

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Andrew Morton
On Fri, 16 Feb 2007 00:43:17 + Ralf Baechle <[EMAIL PROTECTED]> wrote: > On Thu, Feb 15, 2007 at 03:38:23PM -0800, Andrew Morton wrote: > > > hm. So if I have > > > > struct bar { > > unsigned long b; > > } __attribute__((packed)); > > > > struct foo { > >

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Ralf Baechle
On Thu, Feb 15, 2007 at 03:38:23PM -0800, Andrew Morton wrote: > hm. So if I have > > struct bar { > unsigned long b; > } __attribute__((packed)); > > struct foo { > unsigned long u; > struct bar b; > }; > > then the compiler

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Jeremy Fitzhardinge
Andrew Morton wrote: > hm. So if I have > > struct bar { > unsigned long b; > } __attribute__((packed)); > > struct foo { > unsigned long u; > struct bar b; > }; > > then the compiler can see that foo.b.b is well-aligned,

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Andrew Morton
On Thu, 15 Feb 2007 22:18:39 + Ralf Baechle <[EMAIL PROTECTED]> wrote: > On Thu, Feb 15, 2007 at 01:53:58PM -0800, Andrew Morton wrote: > > > > The whole union thing was only needed to get rid of a warning but Marcel's > > > solution does the same thing by attaching the packed keyword to the

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Jeremy Fitzhardinge
Ralf Baechle wrote: > Gcc info page says: > > [...] > `packed' > The `packed' attribute specifies that a variable or structure field > should have the smallest possible alignment--one byte for a > variable, and one bit for a field, unless you specify a larger > value with the

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Ralf Baechle
On Thu, Feb 15, 2007 at 01:53:58PM -0800, Andrew Morton wrote: > > The whole union thing was only needed to get rid of a warning but Marcel's > > solution does the same thing by attaching the packed keyword to the entire > > structure instead, so this patch is now using his macros but using

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Andrew Morton
On Thu, 15 Feb 2007 14:34:41 + Ralf Baechle <[EMAIL PROTECTED]> wrote: > On Wed, Feb 14, 2007 at 08:39:03PM -0800, Andrew Morton wrote: > > > Can someone please tell us how this magic works? (And it does appear to > > work). > > > > It seems to assuming that the compiler will assume that

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Ralf Baechle
On Wed, Feb 14, 2007 at 08:39:03PM -0800, Andrew Morton wrote: > Can someone please tell us how this magic works? (And it does appear to > work). > > It seems to assuming that the compiler will assume that members of packed > structures can have arbitrary alignment, even if that alignment is

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Marcel Holtmann
Hi Andrew, > > +#define get_unaligned(ptr) \ > > +({ \ > > + const struct { \ > > + union {

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Marcel Holtmann
Hi Andrew, +#define get_unaligned(ptr) \ +({ \ + const struct { \ + union {

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Ralf Baechle
On Wed, Feb 14, 2007 at 08:39:03PM -0800, Andrew Morton wrote: Can someone please tell us how this magic works? (And it does appear to work). It seems to assuming that the compiler will assume that members of packed structures can have arbitrary alignment, even if that alignment is

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Andrew Morton
On Thu, 15 Feb 2007 14:34:41 + Ralf Baechle [EMAIL PROTECTED] wrote: On Wed, Feb 14, 2007 at 08:39:03PM -0800, Andrew Morton wrote: Can someone please tell us how this magic works? (And it does appear to work). It seems to assuming that the compiler will assume that members of

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Ralf Baechle
On Thu, Feb 15, 2007 at 01:53:58PM -0800, Andrew Morton wrote: The whole union thing was only needed to get rid of a warning but Marcel's solution does the same thing by attaching the packed keyword to the entire structure instead, so this patch is now using his macros but using __packed

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Jeremy Fitzhardinge
Ralf Baechle wrote: Gcc info page says: [...] `packed' The `packed' attribute specifies that a variable or structure field should have the smallest possible alignment--one byte for a variable, and one bit for a field, unless you specify a larger value with the `aligned'

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Andrew Morton
On Thu, 15 Feb 2007 22:18:39 + Ralf Baechle [EMAIL PROTECTED] wrote: On Thu, Feb 15, 2007 at 01:53:58PM -0800, Andrew Morton wrote: The whole union thing was only needed to get rid of a warning but Marcel's solution does the same thing by attaching the packed keyword to the entire

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Jeremy Fitzhardinge
Andrew Morton wrote: hm. So if I have struct bar { unsigned long b; } __attribute__((packed)); struct foo { unsigned long u; struct bar b; }; then the compiler can see that foo.b.b is well-aligned, regardless of the

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Ralf Baechle
On Thu, Feb 15, 2007 at 03:38:23PM -0800, Andrew Morton wrote: hm. So if I have struct bar { unsigned long b; } __attribute__((packed)); struct foo { unsigned long u; struct bar b; }; then the compiler can see that

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Andrew Morton
On Fri, 16 Feb 2007 00:43:17 + Ralf Baechle [EMAIL PROTECTED] wrote: On Thu, Feb 15, 2007 at 03:38:23PM -0800, Andrew Morton wrote: hm. So if I have struct bar { unsigned long b; } __attribute__((packed)); struct foo { unsigned long u;

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-15 Thread Ralf Baechle
On Thu, Feb 15, 2007 at 05:27:20PM -0800, Andrew Morton wrote: No, icc surely supports attribute(packed). My point is that we shouldn't rely upon the gcc info file for this, because other compilers can (or could) be used to build the kernel. So it would be safer if the C spec said (or

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-14 Thread Andrew Morton
On Wed, 14 Feb 2007 21:42:26 + Ralf Baechle <[EMAIL PROTECTED]> wrote: > Time for a little bit of dead horse flogging. > > On Mon, Mar 06, 2006 at 05:05:52PM -0800, Andrew Morton wrote: > > > > --- a/include/asm-generic/unaligned.h > > > +++ b/include/asm-generic/unaligned.h > > > @@ -78,7

[PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-14 Thread Ralf Baechle
Time for a little bit of dead horse flogging. On Mon, Mar 06, 2006 at 05:05:52PM -0800, Andrew Morton wrote: > > --- a/include/asm-generic/unaligned.h > > +++ b/include/asm-generic/unaligned.h > > @@ -78,7 +78,7 @@ static inline void __ustw(__u16 val, __u > > > > #define __get_unaligned(ptr,

[PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-14 Thread Ralf Baechle
Time for a little bit of dead horse flogging. On Mon, Mar 06, 2006 at 05:05:52PM -0800, Andrew Morton wrote: --- a/include/asm-generic/unaligned.h +++ b/include/asm-generic/unaligned.h @@ -78,7 +78,7 @@ static inline void __ustw(__u16 val, __u #define __get_unaligned(ptr, size) ({

Re: [PATCH] Optimize generic get_unaligned / put_unaligned implementations.

2007-02-14 Thread Andrew Morton
On Wed, 14 Feb 2007 21:42:26 + Ralf Baechle [EMAIL PROTECTED] wrote: Time for a little bit of dead horse flogging. On Mon, Mar 06, 2006 at 05:05:52PM -0800, Andrew Morton wrote: --- a/include/asm-generic/unaligned.h +++ b/include/asm-generic/unaligned.h @@ -78,7 +78,7 @@ static