Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: base/atomicops_internals_x86_msvc.h

Issue 308683011: Use the intrinsic version of the Interlocked* functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/atomicops_internals_x86_msvc.h
diff --git a/base/atomicops_internals_x86_msvc.h b/base/atomicops_internals_x86_msvc.h
index 016744c144416f869606881e87ee7d8072f75cdd..4070565c716fe2acf56f5b2c9900bcf83618d10d 100644
--- a/base/atomicops_internals_x86_msvc.h
+++ b/base/atomicops_internals_x86_msvc.h
@@ -9,6 +9,8 @@
#include <windows.h>
+#include <intrin.h>
+
#include "base/macros.h"
#if defined(ARCH_CPU_64_BITS)
@@ -23,10 +25,32 @@
namespace base {
namespace subtle {
+#if defined(_M_X64)
+#pragma intrinsic(_InterlockedCompareExchange)
Sigurður Ásgeirsson 2014/06/03 15:03:08 Stupid question, but why do you need to declare th
Sébastien Marchand 2014/06/03 19:58:45 I don't need to, I've looked at 'sandbox/win/src/s
+#pragma intrinsic(_InterlockedExchange)
+#pragma intrinsic(_InterlockedExchangeAdd)
+
+#elif defined(_M_IX86)
+extern "C" long _InterlockedCompareExchange(long volatile* destination,
+ long exchange, long comperand);
+#pragma intrinsic(_InterlockedCompareExchange)
+
+extern "C" long _InterlockedExchange(long volatile* destination, long exchange);
+#pragma intrinsic(_InterlockedExchange)
+
+extern "C" long _InterlockedExchangeAdd(long volatile* destination,
+ long increment);
+#pragma intrinsic(_InterlockedExchangeAdd)
+
+#else
+#error Architecture not supported.
+
+#endif
+
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
- LONG result = InterlockedCompareExchange(
+ LONG result = _InterlockedCompareExchange(
Sigurður Ásgeirsson 2014/06/03 15:03:08 maybe a one-line comment that Interlocked* doesn't
Sébastien Marchand 2014/06/03 19:58:45 Done.
reinterpret_cast<volatile LONG*>(ptr),
static_cast<LONG>(new_value),
static_cast<LONG>(old_value));
@@ -35,7 +59,7 @@ inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
Atomic32 new_value) {
- LONG result = InterlockedExchange(
+ LONG result = _InterlockedExchange(
reinterpret_cast<volatile LONG*>(ptr),
static_cast<LONG>(new_value));
return static_cast<Atomic32>(result);
@@ -43,7 +67,7 @@ inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
Atomic32 increment) {
- return InterlockedExchangeAdd(
+ return _InterlockedExchangeAdd(
reinterpret_cast<volatile LONG*>(ptr),
static_cast<LONG>(increment)) + increment;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698