[ltt-dev] [PATCH tip/core/rcu 1/4] Add header files supporting gcc __sync_ primitives

Paolo Bonzini pbonzini at redhat.com
Thu Jun 17 03:55:47 EDT 2010


+#define CACHE_LINE_SIZE 128
+#define mb()    __sync_synchronize()

These are provided by arch_generic.h, aren't they?

In particular, CACHE_LINE_SIZE should be updated there from 64
to 128 if we deem that value to be better.

diff --git a/urcu/uatomic_arch_gcc.h b/urcu/uatomic_arch_gcc.h
new file mode 100644
index 0000000..df208bd
--- /dev/null
+++ b/urcu/uatomic_arch_gcc.h
@@ -0,0 +1,48 @@
+/* xchg */
+#define uatomic_xchg(addr, v) __sync_lock_test_and_set(addr, v)

__sync_lock_test_and_set may only support v==1, and is only
an acquire barrier, so I think it's better to just use the
definition in uatomic_arch_generic.h.

+/* cmpxchg */
+#define uatomic_cmpxchg(addr, old, _new) \
+	__sync_val_compare_and_swap(addr, old, _new)
+
+/* uatomic_add_return */
+#define uatomic_add_return(addr, v) __sync_add_and_fetch(addr, v)

These are also provided by uatomic_arch_generic.h.

Paolo




More information about the lttng-dev mailing list