pthread: initialize static condition variables

Fixes #3741
This commit is contained in:
Christian Prochaska 2020-04-25 18:58:09 +02:00 committed by Norman Feske
parent 905b0c4aef
commit 07b87f6f1f
1 changed files with 12 additions and 3 deletions

View File

@ -903,9 +903,12 @@ extern "C" {
int pthread_cond_destroy(pthread_cond_t *cond)
{
if (!cond || !*cond)
if (!cond)
return EINVAL;
if (*cond == PTHREAD_COND_INITIALIZER)
return 0;
Libc::Allocator alloc { };
destroy(alloc, *cond);
*cond = 0;
@ -967,9 +970,12 @@ extern "C" {
int pthread_cond_signal(pthread_cond_t *cond)
{
if (!cond || !*cond)
if (!cond)
return EINVAL;
if (*cond == PTHREAD_COND_INITIALIZER)
cond_init(cond, NULL);
pthread_cond *c = *cond;
pthread_mutex_lock(&c->counter_mutex);
@ -987,9 +993,12 @@ extern "C" {
int pthread_cond_broadcast(pthread_cond_t *cond)
{
if (!cond || !*cond)
if (!cond)
return EINVAL;
if (*cond == PTHREAD_COND_INITIALIZER)
cond_init(cond, NULL);
pthread_cond *c = *cond;
pthread_mutex_lock(&c->counter_mutex);