Index: webrtc/base/atomicops.h |
diff --git a/webrtc/base/atomicops.h b/webrtc/base/atomicops.h |
index b21bd999f304d2f9cd9742fceebd80b3722e7ce3..42b87097df845a68ba9ec0ca69df2dded0778f93 100644 |
--- a/webrtc/base/atomicops.h |
+++ b/webrtc/base/atomicops.h |
@@ -43,6 +43,16 @@ class AtomicOps { |
new_value, |
old_value); |
} |
+ // Pointer variants. |
+ template <typename T> |
+ static T* AtomicLoadPtr(T* volatile* ptr) { |
+ return *ptr; |
+ } |
+ template <typename T> |
+ static T* CompareAndSwapPtr(T* volatile* ptr, T* old_value, T* new_value) { |
+ return static_cast<T*>(::InterlockedCompareExchangePointer( |
+ reinterpret_cast<PVOID volatile*>(ptr), old_value, new_value)); |
+ } |
#else |
static int Increment(volatile int* i) { |
return __sync_add_and_fetch(i, 1); |
@@ -59,6 +69,15 @@ class AtomicOps { |
static int CompareAndSwap(volatile int* i, int old_value, int new_value) { |
return __sync_val_compare_and_swap(i, old_value, new_value); |
} |
+ // Pointer variants. |
+ template <typename T> |
+ static T* AtomicLoadPtr(T* volatile* ptr) { |
+ return __atomic_load_n(ptr, __ATOMIC_ACQUIRE); |
+ } |
+ template <typename T> |
+ static T* CompareAndSwapPtr(T* volatile* ptr, T* old_value, T* new_value) { |
+ return __sync_val_compare_and_swap(ptr, old_value, new_value); |
+ } |
#endif |
}; |