Index: src/ports/SkAtomics_mips32.h |
diff --git a/src/ports/SkAtomics_sync.h b/src/ports/SkAtomics_mips32.h |
similarity index 71% |
copy from src/ports/SkAtomics_sync.h |
copy to src/ports/SkAtomics_mips32.h |
index 8135ae2e2ae28714bc6d133fa25c2c318231a86b..72fa5d59ed92d8dbf73fc6cd0acaa1425e045138 100644 |
--- a/src/ports/SkAtomics_sync.h |
+++ b/src/ports/SkAtomics_mips32.h |
@@ -1,14 +1,18 @@ |
/* |
- * Copyright 2013 Google Inc. |
+ * Copyright 2014 Google Inc. |
* |
* Use of this source code is governed by a BSD-style license that can be |
* found in the LICENSE file. |
*/ |
-#ifndef SkAtomics_sync_DEFINED |
-#define SkAtomics_sync_DEFINED |
+#ifndef SkAtomics_mips32_DEFINED |
+#define SkAtomics_mips32_DEFINED |
-/** GCC/Clang __sync based atomics. */ |
+/** Similar to SkAtomics_sync but the 32-bit MIPS toolchains for the android |
+ * framework are missing support for __sync* functions that operate on 64-bit |
+ * values. Instead these functions uses __atomic to work around those specific |
scroggo
2014/07/16 19:16:25
use*
|
+ * issues until we can move to <stdatomic.h>. |
+ */ |
#include <stdint.h> |
@@ -17,7 +21,7 @@ static inline __attribute__((always_inline)) int32_t sk_atomic_inc(int32_t* addr |
} |
static inline __attribute__((always_inline)) int64_t sk_atomic_inc(int64_t* addr) { |
- return __sync_fetch_and_add(addr, 1); |
+ return __atomic_fetch_add(addr, 1, __ATOMIC_SEQ_CST); |
} |
static inline __attribute__((always_inline)) int32_t sk_atomic_add(int32_t* addr, int32_t inc) { |
@@ -33,7 +37,7 @@ static inline __attribute__((always_inline)) int32_t sk_atomic_dec(int32_t* addr |
} |
static inline __attribute__((always_inline)) int64_t sk_atomic_dec(int64_t* addr) { |
- return __sync_fetch_and_add(addr, -1); |
+ return __atomic_fetch_add(addr, -1, __ATOMIC_SEQ_CST); |
} |
static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomic_dec() { } |
@@ -47,7 +51,10 @@ static inline __attribute__((always_inline)) bool sk_atomic_cas(int32_t* addr, |
static inline __attribute__((always_inline)) bool sk_atomic_cas(int64_t* addr, |
int64_t before, |
int64_t after) { |
- return __sync_bool_compare_and_swap(addr, before, after); |
+ return __atomic_compare_exchange_n(addr, &before, after, |
+ false /*strong*/, |
+ __ATOMIC_SEQ_CST /*on success*/, |
+ __ATOMIC_SEQ_CST /*on failure*/); |
} |
static inline __attribute__((always_inline)) void* sk_atomic_cas(void** addr, |