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

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

Issue 305593002: Use SkAtomics_sync on Android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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 | « include/core/SkPostConfig.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkAtomics_android_DEFINED
9 #define SkAtomics_android_DEFINED
10
11 /** Android framework atomics. */
12
13 #include <cutils/atomic.h>
14 #include <stdint.h>
15
16 static inline __attribute__((always_inline)) int32_t sk_atomic_inc(int32_t* addr ) {
17 return android_atomic_inc(addr);
18 }
19
20 static inline __attribute__((always_inline)) int32_t sk_atomic_add(int32_t* addr , int32_t inc) {
21 return android_atomic_add(inc, addr);
22 }
23
24 static inline __attribute__((always_inline)) int32_t sk_atomic_dec(int32_t* addr ) {
25 return android_atomic_dec(addr);
26 }
27
28 static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomi c_dec() {
29 //HACK: Android is actually using full memory barriers.
30 // Should this change, uncomment below.
31 //int dummy;
32 //android_atomic_acquire_store(0, &dummy);
33 }
34
35 static inline __attribute__((always_inline)) bool sk_atomic_cas(int32_t* addr,
36 int32_t before,
37 int32_t after) {
38 // android_atomic_release_cas returns 0 for success (if *addr == before and it wrote after).
39 return android_atomic_release_cas(before, after, addr) == 0;
40 }
41
42 static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomi c_conditional_inc() {
43 //HACK: Android is actually using full memory barriers.
44 // Should this change, uncomment below.
45 //int dummy;
46 //android_atomic_acquire_store(0, &dummy);
47 }
48
49 #endif
OLDNEW
« no previous file with comments | « include/core/SkPostConfig.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698