summaryrefslogtreecommitdiff
path: root/lib/libc_r/arch/m68k
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/libc_r/arch/m68k
parent66bdaa1f5ea7558365a91a75db751c76275ebce2 (diff)
md spinlock
Diffstat (limited to 'lib/libc_r/arch/m68k')
-rw-r--r--lib/libc_r/arch/m68k/_atomic_lock.c20
-rw-r--r--lib/libc_r/arch/m68k/_spinlock.h6
2 files changed, 16 insertions, 10 deletions
diff --git a/lib/libc_r/arch/m68k/_atomic_lock.c b/lib/libc_r/arch/m68k/_atomic_lock.c
index d0e2ddbe2d6..9a59370c375 100644
--- a/lib/libc_r/arch/m68k/_atomic_lock.c
+++ b/lib/libc_r/arch/m68k/_atomic_lock.c
@@ -1,14 +1,14 @@
-/* $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 m68k
*/
#include "spinlock.h"
-register_t
-_atomic_lock(volatile register_t *lock)
+int
+_atomic_lock(volatile _spinlock_lock_t *lock)
{
- register_t old;
+ _spinlock_lock_t old;
/*
* The Compare And Swap instruction (mc68020 and above)
@@ -19,17 +19,17 @@ _atomic_lock(volatile register_t *lock)
*
* old = 0;
* CAS(old, 1, *lock);
- * return old;
+ * if (old == 1) { lock was acquired }
*/
- old = 0;
+ old = _SPINLOCK_UNLOCKED;
__asm__("casl %0, %2, %1" : "=d"(old), "=m"(*lock)
- : "d"(1), "0"(old));
- return old;
+ : "d"(_SPINLOCK_LOCKED), "0"(old));
+ return (old != _SPINLOCK_UNLOCKED);
}
int
-_atomic_lock(volatile register_t *lock)
+_atomic_lock(volatile _spinlock_lock_t *lock)
{
- return *lock;
+ return (*lock != _SPINLOCK_UNLOCKED);
}
diff --git a/lib/libc_r/arch/m68k/_spinlock.h b/lib/libc_r/arch/m68k/_spinlock.h
new file mode 100644
index 00000000000..06f9ffeb540
--- /dev/null
+++ b/lib/libc_r/arch/m68k/_spinlock.h
@@ -0,0 +1,6 @@
+/* $OpenBSD: _spinlock.h,v 1.1 1998/12/21 07:37:00 d Exp $ */
+
+#define _SPINLOCK_UNLOCKED (0)
+#define _SPINLOCK_LOCKED (1)
+typedef int _spinlock_lock_t;
+