Commit 79668cdf authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Check whether assembler supports numerical local labels.

2007-11-18  Matthias Clasen  <mclasen@redhat.com>

        * configure.in: Check whether assembler supports numerical local
        labels.

        * glib/gatomic.c: Fix powerpc implementation of atomic ops for
        platforms where the assembler doesn't support numerical local
        labels.  (#445362)


svn path=/trunk/; revision=5861
parent 1e2c77ec
2006-11-15 Ryan Lortie <desrt@desrt.ca>
2007-11-18 Matthias Clasen <mclasen@redhat.com>
* configure.in: Check whether assembler supports numerical local
labels.
* glib/gatomic.c: Fix powerpc implementation of atomic ops for
platforms where the assembler doesn't support numerical local
labels. (#445362)
2007-11-15 Ryan Lortie <desrt@desrt.ca>
* docs/reference/glib/tmpl/markup.sgml:
* glib/gmarkup.h:
......@@ -8,7 +17,7 @@
Closes #496046.
2006-11-15 Ryan Lortie <desrt@desrt.ca>
2007-11-15 Ryan Lortie <desrt@desrt.ca>
* docs/reference/glib/glib-sections.txt:
* glib/glib.symbols:
......
......@@ -2082,6 +2082,17 @@ if test x"$GCC" = xyes; then
AC_DEFINE_UNQUOTED(G_ATOMIC_POWERPC, 1,
[powerpc atomic implementation])
glib_memory_barrier_needed=yes
AC_MSG_CHECKING([whether asm supports numbered local labels])
AC_TRY_COMPILE(
,[
__asm__ __volatile__ ("1: nop\n"
" bne- 1b")
],[
AC_DEFINE_UNQUOTED(ASM_NUMERIC_LABELS, 1, [define if asm blocks can use numeric local labels])
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
])
;;
ia64)
AC_MSG_RESULT([ia64])
......
......@@ -281,6 +281,15 @@ g_atomic_int_exchange_and_add (volatile gint *atomic,
gint val)
{
gint result, temp;
#if ASM_NUMERIC_LABELS
__asm__ __volatile__ ("1: lwarx %0,0,%3\n"
" add %1,%0,%4\n"
" stwcx. %1,0,%3\n"
" bne- 1b"
: "=&b" (result), "=&r" (temp), "=m" (*atomic)
: "b" (atomic), "r" (val), "m" (*atomic)
: "cr0", "memory");
#else
__asm__ __volatile__ (".Lieaa%=: lwarx %0,0,%3\n"
" add %1,%0,%4\n"
" stwcx. %1,0,%3\n"
......@@ -288,6 +297,7 @@ g_atomic_int_exchange_and_add (volatile gint *atomic,
: "=&b" (result), "=&r" (temp), "=m" (*atomic)
: "b" (atomic), "r" (val), "m" (*atomic)
: "cr0", "memory");
#endif
return result;
}
......@@ -297,6 +307,15 @@ g_atomic_int_add (volatile gint *atomic,
gint val)
{
gint result, temp;
#if ASM_NUMERIC_LABELS
__asm__ __volatile__ ("1: lwarx %0,0,%3\n"
" add %1,%0,%4\n"
" stwcx. %1,0,%3\n"
" bne- 1b"
: "=&b" (result), "=&r" (temp), "=m" (*atomic)
: "b" (atomic), "r" (val), "m" (*atomic)
: "cr0", "memory");
#else
__asm__ __volatile__ (".Lia%=: lwarx %0,0,%3\n"
" add %1,%0,%4\n"
" stwcx. %1,0,%3\n"
......@@ -304,6 +323,7 @@ g_atomic_int_add (volatile gint *atomic,
: "=&b" (result), "=&r" (temp), "=m" (*atomic)
: "b" (atomic), "r" (val), "m" (*atomic)
: "cr0", "memory");
#endif
}
# else /* !__OPTIMIZE__ */
gint
......@@ -336,6 +356,18 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic,
gint newval)
{
gint result;
#if ASM_NUMERIC_LABELS
__asm__ __volatile__ ("sync\n"
"1: lwarx %0,0,%1\n"
" subf. %0,%2,%0\n"
" bne 2f\n"
" stwcx. %3,0,%1\n"
" bne- 1b\n"
"2: isync"
: "=&r" (result)
: "b" (atomic), "r" (oldval), "r" (newval)
: "cr0", "memory");
#else
__asm__ __volatile__ ("sync\n"
".L1icae%=: lwarx %0,0,%1\n"
" subf. %0,%2,%0\n"
......@@ -346,6 +378,7 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic,
: "=&r" (result)
: "b" (atomic), "r" (oldval), "r" (newval)
: "cr0", "memory");
#endif
return result == 0;
}
......@@ -355,6 +388,18 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
gpointer newval)
{
gpointer result;
#if ASM_NUMERIC_LABELS
__asm__ __volatile__ ("sync\n"
"1: lwarx %0,0,%1\n"
" subf. %0,%2,%0\n"
" bne 2f\n"
" stwcx. %3,0,%1\n"
" bne- 1b\n"
"2: isync"
: "=&r" (result)
: "b" (atomic), "r" (oldval), "r" (newval)
: "cr0", "memory");
#else
__asm__ __volatile__ ("sync\n"
".L1pcae%=: lwarx %0,0,%1\n"
" subf. %0,%2,%0\n"
......@@ -365,6 +410,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
: "=&r" (result)
: "b" (atomic), "r" (oldval), "r" (newval)
: "cr0", "memory");
#endif
return result == 0;
}
# elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
......@@ -374,6 +420,19 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic,
gint newval)
{
gpointer result;
#if ASM_NUMERIC_LABELS
__asm__ __volatile__ ("sync\n"
"1: lwarx %0,0,%1\n"
" extsw %0,%0\n"
" subf. %0,%2,%0\n"
" bne 2f\n"
" stwcx. %3,0,%1\n"
" bne- 1b\n"
"2: isync"
: "=&r" (result)
: "b" (atomic), "r" (oldval), "r" (newval)
: "cr0", "memory");
#else
__asm__ __volatile__ ("sync\n"
".L1icae%=: lwarx %0,0,%1\n"
" extsw %0,%0\n"
......@@ -385,6 +444,7 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic,
: "=&r" (result)
: "b" (atomic), "r" (oldval), "r" (newval)
: "cr0", "memory");
#endif
return result == 0;
}
......@@ -394,6 +454,18 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
gpointer newval)
{
gpointer result;
#if ASM_NUMERIC_LABELS
__asm__ __volatile__ ("sync\n"
"1: ldarx %0,0,%1\n"
" subf. %0,%2,%0\n"
" bne 2f\n"
" stdcx. %3,0,%1\n"
" bne- 1b\n"
"2: isync"
: "=&r" (result)
: "b" (atomic), "r" (oldval), "r" (newval)
: "cr0", "memory");
#else
__asm__ __volatile__ ("sync\n"
".L1pcae%=: ldarx %0,0,%1\n"
" subf. %0,%2,%0\n"
......@@ -404,6 +476,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
: "=&r" (result)
: "b" (atomic), "r" (oldval), "r" (newval)
: "cr0", "memory");
#endif
return result == 0;
}
# else /* What's that */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment