Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/arch/newsmips/newsmips



Izumi Tsutsui wrote:
> christos%astron.com@localhost wrote:
>
>   
>>> Modified Files:
>>>     src/sys/arch/newsmips/newsmips: news3400.c
>>>
>>> Log Message:
>>> Make badaddr_flag volatile to avoid unintended optimization by gcc4.
>>> Now GENERIC compiled by gcc4 works on NWS-3470D.
>>>
>>> XXX: Is this gcc4 optimization bug, or volitile is required in this case?
>>>       
>> It is not a gcc bug. You need volatile, since gcc cannot intuit that the
>> pointer deref will end up changing its value.
>>     
>
> In this case, "static int badaddr_flag" might be changed in the interrupt
> handler (news3400_intr() in the same source) which is invoked on
> the buserror trap from news3400_badaddr(), not via pointer deref.
>
> I.e. the question is "doesn't gcc4 assume such static variables might
> be changed in the interrupt context in the same source?"
> ---
> Izumi Tsutsui
>   

I've not looked at the code in question, but in general, gcc cannot
intuit that changes occur across an interrupt.

So you generally either mark the variable volatile, or (more frequently)
take action to ensure that while you are looking at a variable,
interrupt that can modify a value this way do not occur.

-- 
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134  Fax: 951 325-2191




Home | Main Index | Thread Index | Old Index