This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: volatile function


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).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]