-# elif defined (G_ATOMIC_SPARCV9)
-/* Adapted from CVS version 1.3 of glibc's sysdeps/sparc/sparc64/bits/atomic.h
- */
-# define ATOMIC_INT_CMP_XCHG(atomic, oldval, newval) \
- ({ \
- gint __result; \
- __asm __volatile ("cas [%4], %2, %0" \
- : "=r" (__result), "=m" (*(atomic)) \
- : "r" (oldval), "m" (*(atomic)), "r" (atomic), \
- "0" (newval)); \
- __result == oldval; \
- })
-
-# if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
-gboolean
-g_atomic_pointer_compare_and_exchange (gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gpointer result;
- __asm __volatile ("cas [%4], %2, %0"
- : "=r" (result), "=m" (*atomic)
- : "r" (oldval), "m" (*atomic), "r" (atomic),
- "0" (newval));
- return result == oldval;
-}
-# elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
-gboolean
-g_atomic_pointer_compare_and_exchange (gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gpointer result;
- gpointer *a = atomic;
- __asm __volatile ("casx [%4], %2, %0"
- : "=r" (result), "=m" (*a)
- : "r" (oldval), "m" (*a), "r" (a),
- "0" (newval));
- return result != 0;
-}
-# else /* What's that */
-# error "Your system has an unsupported pointer size"
-# endif /* GLIB_SIZEOF_VOID_P */
-# define G_ATOMIC_MEMORY_BARRIER \
- __asm __volatile ("membar #LoadLoad | #LoadStore" \
- " | #StoreLoad | #StoreStore" : : : "memory")
-
-# elif defined (G_ATOMIC_ALPHA)
-/* Adapted from CVS version 1.3 of glibc's sysdeps/alpha/bits/atomic.h
- */
-# define ATOMIC_INT_CMP_XCHG(atomic, oldval, newval) \
- ({ \
- gint __result; \
- gint __prev; \
- __asm__ __volatile__ ( \
- " mb\n" \
- "1: ldl_l %0,%2\n" \
- " cmpeq %0,%3,%1\n" \
- " beq %1,2f\n" \
- " mov %4,%1\n" \
- " stl_c %1,%2\n" \
- " beq %1,1b\n" \
- " mb\n" \
- "2:" \
- : "=&r" (__prev), \
- "=&r" (__result) \
- : "m" (*(atomic)), \
- "Ir" (oldval), \
- "Ir" (newval) \
- : "memory"); \
- __result != 0; \
- })
-# if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
-gboolean
-g_atomic_pointer_compare_and_exchange (gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gint result;
- gpointer prev;
- __asm__ __volatile__ (
- " mb\n"
- "1: ldl_l %0,%2\n"
- " cmpeq %0,%3,%1\n"
- " beq %1,2f\n"
- " mov %4,%1\n"
- " stl_c %1,%2\n"
- " beq %1,1b\n"
- " mb\n"
- "2:"
- : "=&r" (prev),
- "=&r" (result)
- : "m" (*atomic),
- "Ir" (oldval),
- "Ir" (newval)
- : "memory");
- return result != 0;
-}
-# elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
-gboolean
-g_atomic_pointer_compare_and_exchange (gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gint result;
- gpointer prev;
- __asm__ __volatile__ (
- " mb\n"
- "1: ldq_l %0,%2\n"
- " cmpeq %0,%3,%1\n"
- " beq %1,2f\n"
- " mov %4,%1\n"
- " stq_c %1,%2\n"
- " beq %1,1b\n"
- " mb\n"
- "2:"
- : "=&r" (prev),
- "=&r" (result)
- : "m" (*atomic),
- "Ir" (oldval),
- "Ir" (newval)
- : "memory");
- return result != 0;
-}
-# else /* What's that */
-# error "Your system has an unsupported pointer size"
-# endif /* GLIB_SIZEOF_VOID_P */
-# define G_ATOMIC_MEMORY_BARRIER __asm ("mb" : : : "memory")
-# elif defined (G_ATOMIC_X86_64)
-/* Adapted from CVS version 1.9 of glibc's sysdeps/x86_64/bits/atomic.h
- */
-gint
-g_atomic_int_exchange_and_add (gint *atomic,
- gint val)
+/**
+ * g_atomic_int_xor:
+ * @atomic: a pointer to a #gint or #guint
+ * @val: the value to 'xor'
+ *
+ * Performs an atomic bitwise 'xor' of the value of @atomic and @val,
+ * storing the result back in @atomic.
+ *
+ * Think of this operation as an atomic version of
+ * `{ tmp = *atomic; *atomic ^= val; return tmp; }`.
+ *
+ * This call acts as a full compiler and hardware memory barrier.
+ *
+ * Returns: the value of @atomic before the operation, unsigned
+ *
+ * Since: 2.30
+ **/
+guint
+(g_atomic_int_xor) (volatile guint *atomic,
+ guint val)