OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkAtomics_DEFINED | 8 #ifndef SkAtomics_DEFINED |
9 #define SkAtomics_DEFINED | 9 #define SkAtomics_DEFINED |
10 | 10 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr); | 146 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr); |
147 return std::atomic_exchange_explicit(ap, val, (std::memory_order)mo); | 147 return std::atomic_exchange_explicit(ap, val, (std::memory_order)mo); |
148 } | 148 } |
149 | 149 |
150 // ~~~~~~~~ Legacy APIs ~~~~~~~~~ | 150 // ~~~~~~~~ Legacy APIs ~~~~~~~~~ |
151 | 151 |
152 // From here down we have shims for our old atomics API, to be weaned off of. | 152 // From here down we have shims for our old atomics API, to be weaned off of. |
153 // We use the default sequentially-consistent memory order to make things simple | 153 // We use the default sequentially-consistent memory order to make things simple |
154 // and to match the practical reality of our old _sync and _win implementations. | 154 // and to match the practical reality of our old _sync and _win implementations. |
155 | 155 |
156 inline int32_t sk_atomic_inc(int32_t* ptr) { return sk_atomic_fetch_a
dd(ptr, +1); } | 156 inline int32_t sk_atomic_inc(int32_t* ptr) { return sk_atomic_fetch_add(ptr, +1)
; } |
157 inline int32_t sk_atomic_dec(int32_t* ptr) { return sk_atomic_fetch_a
dd(ptr, -1); } | 157 inline int32_t sk_atomic_dec(int32_t* ptr) { return sk_atomic_fetch_add(ptr, -1)
; } |
158 inline int32_t sk_atomic_add(int32_t* ptr, int32_t v) { return sk_atomic_fetch_a
dd(ptr, v); } | |
159 | |
160 inline int64_t sk_atomic_inc(int64_t* ptr) { return sk_atomic_fetch_add<int64_t>
(ptr, +1); } | |
161 | 158 |
162 #endif//SkAtomics_DEFINED | 159 #endif//SkAtomics_DEFINED |
OLD | NEW |