From cf236808ad018ce10123321fab0917550e181aa2 Mon Sep 17 00:00:00 2001 From: rpj Date: Tue, 22 Jun 2004 06:12:54 +0000 Subject: Add PTHREAD_{RECURSIVE,ERRORCHECK}_MUTEX_INITIALIZER{,_NP} --- ptw32_mutex_check_need_init.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'ptw32_mutex_check_need_init.c') diff --git a/ptw32_mutex_check_need_init.c b/ptw32_mutex_check_need_init.c index bcaaf8b..5bd01e1 100644 --- a/ptw32_mutex_check_need_init.c +++ b/ptw32_mutex_check_need_init.c @@ -37,11 +37,19 @@ #include "pthread.h" #include "implement.h" +static struct pthread_mutexattr_t_ ptw32_recursive_mutexattr_s = + {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_RECURSIVE}; +static struct pthread_mutexattr_t_ ptw32_errorcheck_mutexattr_s = + {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_ERRORCHECK}; +static pthread_mutexattr_t ptw32_recursive_mutexattr = &ptw32_recursive_mutexattr_s; +static pthread_mutexattr_t ptw32_errorcheck_mutexattr = &ptw32_errorcheck_mutexattr_s; + INLINE int ptw32_mutex_check_need_init (pthread_mutex_t * mutex) { - int result = 0; + register int result = 0; + register pthread_mutex_t mtx; /* * The following guarded test is specifically for statically @@ -74,11 +82,21 @@ ptw32_mutex_check_need_init (pthread_mutex_t * mutex) * re-initialise it only by calling pthread_mutex_init() * explicitly. */ - if (*mutex == PTHREAD_MUTEX_INITIALIZER) + mtx = *mutex; + + if (mtx == PTHREAD_MUTEX_INITIALIZER) { result = pthread_mutex_init (mutex, NULL); } - else if (*mutex == NULL) + else if (mtx == PTHREAD_RECURSIVE_MUTEX_INITIALIZER) + { + result = pthread_mutex_init (mutex, &ptw32_recursive_mutexattr); + } + else if (mtx == PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) + { + result = pthread_mutex_init (mutex, &ptw32_errorcheck_mutexattr); + } + else if (mtx == NULL) { /* * The mutex has been destroyed while we were waiting to -- cgit v1.2.3