summaryrefslogtreecommitdiff
path: root/lib/libpthread/arch/alpha
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>1998-12-21 07:37:02 +0000
committerDavid Leonard <d@cvs.openbsd.org>1998-12-21 07:37:02 +0000
commitb3d4268288925fddfedfa142adcf20c98fb7fc48 (patch)
treede1ca6f15aebff9abb87d6a5edb96455807a752e /lib/libpthread/arch/alpha
parent66bdaa1f5ea7558365a91a75db751c76275ebce2 (diff)
md spinlock
Diffstat (limited to 'lib/libpthread/arch/alpha')
-rw-r--r--lib/libpthread/arch/alpha/_atomic_lock.c20
-rw-r--r--lib/libpthread/arch/alpha/_spinlock.h6
2 files changed, 16 insertions, 10 deletions
diff --git a/lib/libpthread/arch/alpha/_atomic_lock.c b/lib/libpthread/arch/alpha/_atomic_lock.c
index b12bc32d94a..75aace9532c 100644
--- a/lib/libpthread/arch/alpha/_atomic_lock.c
+++ b/lib/libpthread/arch/alpha/_atomic_lock.c
@@ -1,42 +1,42 @@
-/* $OpenBSD: _atomic_lock.c,v 1.2 1998/12/18 05:59:17 d Exp $ */
+/* $OpenBSD: _atomic_lock.c,v 1.3 1998/12/21 07:36:59 d Exp $ */
/*
* Atomic lock for alpha
*/
#include "spinlock.h"
-register_t
-_atomic_lock(volatile register_t * lock)
+int
+_atomic_lock(volatile _spinlock_lock_t * lock)
{
- register_t old;
- register_t new;
+ _spinlock_lock_t old;
+ _spinlock_lock_t new;
int success;
do {
/* load the value of the thread-lock (lock mem on load) */
__asm__( "ldq_l %0, %1" : "=r"(old) : "m"(*lock) );
if (old)
- new = old; /* in-use: put it back */
+ new = old; /* locked: no change */
else
- new = 1; /* free: store a 1 in the lock */
+ new = _SPINLOCK_LOCKED; /* unlocked: grab it */
success = 0;
/* store the new value of the thrd-lock (unlock mem on store) */
/*
* XXX may need to add large branch forward for main line
- * branch prediction to be right :(
+ * branch prediction to be right :( [note from linux]
*/
__asm__( "stq_c %2, %0; beq %2, 1f; mov 1,%1; 1:"
: "=m"(*lock), "=r"(success)
: "r"(new) );
} while (!success);
- return old;
+ return (old != _SPINLOCK_UNLOCKED);
}
int
_atomic_is_locked(volatile register_t * lock)
{
- return *lock;
+ return (*lock != _SPINLOCK_UNLOCKED);
}
diff --git a/lib/libpthread/arch/alpha/_spinlock.h b/lib/libpthread/arch/alpha/_spinlock.h
new file mode 100644
index 00000000000..259260c28a0
--- /dev/null
+++ b/lib/libpthread/arch/alpha/_spinlock.h
@@ -0,0 +1,6 @@
+/* $OpenBSD: _spinlock.h,v 1.1 1998/12/21 07:36:59 d Exp $ */
+
+#define _SPINLOCK_UNLOCKED (0)
+#define _SPINLOCK_LOCKED (1)
+typedef int _spinlock_lock_t;
+