summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/sys
diff options
context:
space:
mode:
authord <d@openbsd.org>1998-12-21 07:36:58 +0000
committerd <d@openbsd.org>1998-12-21 07:36:58 +0000
commit7e271bc515f3a7cb809aafa70bda90a7af35f077 (patch)
tree78eaf0f7aa731fc84022d1ad2f3f30e227b31175 /lib/libpthread/sys
parentclean (diff)
downloadwireguard-openbsd-7e271bc515f3a7cb809aafa70bda90a7af35f077.tar.xz
wireguard-openbsd-7e271bc515f3a7cb809aafa70bda90a7af35f077.zip
md spinlock
Diffstat (limited to 'lib/libpthread/sys')
-rw-r--r--lib/libpthread/sys/slow_atomic_lock.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/libpthread/sys/slow_atomic_lock.c b/lib/libpthread/sys/slow_atomic_lock.c
index ca86bb3dd52..22889ea8691 100644
--- a/lib/libpthread/sys/slow_atomic_lock.c
+++ b/lib/libpthread/sys/slow_atomic_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slow_atomic_lock.c,v 1.2 1998/11/21 14:02:10 d Exp $ */
+/* $OpenBSD: slow_atomic_lock.c,v 1.3 1998/12/21 07:38:43 d Exp $ */
#include <pthread.h>
#include "pthread_private.h"
@@ -12,10 +12,10 @@
* This uses signal masking to make sure that no other thread
* can modify the lock while processing, hence it is very slow.
*/
-register_t
-_thread_slow_atomic_lock(volatile register_t *lock)
+int
+_thread_slow_atomic_lock(volatile _spinlock_lock_t *lock)
{
- register_t old;
+ _spinlock_lock_t old;
sigset_t oldset, newset = (sigset_t)~0;
/* block signals - incurs a context switch */
@@ -23,12 +23,19 @@ _thread_slow_atomic_lock(volatile register_t *lock)
PANIC("_atomic_lock block");
old = *lock;
- if (old == 0)
- *lock = 1;
+ if (old == _SPINLOCK_UNLOCKED)
+ *lock = _SPINLOCK_LOCKED;
/* restore signal mask to what it was */
if (_thread_sys_sigprocmask(SIG_SETMASK, &oldset, NULL) < 0)
PANIC("_atomic_lock restore");
- return old;
+ return (old != _SPINLOCK_UNLOCKED);
+}
+
+int
+_thread_slow_atomic_is_locked(volatile _spinlock_lock_t *lock)
+{
+
+ return (*lock != _SPINLOCK_UNLOCKED);
}