This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: question on volatile
- To: Martin Kahlert <martin dot kahlert at mchp dot siemens dot de>
- Subject: Re: question on volatile
- From: Richard Henderson <rth at cygnus dot com>
- Date: Fri, 5 Nov 1999 09:48:55 -0800
- Cc: egcs at egcs dot cygnus dot com
- References: <199911051029.LAA18342@keksy.mchp.siemens.de>
On Fri, Nov 05, 1999 at 11:29:51AM +0100, Martin Kahlert wrote:
> how can i be sure, that the compiler doesn't compile
> it [ by rearranging stores ]
>
> Is it enough to make the runme field inside Arguments volatile?
For the compiler, yes, for the hardware, it depends.
Does your hardware guarantee total memory ordering?
Many do not.
> These things should be common problems in hardware driver writing, so
> the compiler should provide some mechanism for it.
The mechanism the compiler provides for driver writing
is inline assembly. E.g. for Alpha:
__asm ("mb" : : : "memory")
inserts the needed memory-barrier instruction, and also
tells the compiler that memory should be synced at this
point, which obviates the need to mark the fields volatile.
r~