[Top][All Lists]

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

Re: [avr-gcc-list] "Volatile"

From: Graham Davies
Subject: Re: [avr-gcc-list] "Volatile"
Date: Mon, 18 Apr 2005 07:43:37 -0400

David Brown wrote:

> ...  I cannot think of any sort of architecture ... that would
> require read-modify-write to set a char to a constant value, since a char
> always directly addressible (on machines that can't directly address an
> 8-bit byte, a C "char" may be 16-bit or bigger).

On a 32-bit machine (e.g. Freescale MPC8260) where the variable is mapped to
a 32-bit wide hardware register (e.g. Infineon "Purple" Ethernet switch)
setting a char is not atomic.  The whole register must be read, one byte
modified, and the result written back.  This is an extreme case but I'm not
convinced there wouldn't be more subtle ones that would make reliance on
atomic char writes unportable.  (Getting rather OT here, sorry.)

and David Brown also wrote:

> I have worked with gcc ports where "volatile" was used to indicate
> that a variable should bypass cache, *in addition to* the standard
> properties of volatile.

Wow.  This is new to me.  Thanks for this.

and finally David Brown wrote:

> There is nothing in the C standard that restricts adding
> additional properties like this to volatile ...

I will take your word for it, but is this really a good idea?  If you were
defining the Altera Nios language extensions, would you overload volatile
with the cache bypass effect or would you add a new qualifier, such as
uncached, to do this?


reply via email to

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