diff options
-rw-r--r-- | lib/libc_r/arch/vax/_atomic_lock.c | 32 | ||||
-rw-r--r-- | lib/libpthread/arch/vax/_atomic_lock.c | 32 | ||||
-rw-r--r-- | sys/arch/vax/include/spinlock.h | 6 |
3 files changed, 63 insertions, 7 deletions
diff --git a/lib/libc_r/arch/vax/_atomic_lock.c b/lib/libc_r/arch/vax/_atomic_lock.c index aedbb86c1dd..b85f55e744f 100644 --- a/lib/libc_r/arch/vax/_atomic_lock.c +++ b/lib/libc_r/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); } 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); } diff --git a/sys/arch/vax/include/spinlock.h b/sys/arch/vax/include/spinlock.h index 0c3e43efff4..7c38641bc01 100644 --- a/sys/arch/vax/include/spinlock.h +++ b/sys/arch/vax/include/spinlock.h @@ -1,10 +1,10 @@ -/* $OpenBSD: spinlock.h,v 1.1 2000/04/26 06:08:27 bjc Exp $ */ +/* $OpenBSD: spinlock.h,v 1.2 2002/11/01 20:15:03 miod Exp $ */ #ifndef _MACHINE_SPINLOCK_H_ #define _MACHINE_SPINLOCK_H_ -#define _SPINLOCK_UNLOCKED (1) -#define _SPINLOCK_LOCKED (0) +#define _SPINLOCK_UNLOCKED (0) +#define _SPINLOCK_LOCKED (1) typedef int _spinlock_lock_t; #endif |