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

Unified Diff: src/ports/SkAtomics_mips32.h

Issue 398153002: Fix broken android framework builds where 32-bit MIPS compilers lack 64-bit __sync operators. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« include/core/SkPostConfig.h ('K') | « include/core/SkPostConfig.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« include/core/SkPostConfig.h ('K') | « include/core/SkPostConfig.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698