Index: include/ports/SkAtomics_std.h |
diff --git a/include/ports/SkAtomics_std.h b/include/ports/SkAtomics_std.h |
index e89d74981c449c228899419591c717fb3077155f..4c26858dfda4b0b22be881b3be7b37b05a9e2d26 100644 |
--- a/include/ports/SkAtomics_std.h |
+++ b/include/ports/SkAtomics_std.h |
@@ -1,3 +1,10 @@ |
+/* |
+ * Copyright 2015 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
#ifndef SkAtomics_std_DEFINED |
#define SkAtomics_std_DEFINED |
@@ -47,4 +54,11 @@ bool sk_atomic_compare_exchange(T* ptr, T* expected, T desired, |
(std::memory_order)failure); |
} |
+template <typename T> |
+T sk_atomic_exchange(T* ptr, T val, sk_memory_order mo) { |
+ // All values of mo are valid. |
+ std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr); |
+ return std::atomic_exchange_explicit(ap, val, (std::memory_order)mo); |
+} |
+ |
#endif//SkAtomics_std_DEFINED |