From 06974b302eaf8f08382e6e786aea53f420c12222 Mon Sep 17 00:00:00 2001 From: rpj Date: Fri, 6 Jul 2001 18:16:50 +0000 Subject: Spinlocks and barriers fixed and working. Beta level. * spin.c: Revamped and working; included static initialiser. * barrier.c: Likewise. * condvar.c: Macro constant change; inline auto init routine. * mutex.c: Likewise. * rwlock.c: Likewise. * private.c: Add support for spinlock initialiser. * global.c: Likewise. * implement.h: Likewise. * pthread.h (PTHREAD_SPINLOCK_INITIALIZER): Fix typo. tests/ChangeLog: * spin3.c: Changed test and fixed. * spin4.c: Fixed. * barrier3.c: Fixed. * barrier4.c: Fixed. --- rwlock.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'rwlock.c') diff --git a/rwlock.c b/rwlock.c index 819507b..2cc94ce 100644 --- a/rwlock.c +++ b/rwlock.c @@ -29,7 +29,7 @@ #include "pthread.h" #include "implement.h" -static int +static INLINE int ptw32_rwlock_check_need_init(pthread_rwlock_t *rwlock) { int result = 0; @@ -65,7 +65,7 @@ ptw32_rwlock_check_need_init(pthread_rwlock_t *rwlock) * re-initialise it only by calling pthread_rwlock_init() * explicitly. */ - if (*rwlock == (pthread_rwlock_t) PTW32_OBJECT_AUTO_INIT) + if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) { result = pthread_rwlock_init(rwlock, NULL); } @@ -163,7 +163,7 @@ pthread_rwlock_destroy(pthread_rwlock_t *rwlock) return EINVAL; } - if (*rwlock != (pthread_rwlock_t) PTW32_OBJECT_AUTO_INIT) + if (*rwlock != PTHREAD_RWLOCK_INITIALIZER) { rwl = *rwlock; @@ -226,7 +226,7 @@ pthread_rwlock_destroy(pthread_rwlock_t *rwlock) /* * Check again. */ - if (*rwlock == (pthread_rwlock_t) PTW32_OBJECT_AUTO_INIT) + if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) { /* * This is all we need to do to destroy a statically @@ -268,7 +268,7 @@ pthread_rwlock_rdlock(pthread_rwlock_t *rwlock) * again inside the guarded section of ptw32_rwlock_check_need_init() * to avoid race conditions. */ - if (*rwlock == (pthread_rwlock_t) PTW32_OBJECT_AUTO_INIT) + if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) { result = ptw32_rwlock_check_need_init(rwlock); @@ -340,7 +340,7 @@ pthread_rwlock_wrlock(pthread_rwlock_t * rwlock) * again inside the guarded section of ptw32_rwlock_check_need_init() * to avoid race conditions. */ - if (*rwlock == (pthread_rwlock_t) PTW32_OBJECT_AUTO_INIT) + if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) { result = ptw32_rwlock_check_need_init(rwlock); @@ -435,7 +435,7 @@ pthread_rwlock_unlock(pthread_rwlock_t * rwlock) return(EINVAL); } - if (*rwlock == (pthread_rwlock_t) PTW32_OBJECT_AUTO_INIT) + if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) { /* * Assume any race condition here is harmless. @@ -493,7 +493,7 @@ pthread_rwlock_tryrdlock(pthread_rwlock_t * rwlock) * again inside the guarded section of ptw32_rwlock_check_need_init() * to avoid race conditions. */ - if (*rwlock == (pthread_rwlock_t) PTW32_OBJECT_AUTO_INIT) + if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) { result = ptw32_rwlock_check_need_init(rwlock); @@ -553,7 +553,7 @@ pthread_rwlock_trywrlock(pthread_rwlock_t * rwlock) * again inside the guarded section of ptw32_rwlock_check_need_init() * to avoid race conditions. */ - if (*rwlock == (pthread_rwlock_t) PTW32_OBJECT_AUTO_INIT) + if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) { result = ptw32_rwlock_check_need_init(rwlock); -- cgit v1.2.3