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

Unified Diff: include/ports/SkAtomics_std.h

Issue 1348113004: Add subtract to atomics. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 | « include/ports/SkAtomics_atomic.h ('k') | include/ports/SkAtomics_sync.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/ports/SkAtomics_std.h
diff --git a/include/ports/SkAtomics_std.h b/include/ports/SkAtomics_std.h
index 4c26858dfda4b0b22be881b3be7b37b05a9e2d26..163efb78c0c1019942986ea4c3eaca8d5a049bb5 100644
--- a/include/ports/SkAtomics_std.h
+++ b/include/ports/SkAtomics_std.h
@@ -39,6 +39,13 @@ T sk_atomic_fetch_add(T* ptr, T val, sk_memory_order mo) {
}
template <typename T>
+T sk_atomic_fetch_sub(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_fetch_sub_explicit(ap, val, (std::memory_order)mo);
+}
+
+template <typename T>
bool sk_atomic_compare_exchange(T* ptr, T* expected, T desired,
sk_memory_order success,
sk_memory_order failure) {
« no previous file with comments | « include/ports/SkAtomics_atomic.h ('k') | include/ports/SkAtomics_sync.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698