diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-01-03 21:15:43 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-01-03 21:15:43 +0000 |
commit | 733f25e6d34d8ced182ffd6366d7914d56e71d98 (patch) | |
tree | 18b3f08bbfa7cf6c37e254df3824bb24be4c5d35 /nptl | |
parent | 686b7223d5e87538d8bc7eaf9581f4ad11d666f1 (diff) | |
download | glibc-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')
-rw-r--r-- | nptl/ChangeLog | 11 | ||||
-rw-r--r-- | nptl/Makefile | 4 | ||||
-rw-r--r-- | nptl/atomic.h | 8 | ||||
-rw-r--r-- | nptl/old_pthread_cond_broadcast.c | 19 | ||||
-rw-r--r-- | nptl/old_pthread_cond_signal.c | 18 | ||||
-rw-r--r-- | nptl/old_pthread_cond_timedwait.c | 18 | ||||
-rw-r--r-- | nptl/old_pthread_cond_wait.c | 18 |
7 files changed, 58 insertions, 38 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog index e7173f9e4f..62744b1e37 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,14 @@ +2003-01-03 Ulrich Drepper <drepper@redhat.com> + + * atomic.h: Correct definitions of atomic_full_barrier, + atomic_read_barrier, atomic_write_barrier. + + * old_pthread_cond_broadcast.c: Make memory allocate and initialization + race-free. + * old_pthread_cond_signal.c: Likewise. + * old_pthread_cond_timedwait.c: Likewise. + * old_pthread_cond_wait.c: Likewise. + 2003-01-03 Jakub Jelinek <jakub@redhat.com> * Makefile ($(objpfx)libpthread.so): Depend on ld.so. diff --git a/nptl/Makefile b/nptl/Makefile index 2a68c2e566..ceee78758c 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -212,8 +212,10 @@ $(objpfx)libpthread.so: +preinit += $(objpfx)crti.o # Depend on libc.so so a DT_NEEDED is generated in the shared objects. # This ensures they will load libc.so for needed symbols if loaded by # a statically-linked program that hasn't already loaded it. +# Depend on ld.so too to get proper versions of ld.so symbols. $(objpfx)libpthread.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a + $(common-objpfx)libc_nonshared.a \ + $(if $(filter yes,$(elf)), $(elfobjdir)/ld.so) # Make sure we link with the thread library. ifeq ($(build-shared),yes) diff --git a/nptl/atomic.h b/nptl/atomic.h index 927e0fe5ac..0464705691 100644 --- a/nptl/atomic.h +++ b/nptl/atomic.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -93,17 +93,17 @@ #ifndef atomic_full_barrier -# define full_barrier() __asm ("" ::: "memory") +# define atomic_full_barrier() __asm ("" ::: "memory") #endif #ifndef atomic_read_barrier -# define read_barrier() full_barrier() +# define atomic_read_barrier() atomic_full_barrier() #endif #ifndef atomic_write_barrier -# define write_barrier() full_barrier() +# define atomic_write_barrier() atomic_full_barrier() #endif #endif /* atomic.h */ diff --git a/nptl/old_pthread_cond_broadcast.c b/nptl/old_pthread_cond_broadcast.c index a9713f5e1b..05f24bb52b 100644 --- a/nptl/old_pthread_cond_broadcast.c +++ b/nptl/old_pthread_cond_broadcast.c @@ -20,7 +20,7 @@ #include <errno.h> #include <stdlib.h> #include "pthreadP.h" -#include <lowlevellock.h> +#include <atomic.h> #include <shlib-compat.h> @@ -31,18 +31,19 @@ __pthread_cond_broadcast_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_broadcast (cond->cond); 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 <errno.h> #include <stdlib.h> #include "pthreadP.h" +#include <atomic.h> #include <shlib-compat.h> @@ -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); 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); diff --git a/nptl/old_pthread_cond_wait.c b/nptl/old_pthread_cond_wait.c index 493f00a3eb..b124b260d4 100644 --- a/nptl/old_pthread_cond_wait.c +++ b/nptl/old_pthread_cond_wait.c @@ -20,6 +20,7 @@ #include <errno.h> #include <stdlib.h> #include "pthreadP.h" +#include <atomic.h> #include <shlib-compat.h> @@ -31,18 +32,19 @@ __pthread_cond_wait_2_0 (cond, mutex) { 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_wait (cond->cond, mutex); |