Created
April 21, 2013 19:17
-
-
Save chaelim/5430705 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note From MSDN: | |
// In past versions of the Visual C++ compiler, the _ReadWriteBarrier | |
// and _WriteBarrier functions were enforced only locally and did not | |
// affect functions up the call tree. In Visual C++ 2005 and later, | |
// these functions are enforced all the way up the call tree. | |
// Intel and AMD (x86 and AMD64) enforces strong ordering (program ordering) | |
// except a store followed by a load (the store becomes visible before | |
// the load executes) http://en.wikipedia.org/wiki/Memory_ordering | |
// x86 and x64: Just use compiler fence (no need for hardware fence) | |
#define MEMBAR \ | |
#if defined (_M_IX86) || defined (_M_X64) \ | |
_ReadWriteBarrier(); \ | |
#elif defined (_M_IA64) \ | |
MemoryBarrier(); \ | |
#else \ | |
#error "Need to write code for this architecture" \ | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment