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

Side by Side Diff: include/ports/SkAtomics_std.h

Issue 896553002: Atomics overhaul. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: warning Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « include/ports/SkAtomics_atomic.h ('k') | include/ports/SkAtomics_sync.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #ifndef SkAtomics_std_DEFINED
2 #define SkAtomics_std_DEFINED
3
4 // We try not to depend on the C++ standard library,
5 // but these uses of <atomic> should all inline, so we don't feel to bad here.
6 #include <atomic>
7
8 template <typename T>
9 T sk_atomic_load(const T* ptr, sk_memory_order mo) {
10 const std::atomic<T>* ap = reinterpret_cast<const std::atomic<T>*>(ptr);
11 return std::atomic_load_explicit(ap, (std::memory_order)mo);
12 }
13
14 template <typename T>
15 void sk_atomic_store(T* ptr, T val, sk_memory_order mo) {
16 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr);
17 return std::atomic_store_explicit(ap, val, (std::memory_order)mo);
18 }
19
20 template <typename T>
21 T sk_atomic_fetch_add(T* ptr, T val, sk_memory_order mo) {
22 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr);
23 return std::atomic_fetch_add_explicit(ap, val, (std::memory_order)mo);
24 }
25
26 template <typename T>
27 bool sk_atomic_compare_exchange(T* ptr, T* expected, T desired,
28 sk_memory_order success,
29 sk_memory_order failure) {
30 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr);
31 return std::atomic_compare_exchange_strong_explicit(ap, expected, desired,
32 (std::memory_order)succe ss,
33 (std::memory_order)failu re);
34 }
35
36 #endif//SkAtomics_std_DEFINED
OLDNEW
« 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