summaryrefslogtreecommitdiff
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
parent66bdaa1f5ea7558365a91a75db751c76275ebce2 (diff)
md spinlock
-rw-r--r--lib/libc/gen/_spinlock_stub.c53
-rw-r--r--lib/libc/include/spinlock.h74
-rw-r--r--lib/libc_r/arch/alpha/_atomic_lock.c20
-rw-r--r--lib/libc_r/arch/alpha/_spinlock.h6
-rw-r--r--lib/libc_r/arch/m68k/_atomic_lock.c20
-rw-r--r--lib/libc_r/arch/m68k/_spinlock.h6
-rw-r--r--lib/libc_r/arch/mips/_atomic_lock.c28
-rw-r--r--lib/libc_r/arch/mips/_spinlock.h6
-rw-r--r--lib/libc_r/arch/sparc/_atomic_lock.c4
-rw-r--r--lib/libc_r/arch/sparc/_spinlock.h6
-rw-r--r--lib/libpthread/arch/alpha/_atomic_lock.c20
-rw-r--r--lib/libpthread/arch/alpha/_spinlock.h6
-rw-r--r--lib/libpthread/arch/m68k/_atomic_lock.c20
-rw-r--r--lib/libpthread/arch/m68k/_spinlock.h6
-rw-r--r--lib/libpthread/arch/mips/_atomic_lock.c28
-rw-r--r--lib/libpthread/arch/mips/_spinlock.h6
-rw-r--r--lib/libpthread/arch/sparc/_atomic_lock.c4
-rw-r--r--lib/libpthread/arch/sparc/_spinlock.h6
18 files changed, 124 insertions, 195 deletions
diff --git a/lib/libc/gen/_spinlock_stub.c b/lib/libc/gen/_spinlock_stub.c
deleted file mode 100644
index 5d95a8aadd5..00000000000
--- a/lib/libc/gen/_spinlock_stub.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id: _spinlock_stub.c,v 1.1 1998/11/20 11:18:37 d Exp $
- * $OpenBSD: _spinlock_stub.c,v 1.1 1998/11/20 11:18:37 d Exp $
- *
- */
-
-#include <stdio.h>
-#include <thread_private.h>
-
-/* Don't build these stubs into libc_r: */
-#ifndef _THREAD_SAFE
-#include "spinlock.h"
-
-void
-_spinlock(spinlock_t *lck)
-{
-}
-
-void
-_spinlock_debug(spinlock_t *lck, char *fname, int lineno)
-{
-}
-#endif
diff --git a/lib/libc/include/spinlock.h b/lib/libc/include/spinlock.h
deleted file mode 100644
index 31e7744f0af..00000000000
--- a/lib/libc/include/spinlock.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id: spinlock.h,v 1.2 1998/12/18 05:59:17 d Exp $
- * $OpenBSD: spinlock.h,v 1.2 1998/12/18 05:59:17 d Exp $
- *
- * Lock definitions used in both libc and libpthread.
- *
- */
-
-#ifndef _SPINLOCK_H_
-#define _SPINLOCK_H_
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-/*
- * Lock structure with room for debugging information.
- */
-typedef struct {
- volatile register_t access_lock;
- volatile long lock_owner;
- volatile const char * fname;
- volatile int lineno;
-} spinlock_t;
-
-#define _SPINLOCK_INITIALIZER { 0, 0, 0, 0 }
-
-#define _SPINUNLOCK(_lck) (_lck)->access_lock = 0
-#ifdef _LOCK_DEBUG
-#define _SPINLOCK(_lck) _spinlock_debug(_lck, __FILE__, __LINE__)
-#else
-#define _SPINLOCK(_lck) _spinlock(_lck)
-#endif
-
-/*
- * Thread function prototype definitions:
- */
-__BEGIN_DECLS
-register_t _atomic_lock __P((volatile register_t *));
-int _atomic_is_locked __P((volatile register_t *));
-register_t _thread_slow_atomic_lock __P((volatile register_t *));
-void _spinlock __P((spinlock_t *));
-void _spinlock_debug __P((spinlock_t *, const char *, int));
-__END_DECLS
-
-#endif /* _SPINLOCK_H_ */
diff --git a/lib/libc_r/arch/alpha/_atomic_lock.c b/lib/libc_r/arch/alpha/_atomic_lock.c
index b12bc32d94a..75aace9532c 100644
--- a/lib/libc_r/arch/alpha/_atomic_lock.c
+++ b/lib/libc_r/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/libc_r/arch/alpha/_spinlock.h b/lib/libc_r/arch/alpha/_spinlock.h
new file mode 100644
index 00000000000..259260c28a0
--- /dev/null
+++ b/lib/libc_r/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;
+
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;
+
diff --git a/lib/libc_r/arch/mips/_atomic_lock.c b/lib/libc_r/arch/mips/_atomic_lock.c
index 4df2a99ad85..6961a679069 100644
--- a/lib/libc_r/arch/mips/_atomic_lock.c
+++ b/lib/libc_r/arch/mips/_atomic_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: _atomic_lock.c,v 1.2 1998/12/18 05:59:18 d Exp $ */
+/* $OpenBSD: _atomic_lock.c,v 1.3 1998/12/21 07:37:00 d Exp $ */
/*
* Atomic lock for mips
*/
@@ -12,12 +12,12 @@
* attempt to acquire a lock (by giving it a non-zero value).
* Return zero on success, or the lock's value on failure
*/
-register_t
-_atomic_lock(volatile register_t *lock)
+int
+_atomic_lock(volatile _spinlock_lock_t *lock)
{
- register_t old;
#if __mips >= 2
- register_t temp;
+ _spinlock_lock_t old;
+ _spinlock_lock_t temp;
do {
/*
@@ -27,7 +27,7 @@ _atomic_lock(volatile register_t *lock)
* physical address of lock for diagnostic purposes);
*/
__asm__("ll %0, %1" : "=r"(old) : "m"(*lock));
- if (old)
+ if (old != _SPINLOCK_UNLOCKED)
break; /* already locked */
/*
* Try and store a 1 at the tagged lock address. If
@@ -35,25 +35,29 @@ _atomic_lock(volatile register_t *lock)
* line will have been wiped, and temp will be set to zero
* by the 'store conditional' instruction.
*/
- temp = 1;
+ temp = _SPINLOCK_LOCKED;
__asm__("sc %0, %1" : "=r"(temp), "=m"(*lock)
: "0"(temp));
} while (temp == 0);
+
+ return (old != _SPINLOCK_UNLOCKED);
#else
/*
* Older MIPS cpus have no way of doing an atomic lock
* without some kind of shift to supervisor mode.
*/
- old = _thread_slow_atomic_lock(lock);
-
+ return (_thread_slow_atomic_lock(lock));
#endif
- return old;
}
int
-_atomic_is_locked(volatile register_t * lock)
+_atomic_is_locked(volatile register_t *lock)
{
- return *lock;
+#if __mips >= 2
+ return (*lock != _SPINLOCK_UNLOCKED);
+#else
+ return (_thread_slow_atomic_is_locked(lock));
+#endif
}
diff --git a/lib/libc_r/arch/mips/_spinlock.h b/lib/libc_r/arch/mips/_spinlock.h
new file mode 100644
index 00000000000..06f9ffeb540
--- /dev/null
+++ b/lib/libc_r/arch/mips/_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;
+
diff --git a/lib/libc_r/arch/sparc/_atomic_lock.c b/lib/libc_r/arch/sparc/_atomic_lock.c
index 530c86b4805..31636328f93 100644
--- a/lib/libc_r/arch/sparc/_atomic_lock.c
+++ b/lib/libc_r/arch/sparc/_atomic_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: _atomic_lock.c,v 1.2 1998/12/18 05:59:18 d Exp $ */
+/* $OpenBSD: _atomic_lock.c,v 1.3 1998/12/21 07:37:01 d Exp $ */
/*
* Atomic lock for sparc
*/
@@ -15,5 +15,5 @@ int
_atomic_is_locked(volatile register_t * lock)
{
- return *lock;
+ return _thread_slow_atomic_is_locked(lock);
}
diff --git a/lib/libc_r/arch/sparc/_spinlock.h b/lib/libc_r/arch/sparc/_spinlock.h
new file mode 100644
index 00000000000..87b8e5485e3
--- /dev/null
+++ b/lib/libc_r/arch/sparc/_spinlock.h
@@ -0,0 +1,6 @@
+/* $OpenBSD: _spinlock.h,v 1.1 1998/12/21 07:37:01 d Exp $ */
+
+#define _SPINLOCK_UNLOCKED (0)
+#define _SPINLOCK_LOCKED (1)
+typedef int _spinlock_lock_t;
+
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;
+
diff --git a/lib/libpthread/arch/m68k/_atomic_lock.c b/lib/libpthread/arch/m68k/_atomic_lock.c
index d0e2ddbe2d6..9a59370c375 100644
--- a/lib/libpthread/arch/m68k/_atomic_lock.c
+++ b/lib/libpthread/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/libpthread/arch/m68k/_spinlock.h b/lib/libpthread/arch/m68k/_spinlock.h
new file mode 100644
index 00000000000..06f9ffeb540
--- /dev/null
+++ b/lib/libpthread/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;
+
diff --git a/lib/libpthread/arch/mips/_atomic_lock.c b/lib/libpthread/arch/mips/_atomic_lock.c
index 4df2a99ad85..6961a679069 100644
--- a/lib/libpthread/arch/mips/_atomic_lock.c
+++ b/lib/libpthread/arch/mips/_atomic_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: _atomic_lock.c,v 1.2 1998/12/18 05:59:18 d Exp $ */
+/* $OpenBSD: _atomic_lock.c,v 1.3 1998/12/21 07:37:00 d Exp $ */
/*
* Atomic lock for mips
*/
@@ -12,12 +12,12 @@
* attempt to acquire a lock (by giving it a non-zero value).
* Return zero on success, or the lock's value on failure
*/
-register_t
-_atomic_lock(volatile register_t *lock)
+int
+_atomic_lock(volatile _spinlock_lock_t *lock)
{
- register_t old;
#if __mips >= 2
- register_t temp;
+ _spinlock_lock_t old;
+ _spinlock_lock_t temp;
do {
/*
@@ -27,7 +27,7 @@ _atomic_lock(volatile register_t *lock)
* physical address of lock for diagnostic purposes);
*/
__asm__("ll %0, %1" : "=r"(old) : "m"(*lock));
- if (old)
+ if (old != _SPINLOCK_UNLOCKED)
break; /* already locked */
/*
* Try and store a 1 at the tagged lock address. If
@@ -35,25 +35,29 @@ _atomic_lock(volatile register_t *lock)
* line will have been wiped, and temp will be set to zero
* by the 'store conditional' instruction.
*/
- temp = 1;
+ temp = _SPINLOCK_LOCKED;
__asm__("sc %0, %1" : "=r"(temp), "=m"(*lock)
: "0"(temp));
} while (temp == 0);
+
+ return (old != _SPINLOCK_UNLOCKED);
#else
/*
* Older MIPS cpus have no way of doing an atomic lock
* without some kind of shift to supervisor mode.
*/
- old = _thread_slow_atomic_lock(lock);
-
+ return (_thread_slow_atomic_lock(lock));
#endif
- return old;
}
int
-_atomic_is_locked(volatile register_t * lock)
+_atomic_is_locked(volatile register_t *lock)
{
- return *lock;
+#if __mips >= 2
+ return (*lock != _SPINLOCK_UNLOCKED);
+#else
+ return (_thread_slow_atomic_is_locked(lock));
+#endif
}
diff --git a/lib/libpthread/arch/mips/_spinlock.h b/lib/libpthread/arch/mips/_spinlock.h
new file mode 100644
index 00000000000..06f9ffeb540
--- /dev/null
+++ b/lib/libpthread/arch/mips/_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;
+
diff --git a/lib/libpthread/arch/sparc/_atomic_lock.c b/lib/libpthread/arch/sparc/_atomic_lock.c
index 530c86b4805..31636328f93 100644
--- a/lib/libpthread/arch/sparc/_atomic_lock.c
+++ b/lib/libpthread/arch/sparc/_atomic_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: _atomic_lock.c,v 1.2 1998/12/18 05:59:18 d Exp $ */
+/* $OpenBSD: _atomic_lock.c,v 1.3 1998/12/21 07:37:01 d Exp $ */
/*
* Atomic lock for sparc
*/
@@ -15,5 +15,5 @@ int
_atomic_is_locked(volatile register_t * lock)
{
- return *lock;
+ return _thread_slow_atomic_is_locked(lock);
}
diff --git a/lib/libpthread/arch/sparc/_spinlock.h b/lib/libpthread/arch/sparc/_spinlock.h
new file mode 100644
index 00000000000..87b8e5485e3
--- /dev/null
+++ b/lib/libpthread/arch/sparc/_spinlock.h
@@ -0,0 +1,6 @@
+/* $OpenBSD: _spinlock.h,v 1.1 1998/12/21 07:37:01 d Exp $ */
+
+#define _SPINLOCK_UNLOCKED (0)
+#define _SPINLOCK_LOCKED (1)
+typedef int _spinlock_lock_t;
+