OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 SkOnce_DEFINED | 8 #ifndef SkOnce_DEFINED |
9 #define SkOnce_DEFINED | 9 #define SkOnce_DEFINED |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 inline static void compiler_barrier() { | 78 inline static void compiler_barrier() { |
79 _ReadWriteBarrier(); | 79 _ReadWriteBarrier(); |
80 } | 80 } |
81 #else | 81 #else |
82 inline static void compiler_barrier() { | 82 inline static void compiler_barrier() { |
83 asm volatile("" : : : "memory"); | 83 asm volatile("" : : : "memory"); |
84 } | 84 } |
85 #endif | 85 #endif |
86 | 86 |
87 inline static void full_barrier_on_arm() { | 87 inline static void full_barrier_on_arm() { |
88 #if (defined(SK_CPU_ARM) && SK_ARM_ARCH >= 7) || defined(SK_CPU_ARM64) | 88 #ifdef SK_CPU_ARM |
89 asm volatile("dmb ish" : : : "memory"); | 89 # if SK_ARM_ARCH >= 7 |
90 #elif defined(SK_CPU_ARM) | 90 asm volatile("dmb" : : : "memory"); |
| 91 # else |
91 asm volatile("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory"); | 92 asm volatile("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory"); |
| 93 # endif |
92 #endif | 94 #endif |
93 } | 95 } |
94 | 96 |
95 // On every platform, we issue a compiler barrier to prevent it from reordering | 97 // On every platform, we issue a compiler barrier to prevent it from reordering |
96 // code. That's enough for platforms like x86 where release and acquire | 98 // code. That's enough for platforms like x86 where release and acquire |
97 // barriers are no-ops. On other platforms we may need to be more careful; | 99 // barriers are no-ops. On other platforms we may need to be more careful; |
98 // ARM, in particular, needs real code for both acquire and release. We use a | 100 // ARM, in particular, needs real code for both acquire and release. We use a |
99 // full barrier, which acts as both, because that the finest precision ARM | 101 // full barrier, which acts as both, because that the finest precision ARM |
100 // provides. | 102 // provides. |
101 | 103 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 170 } |
169 | 171 |
170 template <typename Func, typename Arg> | 172 template <typename Func, typename Arg> |
171 inline void SkOnce(SkOnceFlag* once, Func f, Arg arg, void(*atExit)()) { | 173 inline void SkOnce(SkOnceFlag* once, Func f, Arg arg, void(*atExit)()) { |
172 return SkOnce(&once->done, &once->lock, f, arg, atExit); | 174 return SkOnce(&once->done, &once->lock, f, arg, atExit); |
173 } | 175 } |
174 | 176 |
175 #undef SK_ANNOTATE_BENIGN_RACE | 177 #undef SK_ANNOTATE_BENIGN_RACE |
176 | 178 |
177 #endif // SkOnce_DEFINED | 179 #endif // SkOnce_DEFINED |
OLD | NEW |