| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkThread_platform_DEFINED | 10 #ifndef SkThread_platform_DEFINED |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #else // !SK_BUILD_FOR_ANDROID_NDK | 54 #else // !SK_BUILD_FOR_ANDROID_NDK |
| 55 | 55 |
| 56 /* The platform atomics operations are slightly more efficient than the | 56 /* The platform atomics operations are slightly more efficient than the |
| 57 * GCC built-ins, so use them. | 57 * GCC built-ins, so use them. |
| 58 */ | 58 */ |
| 59 #include <utils/Atomic.h> | 59 #include <utils/Atomic.h> |
| 60 | 60 |
| 61 #define sk_atomic_inc(addr) android_atomic_inc(addr) | 61 #define sk_atomic_inc(addr) android_atomic_inc(addr) |
| 62 #define sk_atomic_add(addr, inc) android_atomic_add(inc, addr) | 62 #define sk_atomic_add(addr, inc) android_atomic_add(inc, addr) |
| 63 #define sk_atomic_dec(addr) android_atomic_dec(addr) | 63 #define sk_atomic_dec(addr) android_atomic_dec(addr) |
| 64 void sk_membar_aquire__after_atomic_dec() { | 64 |
| 65 static inline __attribute__((always_inline)) void sk_membar_aquire__after_atomic
_dec() { |
| 65 //HACK: Android is actually using full memory barriers. | 66 //HACK: Android is actually using full memory barriers. |
| 66 // Should this change, uncomment below. | 67 // Should this change, uncomment below. |
| 67 //int dummy; | 68 //int dummy; |
| 68 //android_atomic_aquire_store(0, &dummy); | 69 //android_atomic_aquire_store(0, &dummy); |
| 69 } | 70 } |
| 70 int32_t sk_atomic_conditional_inc(int32_t* addr) { | 71 static inline __attribute__((always_inline)) int32_t sk_atomic_conditional_inc(i
nt32_t* addr) { |
| 71 while (true) { | 72 while (true) { |
| 72 int32_t value = *addr; | 73 int32_t value = *addr; |
| 73 if (value == 0) { | 74 if (value == 0) { |
| 74 return 0; | 75 return 0; |
| 75 } | 76 } |
| 76 if (0 == android_atomic_release_cas(value, value + 1, addr)) { | 77 if (0 == android_atomic_release_cas(value, value + 1, addr)) { |
| 77 return value; | 78 return value; |
| 78 } | 79 } |
| 79 } | 80 } |
| 80 } | 81 } |
| 81 void sk_membar_aquire__after_atomic_conditional_inc() { | 82 static inline __attribute__((always_inline)) void sk_membar_aquire__after_atomic
_conditional_inc() { |
| 82 //HACK: Android is actually using full memory barriers. | 83 //HACK: Android is actually using full memory barriers. |
| 83 // Should this change, uncomment below. | 84 // Should this change, uncomment below. |
| 84 //int dummy; | 85 //int dummy; |
| 85 //android_atomic_aquire_store(0, &dummy); | 86 //android_atomic_aquire_store(0, &dummy); |
| 86 } | 87 } |
| 87 | 88 |
| 88 #endif // !SK_BUILD_FOR_ANDROID_NDK | 89 #endif // !SK_BUILD_FOR_ANDROID_NDK |
| 89 | 90 |
| 90 #else // !SK_BUILD_FOR_ANDROID | 91 #else // !SK_BUILD_FOR_ANDROID |
| 91 | 92 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 typedef SkMutex SkBaseMutex; | 188 typedef SkMutex SkBaseMutex; |
| 188 | 189 |
| 189 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name | 190 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name |
| 190 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name | 191 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name |
| 191 #define SK_DECLARE_MUTEX_ARRAY(name, count) SkBaseMutex name[count] | 192 #define SK_DECLARE_MUTEX_ARRAY(name, count) SkBaseMutex name[count] |
| 192 | 193 |
| 193 #endif // !SK_USE_POSIX_THREADS | 194 #endif // !SK_USE_POSIX_THREADS |
| 194 | 195 |
| 195 | 196 |
| 196 #endif | 197 #endif |
| OLD | NEW |