I don't know that the compiler knows anything about write reordering. The restriction that the write of c must happen before the read of c is something that the processor itself is aware of. The compiler will generate code to do the write then read in sequence, and the processor is smart enough to work out that it can't reorder read/write operations on the same memory location without breaking the code -- this has nothing to do with 'volatile'. See the Itanium memory reordering PDF I referenced earlier in this thread for excruciating detail on its reordering model and the restrictions imposed on it in relation to accesses to the same memory address.
Regards, Steven -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jim Schneider Sent: Saturday, 9 April 2005 12:08 AM To: [email protected] Subject: Re: OpenSSL use of DCLP may not be thread-safe on multiple processors [snip] int a; volatile int c; void foo(int b) { c = b; a = c; } would require that the compiler generate code that stores the value of b into c, and then stores the value in c into a. While the compiler would have to take write reordering into account with respect to this particular process (or it would violate the requirement that c be written before it's read again), it's free to ignore caching. It's also free to ignore write reordering with respect to other processes. [snip] ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List [email protected] Automated List Manager [EMAIL PROTECTED]
