about summary refs log tree commit diff
path: root/linuxthreads/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads/sysdeps')
-rw-r--r--linuxthreads/sysdeps/alpha/pt-machine.h12
-rw-r--r--linuxthreads/sysdeps/powerpc/pt-machine.h9
-rw-r--r--linuxthreads/sysdeps/sparc/sparc32/pt-machine.h5
-rw-r--r--linuxthreads/sysdeps/sparc/sparc64/pt-machine.h8
4 files changed, 17 insertions, 17 deletions
diff --git a/linuxthreads/sysdeps/alpha/pt-machine.h b/linuxthreads/sysdeps/alpha/pt-machine.h
index e59c6906c8..25ba634528 100644
--- a/linuxthreads/sysdeps/alpha/pt-machine.h
+++ b/linuxthreads/sysdeps/alpha/pt-machine.h
@@ -32,6 +32,10 @@
 register char *stack_pointer __asm__("$30");
 
 
+/* Memory barrier; default is to do nothing */
+#define MEMORY_BARRIER() __asm__ __volatile__("mb" : : : "memory")
+
+
 /* Spinlock implementation; required.  */
 PT_EI long int
 testandset (int *spinlock)
@@ -55,11 +59,6 @@ testandset (int *spinlock)
   return ret;
 }
 
-/* Spinlock release; default is just set to zero.  */
-#define RELEASE(spinlock) \
-  __asm__ __volatile__("mb" : : : "memory"); \
-  *spinlock = 0
-
 
 /* Begin allocating thread stacks at this address.  Default is to allocate
    them just below the initial program stack.  */
@@ -102,7 +101,8 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
 	"2:\tmb\n"
 	"/* End compare & swap */"
 	: "=&r"(ret), "=m"(*p)
-	: "r"(oldval), "r"(newval), "m"(*p));
+	: "r"(oldval), "r"(newval), "m"(*p)
+        : "memory");
 
   return ret;
 }
diff --git a/linuxthreads/sysdeps/powerpc/pt-machine.h b/linuxthreads/sysdeps/powerpc/pt-machine.h
index 578369a7fe..c7d0670d82 100644
--- a/linuxthreads/sysdeps/powerpc/pt-machine.h
+++ b/linuxthreads/sysdeps/powerpc/pt-machine.h
@@ -27,12 +27,7 @@
 
 /* For multiprocessor systems, we want to ensure all memory accesses
    are completed before we reset a lock.  */
-#if 0
-/* on non multiprocessor systems, you can just: */
-#define sync() /* nothing */
-#else
-#define sync() __asm__ __volatile__ ("sync")
-#endif
+#define MEMORY_BARRIER() __asm__ __volatile__ ("sync" : : : "memory")
 
 /* Get some notion of the current stack.  Need not be exactly the top
    of the stack, just something somewhere in the current frame.  */
@@ -64,6 +59,6 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
 	: "=&r"(ret)
 	: "r"(p), "r"(newval), "r"(oldval)
 	: "cr0", "memory");
-  sync();
+  MEMORY_BARRIER();
   return ret == 0;
 }
diff --git a/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h b/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h
index 69af8579aa..ddf4932af9 100644
--- a/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h
+++ b/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h
@@ -37,9 +37,8 @@ testandset (int *spinlock)
 }
 
 
-/* Spinlock release; default is just set to zero.  */
-#define RELEASE(spinlock) \
-  __asm__ __volatile__("stbar; stb %1,%0" : "=m"(*(spinlock)) : "r"(0));
+/* Memory barrier; default is to do nothing */
+#define MEMORY_BARRIER() __asm__ __volatile__("stbar" : : : "memory")
 
 
 /* Get some notion of the current stack.  Need not be exactly the top
diff --git a/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h b/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h
index 5560003fc8..02167bd601 100644
--- a/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h
+++ b/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h
@@ -37,6 +37,12 @@ testandset (int *spinlock)
 }
 
 
+/* Memory barrier; default is to do nothing */
+/* FIXME: is stbar OK, or should we use the more general membar instruction?
+   If so, which mode to pass to membar? */
+#define MEMORY_BARRIER() __asm__ __volatile__("stbar" : : : "memory")
+
+
 /* Get some notion of the current stack.  Need not be exactly the top
    of the stack, just something somewhere in the current frame.  */
 #define CURRENT_STACK_FRAME  stack_pointer
@@ -66,7 +72,7 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
   __asm__ __volatile__ ("casx	[%4], %2, %0"
 			: "=r"(readval), "=m"(*p)
 			: "r"(oldval), "m"(*p), "r"(p), "0"(newval));
-
+  MEMORY_BARRIER();
   return readval == oldval;
 }