[U-Boot-Users] struct NS16550 {...} __attribute__ ((packed)) at ns16550.h

Pantelis Antoniou panto at intracom.gr
Tue Apr 26 08:23:33 CEST 2005


Wolfgang Denk wrote:
> In message <426D0A4C.5000105 at intracom.gr> you wrote:
> 
>>Not on ARM it does not.
> 
> 
> Yes, I know? Why did you not quote this part of my message, too?
> 
> 
>>ARM (silently) does the wrong thing i.e. masks out the lower 2 bits.
>>So gcc on ARM generates byte load/stores.
> 
> 
> ...which is broken, especially when there is no need to do this since
> the fields are properly aligned.
> 

The compiler does not know this. A pointer to the structure could be
pointing to an non-aligned address, and when an aligned field within
the structure is accessed it will be not aligned.

This typically happens when networking.

IMHO __attribute((packed)) is deceivingly named, since it implies
two things.

1) Don't leave any space between fields of the structure.
2) Access the fields of the structure even when the alignment of the
    pointer pointing to it is wrong.

Just by the name, you expect only (1).

> Best regards,
> 
> Wolfgang Denk
> 

Regards

Pantelis




More information about the U-Boot mailing list