diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-27 15:55:35 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-27 15:55:35 +0000 |
commit | 64f6d154511fc840e9a2db1f17699fd5799f7917 (patch) | |
tree | c7f62c88a589d19c840652c250b175feb6603b75 /src | |
parent | e8765c46540041240dd9bc3eedaeb6956ddc4ff1 (diff) |
Use SkAtomics_sync on Android
Every doc I've found about using Android's atomics says, "stop".
"* A handful of basic atomic operations. The appropriate pthread
* functions should be used instead of these whenever possible."
"... we recommend stopping from using these functions entirely. Very fortunately, GCC provides handy intrinsics functions that work with very reasonable performance and always provide a full barrier."
As far as I can tell, there's no code generation change here: both the __sync atomics and the android_ atomics use full memory barriers. (And now with this all unified, it'll be easier to get the real wins by switching everything to __atomic atomics, which are like __sync atomics but allow control over memory barriers.)
BUG=skia:
R=bungeman@google.com, djsollen@google.com, mtklein@google.com, reed@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/305593002
git-svn-id: http://skia.googlecode.com/svn/trunk@14896 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/ports/SkAtomics_android.h | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/ports/SkAtomics_android.h b/src/ports/SkAtomics_android.h deleted file mode 100644 index 5025099cbb..0000000000 --- a/src/ports/SkAtomics_android.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef SkAtomics_android_DEFINED -#define SkAtomics_android_DEFINED - -/** Android framework atomics. */ - -#include <cutils/atomic.h> -#include <stdint.h> - -static inline __attribute__((always_inline)) int32_t sk_atomic_inc(int32_t* addr) { - return android_atomic_inc(addr); -} - -static inline __attribute__((always_inline)) int32_t sk_atomic_add(int32_t* addr, int32_t inc) { - return android_atomic_add(inc, addr); -} - -static inline __attribute__((always_inline)) int32_t sk_atomic_dec(int32_t* addr) { - return android_atomic_dec(addr); -} - -static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomic_dec() { - //HACK: Android is actually using full memory barriers. - // Should this change, uncomment below. - //int dummy; - //android_atomic_acquire_store(0, &dummy); -} - -static inline __attribute__((always_inline)) bool sk_atomic_cas(int32_t* addr, - int32_t before, - int32_t after) { - // android_atomic_release_cas returns 0 for success (if *addr == before and it wrote after). - return android_atomic_release_cas(before, after, addr) == 0; -} - -static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomic_conditional_inc() { - //HACK: Android is actually using full memory barriers. - // Should this change, uncomment below. - //int dummy; - //android_atomic_acquire_store(0, &dummy); -} - -#endif |