diff --git a/glib/gbitlock.c b/glib/gbitlock.c
index 1b8c417..d354886 100644
--- a/glib/gbitlock.c
+++ b/glib/gbitlock.c
@@ -284,12 +284,18 @@ g_bit_unlock (volatile gint *address,
               gint           lock_bit)
 {
   guint class = ((gsize) address) % G_N_ELEMENTS (g_bit_lock_contended);
+
+#ifdef G_ATOMIC_OP_USE_GCC_BUILTINS
+  __sync_fetch_and_and (address, ~(1u << lock_bit));
+#else
+
   guint v;
 
- retry:
+retry:
   v = g_atomic_int_get (address);
   if (!g_atomic_int_compare_and_exchange (address, v, v & ~(1u << lock_bit)))
     goto retry;
+#endif
 
   if (g_atomic_int_get (&g_bit_lock_contended[class]))
     g_futex_wake (address);
