| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 SkThread_DEFINED | 8 #ifndef SkThread_DEFINED |
| 9 #define SkThread_DEFINED | 9 #define SkThread_DEFINED |
| 10 | 10 |
| 11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 12 | 12 |
| 13 // SK_ATOMICS_PLATFORM_H must provide inline implementations for the following d
eclarations. | 13 // SK_ATOMICS_PLATFORM_H must provide inline implementations for the following d
eclarations. |
| 14 | 14 |
| 15 /** Atomically adds one to the int referenced by addr and returns the previous v
alue. | 15 /** Atomically adds one to the int referenced by addr and returns the previous v
alue. |
| 16 * No additional memory barrier is required; this must act as a compiler barrie
r. | 16 * No additional memory barrier is required; this must act as a compiler barrie
r. |
| 17 */ | 17 */ |
| 18 static int32_t sk_atomic_inc(int32_t* addr); | 18 static int32_t sk_atomic_inc(int32_t* addr); |
| 19 static int64_t sk_atomic_inc(int64_t* addr); | 19 static int64_t sk_atomic_inc(int64_t* addr); |
| 20 | 20 |
| 21 /** Atomically adds inc to the int referenced by addr and returns the previous v
alue. | 21 /** Atomically adds inc to the int referenced by addr and returns the previous v
alue. |
| 22 * No additional memory barrier is required; this must act as a compiler barrie
r. | 22 * No additional memory barrier is required; this must act as a compiler barrie
r. |
| 23 */ | 23 */ |
| 24 static int32_t sk_atomic_add(int32_t* addr, int32_t inc); | 24 static int32_t sk_atomic_add(int32_t* addr, int32_t inc); |
| 25 static int64_t sk_atomic_add(int64_t* addr, int64_t inc); | |
| 26 | 25 |
| 27 /** Atomically subtracts one from the int referenced by addr and returns the pre
vious value. | 26 /** Atomically subtracts one from the int referenced by addr and returns the pre
vious value. |
| 28 * This must act as a release (SL/S) memory barrier and as a compiler barrier. | 27 * This must act as a release (SL/S) memory barrier and as a compiler barrier. |
| 29 */ | 28 */ |
| 30 static int32_t sk_atomic_dec(int32_t* addr); | 29 static int32_t sk_atomic_dec(int32_t* addr); |
| 31 static int64_t sk_atomic_dec(int64_t* addr); | |
| 32 | 30 |
| 33 /** Atomic compare and set. | 31 /** Atomic compare and set. |
| 34 * If *addr == before, set *addr to after and return true, otherwise return fal
se. | 32 * If *addr == before, set *addr to after and return true, otherwise return fal
se. |
| 35 * This must act as a release (SL/S) memory barrier and as a compiler barrier. | 33 * This must act as a release (SL/S) memory barrier and as a compiler barrier. |
| 36 */ | 34 */ |
| 37 static bool sk_atomic_cas(int32_t* addr, int32_t before, int32_t after); | 35 static bool sk_atomic_cas(int32_t* addr, int32_t before, int32_t after); |
| 38 static bool sk_atomic_cas(int64_t* addr, int64_t before, int64_t after); | |
| 39 | 36 |
| 40 /** If sk_atomic_dec does not act as an acquire (L/SL) barrier, | 37 /** If sk_atomic_dec does not act as an acquire (L/SL) barrier, |
| 41 * this must act as an acquire (L/SL) memory barrier and as a compiler barrier. | 38 * this must act as an acquire (L/SL) memory barrier and as a compiler barrier. |
| 42 */ | 39 */ |
| 43 static void sk_membar_acquire__after_atomic_dec(); | 40 static void sk_membar_acquire__after_atomic_dec(); |
| 44 | 41 |
| 45 /** If sk_atomic_conditional_inc does not act as an acquire (L/SL) barrier, | 42 /** If sk_atomic_conditional_inc does not act as an acquire (L/SL) barrier, |
| 46 * this must act as an acquire (L/SL) memory barrier and as a compiler barrier. | 43 * this must act as an acquire (L/SL) memory barrier and as a compiler barrier. |
| 47 */ | 44 */ |
| 48 static void sk_membar_acquire__after_atomic_conditional_inc(); | 45 static void sk_membar_acquire__after_atomic_conditional_inc(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 SkASSERT(fMutex); | 135 SkASSERT(fMutex); |
| 139 fMutex->assertHeld(); | 136 fMutex->assertHeld(); |
| 140 } | 137 } |
| 141 | 138 |
| 142 private: | 139 private: |
| 143 SkBaseMutex* fMutex; | 140 SkBaseMutex* fMutex; |
| 144 }; | 141 }; |
| 145 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) | 142 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) |
| 146 | 143 |
| 147 #endif | 144 #endif |
| OLD | NEW |