Fix broken android framework builds where 32-bit MIPS compilers lack 64-bit __sync operators. R=mtklein@google.com, reed@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/398153002
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi index 2e8bf3c..55651de 100644 --- a/gyp/common_conditions.gypi +++ b/gyp/common_conditions.gypi
@@ -363,8 +363,6 @@ 'IGNORE_ROT_AA_RECT_OPT', 'SkLONGLONG int64_t', 'SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024)', - 'SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_sync.h"', - 'SK_MUTEX_PLATFORM_H "../../src/ports/SkMutex_pthread.h"', # Transitional, for deprecated SkCanvas::SaveFlags methods. 'SK_ATTR_DEPRECATED=SK_NOTHING_ARG1', 'SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)',
diff --git a/src/ports/SkAtomics_sync.h b/src/ports/SkAtomics_sync.h index ed9e3d1..6355082 100644 --- a/src/ports/SkAtomics_sync.h +++ b/src/ports/SkAtomics_sync.h
@@ -17,7 +17,15 @@ } static inline __attribute__((always_inline)) int64_t sk_atomic_inc(int64_t* addr) { +#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(__mips__) && !defined(__LP64__) + /** The 32-bit MIPS toolchain for the android framework is missing support + * for __sync* functions that operate on 64-bit values. The workaround is + * to use __atomic* functions until we can move everything to <stdatomic.h>. + */ + return __atomic_fetch_add(addr, 1, __ATOMIC_SEQ_CST); +#else return __sync_fetch_and_add(addr, 1); +#endif } static inline __attribute__((always_inline)) int32_t sk_atomic_add(int32_t* addr, int32_t inc) {