Fix missing error handling of pthreads_mutex_init and cond_wait
authorIvan Maidanski <ivmai@mail.ru>
Sat, 27 Sep 2014 15:30:06 +0000 (19:30 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 27 Sep 2014 16:03:20 +0000 (20:03 +0400)
commit734827bf66d135fccd5193b5f9d880ba23b44646
tree953c09c076d0b6fb96c72f1822bfeb0b20e2bb1d
parent8fc1f3b61b02320848b035ccccd59e04e77d3f6b
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.
include/private/darwin_semaphore.h
misc.c
specific.c