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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 } | 81 } |
82 static inline __attribute__((always_inline)) void sk_membar_aquire__after_atomic _conditional_inc() { | 82 static inline __attribute__((always_inline)) void sk_membar_aquire__after_atomic _conditional_inc() { |
83 //HACK: Android is actually using full memory barriers. | 83 //HACK: Android is actually using full memory barriers. |
84 // Should this change, uncomment below. | 84 // Should this change, uncomment below. |
85 //int dummy; | 85 //int dummy; |
86 //android_atomic_aquire_store(0, &dummy); | 86 //android_atomic_aquire_store(0, &dummy); |
87 } | 87 } |
88 | 88 |
89 #endif // SK_BUILD_FOR_ANDROID_FRAMEWORK | 89 #endif // SK_BUILD_FOR_ANDROID_FRAMEWORK |
90 | 90 |
91 int32_t sk_atomic_unprotected_read(const volatile int32_t & x) { | |
bsalomon
2013/07/15 13:04:08
We've got several implementations of this that are
bungeman-skia
2013/07/15 16:02:41
Yes, we need to clean this up in general. Note tha
| |
92 return x; | |
93 } | |
94 | |
91 #else // !SK_BUILD_FOR_ANDROID | 95 #else // !SK_BUILD_FOR_ANDROID |
92 | 96 |
93 /** Implemented by the porting layer, this function adds one to the int | 97 /** Implemented by the porting layer, this function adds one to the int |
94 specified by the address (in a thread-safe manner), and returns the | 98 specified by the address (in a thread-safe manner), and returns the |
95 previous value. | 99 previous value. |
96 No additional memory barrier is required. | 100 No additional memory barrier is required. |
97 This must act as a compiler barrier. | 101 This must act as a compiler barrier. |
98 */ | 102 */ |
99 SK_API int32_t sk_atomic_inc(int32_t* addr); | 103 SK_API int32_t sk_atomic_inc(int32_t* addr); |
100 | 104 |
(...skipping 22 matching lines...) Expand all Loading... | |
123 No additional memory barrier is required. | 127 No additional memory barrier is required. |
124 This must act as a compiler barrier. | 128 This must act as a compiler barrier. |
125 */ | 129 */ |
126 SK_API int32_t sk_atomic_conditional_inc(int32_t*); | 130 SK_API int32_t sk_atomic_conditional_inc(int32_t*); |
127 /** If sk_atomic_conditional_inc does not act as an aquire (L/SL) barrier, this | 131 /** If sk_atomic_conditional_inc does not act as an aquire (L/SL) barrier, this |
128 is expected to act as an aquire (L/SL) memory barrier and as a compiler | 132 is expected to act as an aquire (L/SL) memory barrier and as a compiler |
129 barrier. | 133 barrier. |
130 */ | 134 */ |
131 SK_API void sk_membar_aquire__after_atomic_conditional_inc(); | 135 SK_API void sk_membar_aquire__after_atomic_conditional_inc(); |
132 | 136 |
137 /** Forces an atomic read of 'x' and marks the read as a benign race. | |
138 No additional memory barrier is required. | |
139 This does not need to act as a compiler barrier. | |
140 */ | |
141 SK_API int32_t sk_atomic_unprotected_read(const volatile int32_t & x); | |
142 | |
133 #endif // !SK_BUILD_FOR_ANDROID | 143 #endif // !SK_BUILD_FOR_ANDROID |
134 | 144 |
135 #ifdef SK_USE_POSIX_THREADS | 145 #ifdef SK_USE_POSIX_THREADS |
136 | 146 |
137 #include <pthread.h> | 147 #include <pthread.h> |
138 | 148 |
139 // A SkBaseMutex is a POD structure that can be directly initialized | 149 // A SkBaseMutex is a POD structure that can be directly initialized |
140 // at declaration time with SK_DECLARE_STATIC/GLOBAL_MUTEX. This avoids the | 150 // at declaration time with SK_DECLARE_STATIC/GLOBAL_MUTEX. This avoids the |
141 // generation of a static initializer in the final machine code (and | 151 // generation of a static initializer in the final machine code (and |
142 // a corresponding static finalizer). | 152 // a corresponding static finalizer). |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 | 195 |
186 typedef SkMutex SkBaseMutex; | 196 typedef SkMutex SkBaseMutex; |
187 | 197 |
188 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name | 198 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name |
189 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name | 199 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name |
190 | 200 |
191 #endif // !SK_USE_POSIX_THREADS | 201 #endif // !SK_USE_POSIX_THREADS |
192 | 202 |
193 | 203 |
194 #endif | 204 #endif |
OLD | NEW |