This is the mail archive of the gcc@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]

Re: question on volatile


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~


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