Bad volatile -mstrict-align code on powerpc on 4.0.2?

Peter Dufault dufault at hda.com
Mon Nov 7 00:08:46 UTC 2005


On Nov 6, 2005, at 4:43 PM, Till Straumann wrote:

> It could be that the compiler doesn't realize that your structure is
> properly aligned although you hardcode it's address as 0x9fff9800.
> Since the struct is 'packed' and you ask for 'mstrict-align' the  
> compiler does only byte-wise access (no clue why writing a 16-bit
> word as two bytes results in lbz/li/stb instead of just li/stb...).

Yes, that to me seems to really violate the "volatility" aspect of it.
>
> I have tried to hint
>
> __attribute__((packed,aligned(2)))
>
> which seems to generate proper code even with -mstrict-align

That was the work around I found too.  Do you agree this is a  
compiler bug?  If so I'll open it.

>
> YMMV
>
> T.
>
>
> BTW - if you don't mind a comment:
> IMO it is better coding practice to use in_be16/out_be16 (or
> ld_be16/st_be16 if you are sure you don't need the eieio)
> for memory-mapped device register access.
> It helps to make your code more portable and readable,
> clearly identifying I/O operations as such (plus, these
> inlines would automatically have enforced the correct
> operation :-) w/o surprises...).
>

Plus it gives you a place to hook in device-level simulation.  This  
is legacy code, though, and I've got lots of memory mapped device I/O  
I'd like to move forward without much re-write.

Peter



More information about the users mailing list