Add support for x86 older than P4, with CONFIG_HAS_FENCE option
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Thu, 12 Feb 2009 18:42:31 +0000 (13:42 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Thu, 12 Feb 2009 18:42:31 +0000 (13:42 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
urcu.h

diff --git a/urcu.h b/urcu.h
index 79d9464b0be63142fb51cb2f00d11edb5996441d..3e1ad78324cda478711e1c3f521bd62359bd2212 100644 (file)
--- a/urcu.h
+++ b/urcu.h
 #define likely(x)       __builtin_expect(!!(x), 1)
 #define unlikely(x)     __builtin_expect(!!(x), 0)
 
+/* Assume P4 or newer */
+#define CONFIG_HAS_FENCE 1
+
 /* x86 32/64 specific */
+#ifdef CONFIG_HAS_FENCE
 #define mb()    asm volatile("mfence":::"memory")
 #define rmb()   asm volatile("lfence":::"memory")
-#define wmb()   asm volatile("sfence" ::: "memory")
+#define wmb()   asm volatile("sfence"::: "memory")
+#else
+/*
+ * Some non-Intel clones support out of order store. wmb() ceases to be a
+ * nop for these.
+ */
+#define mb()    asm volatile("lock; addl $0,0(%%esp)":::"memory")
+#define rmb()   asm volatile("lock; addl $0,0(%%esp)":::"memory")
+#define wmb()   asm volatile("lock; addl $0,0(%%esp)"::: "memory")
+#endif
 
 /* Assume SMP machine, given we don't have this information */
 #define CONFIG_SMP 1
This page took 0.025598 seconds and 4 git commands to generate.