[U-Boot] __attribute__((__packed__)) switching to byte-access on ARM

Kenneth Johansson kenneth at southpole.se
Mon Aug 11 18:50:02 CEST 2008


On Mon, 2008-08-11 at 18:23 +0200, Guennadi Liakhovetski wrote:

> I cannot think of any such examples... I know access-types can be changed 
> on the hardware, say, on a 16-bit bus a 32-bit access can be split into 
> two 16-bit accesses, but I currently cannot think of any examples of the 
> compiler doing such things. But, I think, I can imagine _why_ the compiler 
> might decide to do that - it cannot guarantee, that the structure is 
> 32-bit aligned, so, it is opting for the "safe" variant... So, the 
> question is: is the compiler right and the c-code was wrong, or the other 
> way round?

Both are "right" :). C has a lot of implementation specific stuff that
can make life interesting. Simple thing like if char is signed or
unsigned sometimes is really important. 

If you have to make sure that the read/write is done in 16 bit the only
option is to use assembler code. 







More information about the U-Boot mailing list