summaryrefslogtreecommitdiff
path: root/specific.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2014-09-27 19:30:06 +0400
committerIvan Maidanski <ivmai@mail.ru>2014-09-27 20:03:20 +0400
commit734827bf66d135fccd5193b5f9d880ba23b44646 (patch)
tree953c09c076d0b6fb96c72f1822bfeb0b20e2bb1d /specific.c
parent8fc1f3b61b02320848b035ccccd59e04e77d3f6b (diff)
downloadbdwgc-734827bf66d135fccd5193b5f9d880ba23b44646.tar.gz
Fix missing error handling of pthreads_mutex_init and cond_wait
* include/private/darwin_semaphore.h (sem_init): Destroy sem->mutex if sem->cond initialization failed. * include/private/darwin_semaphore.h (sem_post): Ignore pthread_mutex_unlock result in case of pthread_cond_signal. * include/private/darwin_semaphore.h (sem_wait): Unlock mutex and return error (-1) if pthread_cond_wait failed. * include/private/darwin_semaphore.h (sem_init): If pshared then return -1 (with the appropriate errno code set) instead of ABORT. * include/private/darwin_semaphore.h (sem_init, sem_post, sem_wait): Treat non-zero value returned by pthread functions as error (instead of only negative values). * include/private/darwin_semaphore.h (sem_init, sem_post, sem_wait): Reformat code. * misc.c (GC_init): Abort (with the appropriate message) if pthread_mutex[attr]_init failed (SN_TARGET_PS3 case only). * specific.c (GC_key_create_inner): If pthread_mutex_init failed then return its error code.
Diffstat (limited to 'specific.c')
-rw-r--r--specific.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/specific.c b/specific.c
index 3657fbad..ba23e47d 100644
--- a/specific.c
+++ b/specific.c
@@ -26,12 +26,14 @@ static const tse invalid_tse = {INVALID_QTID, 0, 0, INVALID_THREADID};
GC_INNER int GC_key_create_inner(tsd ** key_ptr)
{
int i;
+ int ret;
tsd * result = (tsd *)MALLOC_CLEAR(sizeof(tsd));
/* A quick alignment check, since we need atomic stores */
GC_ASSERT((word)(&invalid_tse.next) % sizeof(tse *) == 0);
if (0 == result) return ENOMEM;
- pthread_mutex_init(&(result -> lock), NULL);
+ ret = pthread_mutex_init(&result->lock, NULL);
+ if (ret != 0) return ret;
for (i = 0; i < TS_CACHE_SIZE; ++i) {
result -> cache[i] = (/* no const */ tse *)&invalid_tse;
}