From: Philip Craig <philipc@xxxxxxxxxxxx> Date: Tue, 29 Apr 2008 16:00:35 +1000 > David Miller wrote: > > Now these elements cannot be assumed to have any particular > > alignment, so gcc will emit byte-at-a-time accesses to these > > elements. > > Ah, so the problem is the __attribute__(packed) removes align > restrictions for the whole structure, in addition to removing > padding. > > Is there any way to tell gcc to pack but still align the whole > thing? Is there any way to tell ARM not to layout structures in such a silly way by default? :-))) > eg what does it do for this: > struct t { > struct s { > u16 a; > u16 b; > } __attribute__(packed); > }; 'a' and 'b' cannot be assumed to be aligned in any particular way, and thus byte-at-a-time accesses will be made to them. This program: -------------------- typedef unsigned short u16; struct t { struct s { u16 a; u16 b; } __attribute__((packed)) x; }; u16 a(struct t *p) { return p->x.a; } u16 b(struct t *p) { return p->x.b; } -------------------- results in the following on sparc64: a: ldub [%o0], %g1 ldub [%o0+1], %o0 sllx %g1, 8, %g1 jmp %o7+8 or %o0, %g1, %o0 .size a, .-a .align 4 .align 32 .global b .type b, #function .proc 04 b: ldub [%o0+2], %g1 ldub [%o0+3], %o0 sllx %g1, 8, %g1 jmp %o7+8 or %o0, %g1, %o0 .size b, .-b -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html