On Tue 21 Feb 2012 09:57:12 GMT, Dave Martin wrote:
struct pad_conf_entry {
u16 offset;
u16 val;
} __attribute__ ((packed));
The "packed" attribute specifies that all struct elements ought to be
considered to have alignment requirement 1 instead of their default
alignment. Thus the whole struct ends up having alignment requirement 1;
and since the section contains only a single variable of such struct
type, this is then also the alignment requirement of the section.
Is "packed" even wanted here?
Based on a very brief skim of the code, it looks like the packed attribute
is an unnecessary attempt to save some space -- unnecessary because all
ARM ABI variants I know of (actually, all arches I know of) will pack that
structure into a word anyway as a result of natural alignment of the
members. It doesn't look to me like the packed structure is used to map a
memory-mapped peripheral directly or otherwise communicate with the outside
world -- which would be the only situations in which a packed structure
would normally make sense.
Of course, I may have missed something...
I'm not sure, but I believe that the compiler requires (prefers) any
structs that you want included inside packed structs to be themselves
packed, so you can end up with some structs with apparently unnecessary
attributes on them.
It might also have an effect when you place the struct inside an
unpacked struct?
Without context I've no idea whether that's what's going on here. Of
course, a no-op "packed" attribute ought to be harmless...
Andrew
_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev