summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2002-11-12 18:56:29 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2002-11-12 18:56:29 +0000
commit6a2b2974d6d0469840b37a9109b8e5f45cf05170 (patch)
treeef09c3f33e6f664cf18e4b276b22c915c9040c59
parent5310b67125a2c4c3936791cfd77dbe37cf314856 (diff)
Fix the C version of atomic lock so that the compiler will not share
registers. ok marc@
-rw-r--r--lib/libc_r/arch/powerpc/_atomic_lock.c7
-rw-r--r--lib/libpthread/arch/powerpc/_atomic_lock.c7
2 files changed, 8 insertions, 6 deletions
diff --git a/lib/libc_r/arch/powerpc/_atomic_lock.c b/lib/libc_r/arch/powerpc/_atomic_lock.c
index 0d6099bbfed..d248b4725cf 100644
--- a/lib/libc_r/arch/powerpc/_atomic_lock.c
+++ b/lib/libc_r/arch/powerpc/_atomic_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: _atomic_lock.c,v 1.4 2002/10/11 19:08:41 marc Exp $ */
+/* $OpenBSD: _atomic_lock.c,v 1.5 2002/11/12 18:56:28 drahn Exp $ */
/*
* Atomic lock for powerpc
*/
@@ -10,11 +10,12 @@ _atomic_lock(volatile _spinlock_lock_t *lock)
{
_spinlock_lock_t old;
- __asm__("1: lwarx %0,0,%1 \n"
+ __asm__("1: lwarx 0,0,%1 \n"
" stwcx. %2,0,%1 \n"
" bne- 1b \n"
+ " mr %0, 0 \n"
: "=r" (old), "=r" (lock)
- : "r" (_SPINLOCK_LOCKED), "1" (lock)
+ : "r" (_SPINLOCK_LOCKED), "1" (lock) : "0"
);
return (old != _SPINLOCK_UNLOCKED);
diff --git a/lib/libpthread/arch/powerpc/_atomic_lock.c b/lib/libpthread/arch/powerpc/_atomic_lock.c
index 0d6099bbfed..d248b4725cf 100644
--- a/lib/libpthread/arch/powerpc/_atomic_lock.c
+++ b/lib/libpthread/arch/powerpc/_atomic_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: _atomic_lock.c,v 1.4 2002/10/11 19:08:41 marc Exp $ */
+/* $OpenBSD: _atomic_lock.c,v 1.5 2002/11/12 18:56:28 drahn Exp $ */
/*
* Atomic lock for powerpc
*/
@@ -10,11 +10,12 @@ _atomic_lock(volatile _spinlock_lock_t *lock)
{
_spinlock_lock_t old;
- __asm__("1: lwarx %0,0,%1 \n"
+ __asm__("1: lwarx 0,0,%1 \n"
" stwcx. %2,0,%1 \n"
" bne- 1b \n"
+ " mr %0, 0 \n"
: "=r" (old), "=r" (lock)
- : "r" (_SPINLOCK_LOCKED), "1" (lock)
+ : "r" (_SPINLOCK_LOCKED), "1" (lock) : "0"
);
return (old != _SPINLOCK_UNLOCKED);