summaryrefslogtreecommitdiffstats
path: root/base/atomicops_internals_x86_msvc.h
diff options
context:
space:
mode:
authorscottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-15 08:51:28 +0000
committerscottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-15 08:51:28 +0000
commita48610cce51c396e5667b70bce05a5ad80fbc83c (patch)
tree95b14cb1455470ee1b300fc5d34f6de2d840058c /base/atomicops_internals_x86_msvc.h
parent2632f5046d811f8780484cbaf983f3c9a97c9ea9 (diff)
downloadchromium_src-a48610cce51c396e5667b70bce05a5ad80fbc83c.zip
chromium_src-a48610cce51c396e5667b70bce05a5ad80fbc83c.tar.gz
chromium_src-a48610cce51c396e5667b70bce05a5ad80fbc83c.tar.bz2
Workaround to make MemoryBarrier compile on Win x64
windows.h #defines "MemoryBarrier" on x64 (on x86 it's an forceinline function). Because atomicops.h uses MemoryBarrier as the public api name, workaround by #undefing and then calling the implementation directly. ref: http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx R=brettw@chromium.org BUG=166496 Review URL: https://chromiumcodereview.appspot.com/11888016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/atomicops_internals_x86_msvc.h')
-rw-r--r--base/atomicops_internals_x86_msvc.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/base/atomicops_internals_x86_msvc.h b/base/atomicops_internals_x86_msvc.h
index eacbb5e..3a2c72d 100644
--- a/base/atomicops_internals_x86_msvc.h
+++ b/base/atomicops_internals_x86_msvc.h
@@ -9,6 +9,15 @@
#include <windows.h>
+#if defined(ARCH_CPU_64_BITS)
+// windows.h #defines this (only on x64). This causes problems because the
+// public API also uses MemoryBarrier at the public name for this fence. So, on
+// X64, undef it, and call its documented
+// (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx)
+// implementation directly.
+#undef MemoryBarrier
+#endif
+
namespace base {
namespace subtle {
@@ -46,8 +55,13 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
#error "We require at least vs2005 for MemoryBarrier"
#endif
inline void MemoryBarrier() {
+#if defined(ARCH_CPU_64_BITS)
+ // See #undef and note at the top of this file.
+ __faststorefence();
+#else
// We use MemoryBarrier from WinNT.h
::MemoryBarrier();
+#endif
}
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,