Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

See the ChangeLogs

  • Loading branch information...
commit d582e610740d4996ccb7f2c056017bbc545c2b51 1 parent d324827
rpj authored
View
6 ChangeLog
@@ -1,3 +1,9 @@
+2011-07-02 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * pthread_spin_unlock.c (EPERM): Return success if unlocking a lock
+ that is not locked, because single CPU machines wrap a
+ PTHREAD_MUTEX_NORMAL mutex, which returns success in this case.
+
2011-07-02 Daniel Richard G. <skunk at iskunk dot org>
* Makefile: Cleanups and implovements.
View
14 implement.h
@@ -85,21 +85,21 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
#else
#define INLINE
#endif
+
#if defined(_MSC_VER) && _MSC_VER < 1300
/*
* MSVC 6 does not use the "volatile" qualifier
*/
-#define VOLATILE
+#define PTW32_INTERLOCKED_VOLATILE
#else
-#define VOLATILE volatile
+#define PTW32_INTERLOCKED_VOLATILE volatile
#endif
-
#define PTW32_INTERLOCKED_LONG long
#define PTW32_INTERLOCKED_SIZE size_t
#define PTW32_INTERLOCKED_PVOID PVOID
-#define PTW32_INTERLOCKED_LONGPTR VOLATILE long*
-#define PTW32_INTERLOCKED_SIZEPTR VOLATILE size_t*
-#define PTW32_INTERLOCKED_PVOID_PTR VOLATILE PVOID*
+#define PTW32_INTERLOCKED_LONGPTR PTW32_INTERLOCKED_VOLATILE long*
+#define PTW32_INTERLOCKED_SIZEPTR PTW32_INTERLOCKED_VOLATILE size_t*
+#define PTW32_INTERLOCKED_PVOID_PTR PTW32_INTERLOCKED_VOLATILE PVOID*
#if defined(__MINGW64__) || defined(__MINGW32__)
# include <stdint.h>
@@ -147,7 +147,7 @@ struct ptw32_thread_t_
HANDLE threadH; /* Win32 thread handle - POSIX thread is invalid if threadH == 0 */
pthread_t ptHandle; /* This thread's permanent pthread_t handle */
ptw32_thread_t * prevReuse; /* Links threads on reuse stack */
- VOLATILE PThreadState state;
+ volatile PThreadState state;
ptw32_mcs_lock_t threadLock; /* Used for serialised access to public thread state */
ptw32_mcs_lock_t stateLock; /* Used for async-cancel safety */
HANDLE cancelEvent;
View
3  pthread_spin_unlock.c
@@ -61,9 +61,8 @@ pthread_spin_unlock (pthread_spinlock_t * lock)
(PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED))
{
case PTW32_SPIN_LOCKED:
- return 0;
case PTW32_SPIN_UNLOCKED:
- return EPERM;
+ return 0;
case PTW32_SPIN_USE_MUTEX:
return pthread_mutex_unlock (&(s->u.mutex));
}
View
2  tests/Bmakefile
@@ -326,7 +326,7 @@ robust4.pass: robust3.pass
robust5.pass: robust4.pass
rwlock1.pass: condvar6.pass
rwlock2.pass: rwlock1.pass
-rwlock3.pass: rwlock2.pass
+rwlock3.pass: rwlock2.pass join2.pass
rwlock4.pass: rwlock3.pass
rwlock5.pass: rwlock4.pass
rwlock6.pass: rwlock5.pass
View
11 tests/ChangeLog
@@ -1,3 +1,14 @@
+2011-07-02 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * spin3.c: Unlock the unlocked spinlock now returns success.
+ * rwlock3.c: Join the thread to ensure it's completed.
+ * rwlock4.c: Likewise.
+ * rwlock5.c: Likewise.
+ * Makefile: Adjust prerequisites.
+ * GNUmakefile: Likewise.
+ * Bmakefile: Likewise.
+ * Wmakefile: Likewise.
+
2011-07-02 Daniel Richard G. <skunk at iskunk dot org>
* *.[ch]: Cleanups around timeb struct, mainly centralising
View
2  tests/GNUmakefile
@@ -348,7 +348,7 @@ robust4.pass: robust3.pass
robust5.pass: robust4.pass
rwlock1.pass: condvar6.pass
rwlock2.pass: rwlock1.pass
-rwlock3.pass: rwlock2.pass
+rwlock3.pass: rwlock2.pass join2.pass
rwlock4.pass: rwlock3.pass
rwlock5.pass: rwlock4.pass
rwlock6.pass: rwlock5.pass
View
2  tests/Makefile
@@ -417,7 +417,7 @@ robust4.pass: robust3.pass
robust5.pass: robust4.pass
rwlock1.pass: condvar6.pass
rwlock2.pass: rwlock1.pass
-rwlock3.pass: rwlock2.pass
+rwlock3.pass: rwlock2.pass join2.pass
rwlock4.pass: rwlock3.pass
rwlock5.pass: rwlock4.pass
rwlock6.pass: rwlock5.pass
View
2  tests/Wmakefile
@@ -324,7 +324,7 @@ robust4.pass: robust3.pass
robust5.pass: robust4.pass
rwlock1.pass: condvar6.pass
rwlock2.pass: rwlock1.pass
-rwlock3.pass: rwlock2.pass
+rwlock3.pass: rwlock2.pass join2.pass
rwlock4.pass: rwlock3.pass
rwlock5.pass: rwlock4.pass
rwlock6.pass: rwlock5.pass
View
4 tests/rwlock3.c
@@ -37,6 +37,8 @@
* and then unlock it again.
*
* Depends on API functions:
+ * pthread_create()
+ * pthread_join()
* pthread_rwlock_wrlock()
* pthread_rwlock_trywrlock()
* pthread_rwlock_unlock()
@@ -66,7 +68,7 @@ main()
assert(pthread_create(&t, NULL, func, NULL) == 0);
- Sleep(20);
+ assert(pthread_join(t, NULL) == 0);
assert(pthread_rwlock_unlock(&rwlock1) == 0);
View
4 tests/rwlock4.c
@@ -37,6 +37,8 @@
* and then unlock it again.
*
* Depends on API functions:
+ * pthread_create()
+ * pthread_join()
* pthread_rwlock_rdlock()
* pthread_rwlock_trywrlock()
* pthread_rwlock_unlock()
@@ -66,7 +68,7 @@ main()
assert(pthread_create(&t, NULL, func, NULL) == 0);
- Sleep(20);
+ assert(pthread_join(t, NULL) == 0);
assert(pthread_rwlock_unlock(&rwlock1) == 0);
View
4 tests/rwlock5.c
@@ -37,6 +37,8 @@
* and then unlock it again.
*
* Depends on API functions:
+ * pthread_create()
+ * pthread_join()
* pthread_rwlock_rdlock()
* pthread_rwlock_tryrdlock()
* pthread_rwlock_unlock()
@@ -68,7 +70,7 @@ main()
assert(pthread_create(&t, NULL, func, NULL) == 0);
- Sleep(20);
+ assert(pthread_join(t, NULL) == 0);
assert(pthread_rwlock_unlock(&rwlock1) == 0);
View
6 tests/spin3.c
@@ -64,7 +64,11 @@ main()
assert(pthread_spin_lock(&spin) == 0);
assert(pthread_create(&t, NULL, unlocker, (void*)0) == 0);
assert(pthread_join(t, NULL) == 0);
- assert(pthread_spin_unlock(&spin) == EPERM);
+ /*
+ * Our spinlocks don't record the owner thread so any thread can unlock the spinlock,
+ * but nor is it an error for any thread to unlock a spinlock that is not locked.
+ */
+ assert(pthread_spin_unlock(&spin) == 0);
assert(pthread_spin_destroy(&spin) == 0);
assert(wasHere == 2);
Please sign in to comment.
Something went wrong with that request. Please try again.