summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpj <rpj>2001-10-12 08:24:52 +0000
committerrpj <rpj>2001-10-12 08:24:52 +0000
commit50d2dd36c9a30460b32a4c9a3b4b2c456a255467 (patch)
treec05551527200da991f9482d57fc18fa43ea29695
parent64a1ea1aa97e5de174220f8de6815ede9fcfabac (diff)
* spin.c (pthread_spin_unlock): Was not returning
EPERM if the spinlock was not locked, for multi CPU machines.
-rw-r--r--ChangeLog6
-rw-r--r--spin.c15
2 files changed, 14 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 07b04a4..7c5ee62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-10-12 Ross Johnson <rpj@setup1.ise.canberra.edu.au>
+
+ * spin.c (pthread_spin_unlock): Was not returning
+ EPERM if the spinlock was not locked, for multi CPU
+ machines.
+
2001-10-08 Ross Johnson <rpj@setup1.ise.canberra.edu.au>
* spin.c (pthread_spin_trylock): Was not returning
diff --git a/spin.c b/spin.c
index d2d795f..6688219 100644
--- a/spin.c
+++ b/spin.c
@@ -253,17 +253,18 @@ pthread_spin_unlock(pthread_spinlock_t *lock)
{
register pthread_spinlock_t s = *lock;
- if (s->interlock == PTW32_SPIN_USE_MUTEX)
+ if (s == PTHREAD_SPINLOCK_INITIALIZER)
{
- return pthread_mutex_unlock(&(s->u.mutex));
+ return EPERM;
}
- if ((_LONG) PTW32_SPIN_LOCKED ==
- InterlockedCompareExchange((_LPLONG) &(s->interlock),
- (_LONG) PTW32_SPIN_UNLOCKED,
- (_LONG) PTW32_SPIN_LOCKED ) )
+ switch ((long) InterlockedCompareExchange((_LPLONG) &(s->interlock),
+ (_LONG) PTW32_SPIN_UNLOCKED,
+ (_LONG) PTW32_SPIN_LOCKED ))
{
- return 0;
+ case PTW32_SPIN_LOCKED: return 0;
+ case PTW32_SPIN_UNLOCKED: return EPERM;
+ case PTW32_SPIN_USE_MUTEX: return pthread_mutex_unlock(&(s->u.mutex));
}
return EINVAL;