avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Tip: handling volatile operands


From: Dave N6NZ
Subject: Re: [avr-gcc-list] Tip: handling volatile operands
Date: Fri, 11 Jan 2008 10:04:09 -0800
User-agent: Thunderbird 1.5 (X11/20051201)



Dave Hansen wrote:

   switch (ioport)
   {
    case 1: ...
    case 2: ...
    case 99: ...
   }

This is (IMHO) a closer abstraction of what you actually want done.

But there is no general guarantee that the compiler won't turn a switch into an if..then..else if... chain. It would be an interesting test of the volatile keyword to see if declaring the switch variable volatile has the effect of forcing a jump table.

It appears to me that this whole discussion is about is trying to cheap out on critical sections by looking for locks that come for free under specific circumstances with particular releases of the optimizer. Maybe it is better to document the places where it isn't obvious that you need a lock?

-dave






reply via email to

[Prev in Thread] Current Thread [Next in Thread]