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

Side by Side Diff: include/core/SkThread_platform.h

Issue 12739007: refactor android defines to implicitly assume NDK compliance unless it is explicitly marked as bein… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkThread_platform_DEFINED 10 #ifndef SkThread_platform_DEFINED
11 #define SkThread_platform_DEFINED 11 #define SkThread_platform_DEFINED
12 12
13 #if defined(SK_BUILD_FOR_ANDROID) 13 #if defined(SK_BUILD_FOR_ANDROID)
14 14
15 #if defined(SK_BUILD_FOR_ANDROID_NDK) 15 #if !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
borenet 2013/03/13 12:08:19 I understand the desire to make as small a modific
djsollen 2013/03/13 12:26:41 I thought of doing that as well, but it makes the
borenet 2013/03/13 12:42:12 SGTM
16 16
17 #include <stdint.h> 17 #include <stdint.h>
18 18
19 /* Just use the GCC atomic intrinsics. They're supported by the NDK toolchain, 19 /* Just use the GCC atomic intrinsics. They're supported by the NDK toolchain,
20 * have reasonable performance, and provide full memory barriers 20 * have reasonable performance, and provide full memory barriers
21 */ 21 */
22 static inline __attribute__((always_inline)) int32_t sk_atomic_inc(int32_t *addr ) { 22 static inline __attribute__((always_inline)) int32_t sk_atomic_inc(int32_t *addr ) {
23 return __sync_fetch_and_add(addr, 1); 23 return __sync_fetch_and_add(addr, 1);
24 } 24 }
25 25
(...skipping 18 matching lines...) Expand all
44 44
45 if (before == value) { 45 if (before == value) {
46 return value; 46 return value;
47 } else { 47 } else {
48 value = before; 48 value = before;
49 } 49 }
50 } 50 }
51 } 51 }
52 static inline __attribute__((always_inline)) void sk_membar_aquire__after_atomic _conditional_inc() { } 52 static inline __attribute__((always_inline)) void sk_membar_aquire__after_atomic _conditional_inc() { }
53 53
54 #else // !SK_BUILD_FOR_ANDROID_NDK 54 #else // SK_BUILD_FOR_ANDROID_FRAMEWORK
55 55
56 /* The platform atomics operations are slightly more efficient than the 56 /* The platform atomics operations are slightly more efficient than the
57 * GCC built-ins, so use them. 57 * GCC built-ins, so use them.
58 */ 58 */
59 #include <utils/Atomic.h> 59 #include <utils/Atomic.h>
60 60
61 #define sk_atomic_inc(addr) android_atomic_inc(addr) 61 #define sk_atomic_inc(addr) android_atomic_inc(addr)
62 #define sk_atomic_add(addr, inc) android_atomic_add(inc, addr) 62 #define sk_atomic_add(addr, inc) android_atomic_add(inc, addr)
63 #define sk_atomic_dec(addr) android_atomic_dec(addr) 63 #define sk_atomic_dec(addr) android_atomic_dec(addr)
64 64
(...skipping 14 matching lines...) Expand all
79 } 79 }
80 } 80 }
81 } 81 }
82 static inline __attribute__((always_inline)) void sk_membar_aquire__after_atomic _conditional_inc() { 82 static inline __attribute__((always_inline)) void sk_membar_aquire__after_atomic _conditional_inc() {
83 //HACK: Android is actually using full memory barriers. 83 //HACK: Android is actually using full memory barriers.
84 // Should this change, uncomment below. 84 // Should this change, uncomment below.
85 //int dummy; 85 //int dummy;
86 //android_atomic_aquire_store(0, &dummy); 86 //android_atomic_aquire_store(0, &dummy);
87 } 87 }
88 88
89 #endif // !SK_BUILD_FOR_ANDROID_NDK 89 #endif // SK_BUILD_FOR_ANDROID_FRAMEWORK
90 90
91 #else // !SK_BUILD_FOR_ANDROID 91 #else // !SK_BUILD_FOR_ANDROID
92 92
93 /** Implemented by the porting layer, this function adds one to the int 93 /** Implemented by the porting layer, this function adds one to the int
94 specified by the address (in a thread-safe manner), and returns the 94 specified by the address (in a thread-safe manner), and returns the
95 previous value. 95 previous value.
96 No additional memory barrier is required. 96 No additional memory barrier is required.
97 This must act as a compiler barrier. 97 This must act as a compiler barrier.
98 */ 98 */
99 SK_API int32_t sk_atomic_inc(int32_t* addr); 99 SK_API int32_t sk_atomic_inc(int32_t* addr);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 typedef SkMutex SkBaseMutex; 188 typedef SkMutex SkBaseMutex;
189 189
190 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name 190 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name
191 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name 191 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name
192 #define SK_DECLARE_MUTEX_ARRAY(name, count) SkBaseMutex name[count] 192 #define SK_DECLARE_MUTEX_ARRAY(name, count) SkBaseMutex name[count]
193 193
194 #endif // !SK_USE_POSIX_THREADS 194 #endif // !SK_USE_POSIX_THREADS
195 195
196 196
197 #endif 197 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698