--- webkitgtk-2.0.0/configure.ac.orig 2013-04-12 08:25:14.896829422 +0200 +++ webkitgtk-2.0.0/configure.ac 2013-04-12 08:27:21.244776999 +0200 @@ -32,6 +32,18 @@ AM_INIT_AUTOMAKE([foreign subdir-objects dist-xz no-dist-gzip tar-ustar]) m4_include([Source/autotools/SetupAutomake.m4]) +dnl Check whether the target supports 64-bit __sync_*_compare_and_swap. +AC_TRY_LINK([#include ], + [uint64_t foo, bar; + bar = __sync_val_compare_and_swap(&foo, 0, 1);], + wtf_cv_have_64bit_sync_builtins=yes, + wtf_cv_have_64bit_sync_builtins=no) + +if test $wtf_cv_have_64bit_sync_builtins = yes; then + AC_DEFINE(HAVE_64BIT_SYNC_BUILTINS, 1, + [Define to 1 if the target supports 64-bit __sync_*_compare_and_swap]) +fi + ###################################################################################### # Processing of configuration files ###################################################################################### --- webkitgtk-2.0.0/Source/WTF/wtf/Atomics.h~ 2013-04-12 08:05:55.951740895 +0200 +++ webkitgtk-2.0.0/Source/WTF/wtf/Atomics.h 2013-04-12 08:22:46.701992338 +0200 @@ -70,6 +70,9 @@ #elif OS(ANDROID) #include #endif +#ifndef HAVE_64BIT_SYNC_BUILTINS +#include +#endif namespace WTF { @@ -113,8 +113,15 @@ inline int atomicIncrement(int volatile* addend) { return __sync_add_and_fetch(addend, 1); } inline int atomicDecrement(int volatile* addend) { return __sync_sub_and_fetch(addend, 1); } +#ifdef HAVE_64BIT_SYNC_BUILTINS inline int64_t atomicIncrement(int64_t volatile* addend) { return __sync_add_and_fetch(addend, 1); } inline int64_t atomicDecrement(int64_t volatile* addend) { return __sync_sub_and_fetch(addend, 1); } +#else +static pthread_mutex_t global_wtf_lock = PTHREAD_MUTEX_INITIALIZER; + +inline int64_t atomicIncrement(int64_t volatile* addend) { pthread_mutex_lock(&global_wtf_lock); int64_t v = (*addend)++; pthread_mutex_unlock(&global_wtf_lock); return v; } +inline int64_t atomicDecrement(int64_t volatile* addend) { pthread_mutex_lock(&global_wtf_lock); int64_t v = (*addend)--; pthread_mutex_unlock(&global_wtf_lock); return v; } +#endif #endif