2000-04-11  Ulrich Drepper  <drepper@redhat.com>

	* internals.h: Define MEMORY_BARRIER as empty if not defined already.
	* spinlock.c (__pthread_lock): Add memory barriers.
	(__pthread_unlock): Likewise.
	* sysdeps/alpha/pt-machine.h (MEMORY_BARRIER): Define using mb
	instruction.
	(RELEASE): Not needed anymore.
	(__compare_and_swap): Mark asm as modifying memory.
	* sysdeps/powerpc/pt-machine.h (sync): Remove.  Replace with definition
	of MEMORY_BARRIER.
	(__compare_and_swap): Use MEMORY_BARRIER instead of sync.
	* sysdeps/sparc/sparc32/pt-machine.h (RELEASE): Not needed anymore.
	(MEMORY_BARRIER): Define using stbar.
	* sysdeps/sparc/sparc64/pt-machine.h (MEMORY_BARRIER): Define using
	stbar.
	(__compare_and_swap): Use MEMORY_BARRIER to ensure ordering.
	Patch by Xavier Leroy <Xavier.Leroy@inria.fr> based on comments by
	Mike Burrows <m3b@pa.dec.com>.
This commit is contained in:
Ulrich Drepper
2000-04-11 17:03:03 +00:00
parent e7c036b39e
commit de26253715
7 changed files with 61 additions and 17 deletions
@@ -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;
}