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. --- mutex.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'mutex.c') diff --git a/mutex.c b/mutex.c index 22a7e7b..09dbc2f 100644 --- a/mutex.c +++ b/mutex.c @@ -27,7 +27,7 @@ #include "implement.h" -static int +static INLINE int ptw32_mutex_check_need_init(pthread_mutex_t *mutex) { int result = 0; @@ -63,7 +63,7 @@ ptw32_mutex_check_need_init(pthread_mutex_t *mutex) * re-initialise it only by calling pthread_mutex_init() * explicitly. */ - if (*mutex == (pthread_mutex_t) PTW32_OBJECT_AUTO_INIT) + if (*mutex == PTHREAD_MUTEX_INITIALIZER) { result = pthread_mutex_init(mutex, NULL); } @@ -170,7 +170,7 @@ pthread_mutex_destroy(pthread_mutex_t *mutex) /* * Check to see if we have something to delete. */ - if (*mutex != (pthread_mutex_t) PTW32_OBJECT_AUTO_INIT) + if (*mutex != PTHREAD_MUTEX_INITIALIZER) { mx = *mutex; @@ -225,7 +225,7 @@ pthread_mutex_destroy(pthread_mutex_t *mutex) /* * Check again. */ - if (*mutex == (pthread_mutex_t) PTW32_OBJECT_AUTO_INIT) + if (*mutex == PTHREAD_MUTEX_INITIALIZER) { /* * This is all we need to do to destroy a statically @@ -630,7 +630,7 @@ pthread_mutex_lock(pthread_mutex_t *mutex) * again inside the guarded section of ptw32_mutex_check_need_init() * to avoid race conditions. */ - if (*mutex == (pthread_mutex_t) PTW32_OBJECT_AUTO_INIT) + if (*mutex == PTHREAD_MUTEX_INITIALIZER) { if ((result = ptw32_mutex_check_need_init(mutex)) != 0) { @@ -694,7 +694,7 @@ pthread_mutex_unlock(pthread_mutex_t *mutex) * race condition. If another thread holds the * lock then we shouldn't be in here. */ - if (mx != (pthread_mutex_t) PTW32_OBJECT_AUTO_INIT) + if (mx != PTHREAD_MUTEX_INITIALIZER) { if (mx->ownerThread == (pthread_t) PTW32_MUTEX_OWNER_ANONYMOUS || pthread_equal(mx->ownerThread, pthread_self())) @@ -745,7 +745,7 @@ pthread_mutex_trylock(pthread_mutex_t *mutex) * again inside the guarded section of ptw32_mutex_check_need_init() * to avoid race conditions. */ - if (*mutex == (pthread_mutex_t) PTW32_OBJECT_AUTO_INIT) + if (*mutex == PTHREAD_MUTEX_INITIALIZER) { result = ptw32_mutex_check_need_init(mutex); } -- cgit v1.2.3