diff -u glib2.0-2.22.2/glib/gatomic.c glib2.0-2.23.0/glib/gatomic.c
--- glib2.0-2.22.2/glib/gatomic.c	2009-12-02 16:22:03.000000000 +0000
+++ glib2.0-2.23.0/glib/gatomic.c	2009-12-03 13:49:17.000000000 +0000
@@ -561,8 +561,39 @@
 #    error "Your system has an unsupported pointer size"
 #  endif /* GLIB_SIZEOF_VOID_P */
 # elif defined (G_ATOMIC_ARM)
+
+/* Use the GCC atomic intrinsics if available.
+   For ARM, the intrinsics require GCC 4.4 or later, and linux 2.6.13 or later*/
+#  ifdef G_ATOMIC_ARM_USE_GCC_INTRINSICS
+
+/* Note that the definition of ARM_ATOMIC_SPIN_UNLOCKED as 0 is determined by
+   the specification of __sync_lock_test_and_set(). */
+#  define ARM_ATOMIC_SPIN_UNLOCKED ((void *)0)
+#  define ARM_ATOMIC_SPIN_LOCKED ((void *)1)
+
+static void *volatile atomic_spin = ARM_ATOMIC_SPIN_UNLOCKED;
+
+/* For future compatibility, we can't assume we're not running on an SMP system
+   so memory barriers are needed in general: */
+#   define G_ATOMIC_MEMORY_BARRIER __sync_synchronize()
+
+static void atomic_spin_lock (void)
+{
+  while(__sync_lock_test_and_set(&atomic_spin, ARM_ATOMIC_SPIN_LOCKED)
+		!= ARM_ATOMIC_SPIN_UNLOCKED)
+    sched_yield(); /* Yield until the lock is successfully obtained. */
+}
+
+static void atomic_spin_unlock (void)
+{
+  __sync_lock_release(&atomic_spin);
+}
+
+#  else /* !G_ATOMIC_ARM_USE_GCC_INTRINSICS */
+
 static volatile int atomic_spin = 0;
 
+/* If GCC doesn't have the instrinsics, fall back to the old implementation: */
 static int atomic_spin_trylock (void)
 {
   int result;
@@ -588,6 +619,7 @@
 {
   atomic_spin = 0;
 }
+#  endif /* !G_ATOMIC_ARM_USE_GCC_INTRINSICS */
 
 gint
 g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, 
diff -u glib2.0-2.22.2/configure.in glib2.0-2.23.0/configure.in
--- glib2.0-2.22.2/configure.in	2009-12-02 13:57:25.000000000 +0000
+++ glib2.0-2.23.0/configure.in	2009-12-03 13:41:17.000000000 +0000
@@ -2480,7 +2480,18 @@
       AC_DEFINE_UNQUOTED(G_ATOMIC_ARM, 1,
                          [arm atomic implementation])
       glib_memory_barrier_needed=no
-      ;;
+      AC_MSG_CHECKING([whether GCC supports atomic intrinsics])
+      AC_TRY_LINK(
+		,[ 
+			__sync_synchronize();
+		],[
+			AC_DEFINE_UNQUOTED(G_ATOMIC_ARM_USE_GCC_INTRINSICS, 1, [define if the GCC atomic intrinsics are to be used for ARM])
+			AC_MSG_RESULT([yes])
+			glib_memory_barrier_needed=yes
+		],[
+			AC_MSG_RESULT([no])
+		])
+      ;;	
     crisv32*|etraxfs*)
       AC_MSG_RESULT([crisv32])
       AC_DEFINE_UNQUOTED(G_ATOMIC_CRISV32, 1,
@@ -2491,6 +2502,9 @@
       AC_MSG_CHECKING([whether GCC supports atomic intrinsics])
       AC_TRY_LINK(
 		,[ 
+			void *volatile lock = (void *)0;
+			__sync_lock_test_and_set(&lock, (void *)1);
+			__sync_lock_release(&lock);
 			__sync_synchronize();
 		],[
 			AC_DEFINE_UNQUOTED(G_ATOMIC_ARM_USE_GCC_INTRINSICS, 1, [define if the GCC atomic intrinsics are to be used for ARM])
