summaryrefslogtreecommitdiff
path: root/lib/libpthread/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2002-11-01 20:15:04 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2002-11-01 20:15:04 +0000
commit82e958ef880266c36148d5aaeb42d95ef380087f (patch)
treeb457e68407c2be0011c2a0f9f138607023d2deeb /lib/libpthread/arch
parent9c3dd382bf4e91cc099142395a8e07501f5bfbdf (diff)
Working atomic locks on vax for libc_r.
ok marc@
Diffstat (limited to 'lib/libpthread/arch')
-rw-r--r--lib/libpthread/arch/vax/_atomic_lock.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/libpthread/arch/vax/_atomic_lock.c b/lib/libpthread/arch/vax/_atomic_lock.c
index aedbb86c1dd..b85f55e744f 100644
--- a/lib/libpthread/arch/vax/_atomic_lock.c
+++ b/lib/libpthread/arch/vax/_atomic_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: _atomic_lock.c,v 1.2 2002/10/11 19:08:41 marc Exp $ */
+/* $OpenBSD: _atomic_lock.c,v 1.3 2002/11/01 20:14:59 miod Exp $ */
/*
* Atomic lock for vax
@@ -9,5 +9,33 @@
int
_atomic_lock(volatile _spinlock_lock_t *lock)
{
- return (_thread_slow_atomic_lock(lock));
+ _spinlock_lock_t old;
+
+ /*
+ * The Branch on Bit Set and Set Interlocked instruction
+ * sets a given bit in a register or a memory location, as an
+ * atomic, interlocked operation.
+ * If the bit was set, execution continues at the branch
+ * location.
+ *
+ * For more details, please refer to the Vax Architecture
+ * Reference Manual, chapter 3 (Instructions), section
+ * ``Control instructions''.
+ */
+ __asm__ (
+ "movl $1, %1\n" /* _SPINLOCK_LOCKED */
+ "bbssi $0, %0, 1f\n"
+ "movl $0, %1\n" /* _SPINLOCK_UNLOCKED */
+ "1: \n"
+ : "=m" (*lock), "=r" (old) : "0" (*lock)
+ );
+
+ return (old != _SPINLOCK_UNLOCKED);
+}
+
+int
+_atomic_is_locked(volatile _spinlock_lock_t *lock)
+{
+
+ return (*lock != _SPINLOCK_UNLOCKED);
}