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 19808007: Split atomic and mutex implementations and make inlinable. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Address dependency comments. Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « include/gpu/GrBackendEffectFactory.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
(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 #define sk_atomic_inc(addr) android_atomic_inc(addr)
17 #define sk_atomic_add(addr, inc) android_atomic_add(inc, addr)
18 #define sk_atomic_dec(addr) android_atomic_dec(addr)
19
20 static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomi c_dec() {
21 //HACK: Android is actually using full memory barriers.
22 // Should this change, uncomment below.
23 //int dummy;
24 //android_atomic_acquire_store(0, &dummy);
25 }
26
27 static inline __attribute__((always_inline)) int32_t sk_atomic_conditional_inc(i nt32_t* addr) {
28 while (true) {
29 int32_t value = *addr;
30 if (value == 0) {
31 return 0;
32 }
33 if (0 == android_atomic_release_cas(value, value + 1, addr)) {
34 return value;
35 }
36 }
37 }
38
39 static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomi c_conditional_inc() {
40 //HACK: Android is actually using full memory barriers.
41 // Should this change, uncomment below.
42 //int dummy;
43 //android_atomic_acquire_store(0, &dummy);
44 }
45
46 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrBackendEffectFactory.h ('k') | src/ports/SkAtomics_none.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698