synchronized vs. C volatile

Sean Kelly sean at invisibleduck.org
Mon Aug 9 09:52:11 PDT 2010


SK Wrote:
> 
> Andrei's book does not list volatile as a keyword in D.  I'm at a loss
> unless 'synchronized' performs double duty as volatile.  For example,
> device status registers are "const volatile" in C/C++.  The compiler
> disallows writes and does not optimize away reads.   Mutexes are
> irrelevant and for that matter the processor may not (and need not)
> even support atomic instructions.

So you're one of the few people who actually use C volatile as intended, huh? :-)  I think right now your best bet is to use inline asm, or call out to a function written in assembly if you're targeting something other than x86.  As I said in my other post, the compiler won't optimize away ask blocks, nor will it optimize across them.  Walter has stated that it's incorrect behavior for a compiler to do so.  GDC or LDC might however, I really couldn't say.


More information about the Digitalmars-d mailing list