Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libgc
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2013-02-23 01:25:21 +0400
committerMiguel de Icaza <miguel@gnome.org>2013-02-23 01:25:21 +0400
commit7899d2f452fadddaa6e505bd89690aaa67d56b40 (patch)
treef8e180f70836926cdfab60eefea7f4240ff3d79f /libgc
parentdd5e72a46ff2fb187db84c1392692b0523008b60 (diff)
parent8b3f25b841abc803d62af28424f22cd3383e688f (diff)
Merge pull request #554 from deplinenoise/ppc_fixes
PPC build fixes
Diffstat (limited to 'libgc')
-rw-r--r--libgc/configure.in16
-rw-r--r--libgc/include/private/gc_locks.h8
2 files changed, 24 insertions, 0 deletions
diff --git a/libgc/configure.in b/libgc/configure.in
index be6f6d4259b..837e2cb9f15 100644
--- a/libgc/configure.in
+++ b/libgc/configure.in
@@ -217,6 +217,22 @@ case "$host" in
esac
AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
+# Check if the GCC builtin __sync_bool_compare_and_swap is available.
+# It is preferred in gc_locks.h for PPC as GCC 4.4 has a problem with the inline assembly there.
+AC_MSG_CHECKING(for __sync_bool_compare_and_swap)
+AC_TRY_COMPILE([],[
+volatile unsigned int foo = 0;
+int main(int argc, char** argv) {
+ unsigned int r1 = __sync_bool_compare_and_swap(&foo, 0, 1);
+ return 0;
+}
+], [
+AC_MSG_RESULT(yes)
+AC_DEFINE(HAS___SYNC_BOOL_COMPARE_AND_SWAP)
+], [
+AC_MSG_RESULT(no)
+])
+
AC_MSG_CHECKING(for xlc)
AC_TRY_COMPILE([],[
#ifndef __xlC__
diff --git a/libgc/include/private/gc_locks.h b/libgc/include/private/gc_locks.h
index a45553aa7ca..8705d07a1bb 100644
--- a/libgc/include/private/gc_locks.h
+++ b/libgc/include/private/gc_locks.h
@@ -475,6 +475,9 @@
inline static GC_bool GC_compare_and_exchange(volatile GC_word *addr,
GC_word old, GC_word new_val)
{
+# if HAS___SYNC_BOOL_COMPARE_AND_SWAP
+ return __sync_bool_compare_and_swap(addr, old, new_val);
+# else
unsigned long result, dummy;
__asm__ __volatile__(
"1:\tldarx %0,0,%5\n"
@@ -491,12 +494,16 @@
: "r" (new_val), "r" (old), "2"(addr)
: "cr0","memory");
return (GC_bool) result;
+# endif
}
# else
/* Returns TRUE if the comparison succeeded. */
inline static GC_bool GC_compare_and_exchange(volatile GC_word *addr,
GC_word old, GC_word new_val)
{
+# if HAS___SYNC_BOOL_COMPARE_AND_SWAP
+ return __sync_bool_compare_and_swap(addr, old, new_val);
+# else
int result, dummy;
__asm__ __volatile__(
"1:\tlwarx %0,0,%5\n"
@@ -513,6 +520,7 @@
: "r" (new_val), "r" (old), "2"(addr)
: "cr0","memory");
return (GC_bool) result;
+# endif
}
# endif
# endif /* !GENERIC_COMPARE_AND_SWAP */