volatile function
Cedric Roux
cedric.roux@acri-st.fr
Tue Jan 25 09:37:00 GMT 2011
On 01/25/2011 09:04 AM, kevin diggs wrote:
> Hi,
>
> The function in question is returning the value of the PLL config
> register in a PowerPC 750GX. I wanted to make sure that the optimizer
> does not move or eliminate the call. I thought that is one of the uses
> of the volatile qualifier???
>
> Thanks!
>
> kevin
>
>>> static inline volatile unsigned int get_PLL(void)
>>> {
>>> unsigned int ret;
>>>
>>> __asm__ __volatile__ ("mfspr %0,%1":
>>> "=r"(ret):
>>> "i"(SPRN_HID1)
>>> );
>>>
>>> return ret;
>>> }
I think that SPRN_HID1 has to be declared as volatile
(if that has a meaning at all in your case) for gcc
to force the load in all cases (my .02 euros, I don't
know your target asm, I don't know what SPRN_HID1 is).
More information about the Gcc-help
mailing list