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

Kenneth Johansson kenneth at southpole.se
Mon Aug 11 19:21:28 CEST 2008


On Mon, 2008-08-11 at 19:00 +0200, Guennadi Liakhovetski wrote:
> On Mon, 11 Aug 2008, Kenneth Johansson wrote:
> 
> > 
> > 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. 
> 
> I think, properly written mmapped-register access functions like readl() 
> work perfectly too.
> 

what does the compiler do if you change the code  to 

        return *(ulong*)&timers->TCNTO4;






More information about the U-Boot mailing list