about summary refs log tree commit diff
path: root/nptl/old_pthread_cond_timedwait.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-01-03 21:15:43 +0000
committerUlrich Drepper <drepper@redhat.com>2003-01-03 21:15:43 +0000
commit733f25e6d34d8ced182ffd6366d7914d56e71d98 (patch)
tree18b3f08bbfa7cf6c37e254df3824bb24be4c5d35 /nptl/old_pthread_cond_timedwait.c
parent686b7223d5e87538d8bc7eaf9581f4ad11d666f1 (diff)
downloadglibc-733f25e6d34d8ced182ffd6366d7914d56e71d98.tar.gz
glibc-733f25e6d34d8ced182ffd6366d7914d56e71d98.tar.xz
glibc-733f25e6d34d8ced182ffd6366d7914d56e71d98.zip
Update.
2003-01-03  Jakub Jelinek  <jakub@redhat.com>

	* 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.
Diffstat (limited to 'nptl/old_pthread_cond_timedwait.c')
-rw-r--r--nptl/old_pthread_cond_timedwait.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/nptl/old_pthread_cond_timedwait.c b/nptl/old_pthread_cond_timedwait.c
index 7b0faa78d2..ef4db9e6e8 100644
--- a/nptl/old_pthread_cond_timedwait.c
+++ b/nptl/old_pthread_cond_timedwait.c
@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include "pthreadP.h"
+#include <atomic.h>
 #include <shlib-compat.h>
 
 
@@ -32,18 +33,19 @@ __pthread_cond_timedwait_2_0 (cond, mutex, abstime)
 {
   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_timedwait (cond->cond, mutex, abstime);