From 733f25e6d34d8ced182ffd6366d7914d56e71d98 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 3 Jan 2003 21:15:43 +0000 Subject: Update. 2003-01-03 Jakub Jelinek * sysdeps/generic/ldsodefs.h (_dl_allocate_tls, _dl_deallocate_tls): Add rtld_hidden_proto. * sysdeps/generic/dl-tls.c (_dl_deallocate_tls): Add rtld_hidden_def. (_dl_allocate_tls): Likewise. Remove INTDEF. --- nptl/old_pthread_cond_signal.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'nptl/old_pthread_cond_signal.c') diff --git a/nptl/old_pthread_cond_signal.c b/nptl/old_pthread_cond_signal.c index 952ee6de41..717a33912b 100644 --- a/nptl/old_pthread_cond_signal.c +++ b/nptl/old_pthread_cond_signal.c @@ -20,6 +20,7 @@ #include #include #include "pthreadP.h" +#include #include @@ -30,18 +31,19 @@ __pthread_cond_signal_2_0 (cond) { if (cond->cond == NULL) { - lll_mutex_lock (cond->lock); + pthread_cond_t *newcond; - /* Check whether the condvar is still not allocated. */ - if (cond->cond == NULL) - cond->cond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); + newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); + if (newcond == NULL) + return ENOMEM; - lll_mutex_unlock (cond->lock); + *newcond = (struct pthread_cond_t) PTHREAD_COND_INITIALIZER; - if (cond->cond == NULL) - return ENOMEM; + atomic_write_barrier (); - *cond->cond = (struct pthread_cond_t) PTHREAD_COND_INITIALIZER; + if (atomic_compare_and_exchange_acq (&cond->cond, newcond, NULL) != 0) + /* Somebody else just initialized the condvar. */ + free (newcond); } return __pthread_cond_signal (cond->cond); -- cgit v1.2.3