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