Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: src/ports/SkAtomics_android.h

Issue 123093002: Use a spinlock in SkOnce. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comments Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkOnce.h ('k') | src/ports/SkAtomics_none.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 SkAtomics_android_DEFINED 8 #ifndef SkAtomics_android_DEFINED
9 #define SkAtomics_android_DEFINED 9 #define SkAtomics_android_DEFINED
10 10
(...skipping 18 matching lines...) Expand all
29 int32_t value = *addr; 29 int32_t value = *addr;
30 if (value == 0) { 30 if (value == 0) {
31 return 0; 31 return 0;
32 } 32 }
33 if (0 == android_atomic_release_cas(value, value + 1, addr)) { 33 if (0 == android_atomic_release_cas(value, value + 1, addr)) {
34 return value; 34 return value;
35 } 35 }
36 } 36 }
37 } 37 }
38 38
39 static inline __attribute___((always_inline)) bool sk_atomic_cas(int32_t* addr,
40 int32_t before,
41 int32_t after) {
42 // android_atomic_release_cas returns 0 for success (if *addr == before and it wrote after).
43 return android_atomic_release_cas(before, after, addr) == 0;
44 }
45
39 static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomi c_conditional_inc() { 46 static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomi c_conditional_inc() {
40 //HACK: Android is actually using full memory barriers. 47 //HACK: Android is actually using full memory barriers.
41 // Should this change, uncomment below. 48 // Should this change, uncomment below.
42 //int dummy; 49 //int dummy;
43 //android_atomic_acquire_store(0, &dummy); 50 //android_atomic_acquire_store(0, &dummy);
44 } 51 }
45 52
46 #endif 53 #endif
OLDNEW
« no previous file with comments | « src/core/SkOnce.h ('k') | src/ports/SkAtomics_none.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698