From 29bc410c29ee2185bf91bf5fa923d8646ee9d501 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 4 Jan 2003 09:45:01 +0000 Subject: Update. * old_pthread_cond_broadcast.c: Optimize initialization a bit to work around gcc defficiencies. * old_pthread_cond_signal.c: Likewise. * old_pthread_cond_timedwait.c: Likewise. * old_pthread_cond_wait.c: Likewise. --- nptl/ChangeLog | 6 ++++++ nptl/old_pthread_cond_broadcast.c | 11 ++++++++--- nptl/old_pthread_cond_signal.c | 11 ++++++++--- nptl/old_pthread_cond_timedwait.c | 11 ++++++++--- nptl/old_pthread_cond_wait.c | 11 ++++++++--- 5 files changed, 38 insertions(+), 12 deletions(-) (limited to 'nptl') diff --git a/nptl/ChangeLog b/nptl/ChangeLog index d8a27c8107..2025464bfb 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,5 +1,11 @@ 2003-01-04 Ulrich Drepper + * old_pthread_cond_broadcast.c: Optimize initialization a bit to work + around gcc defficiencies. + * old_pthread_cond_signal.c: Likewise. + * old_pthread_cond_timedwait.c: Likewise. + * old_pthread_cond_wait.c: Likewise. + * pthreadP.h (pthread_cond_2_0_t): Remove unneeded lock element. 2003-01-03 Ulrich Drepper diff --git a/nptl/old_pthread_cond_broadcast.c b/nptl/old_pthread_cond_broadcast.c index 19918b072f..0db0aeab96 100644 --- a/nptl/old_pthread_cond_broadcast.c +++ b/nptl/old_pthread_cond_broadcast.c @@ -33,13 +33,18 @@ __pthread_cond_broadcast_2_0 (cond) { pthread_cond_t *newcond; +#if LLL_MUTEX_LOCK_INITIALIZER == 0 + newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1); + if (newcond == NULL) + return ENOMEM; +#else newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); if (newcond == NULL) return ENOMEM; - *newcond = (pthread_cond_t) PTHREAD_COND_INITIALIZER; - - atomic_write_barrier (); + /* Initialize the condvar. */ + (void) pthread_cond_init (newcond, NULL); +#endif if (atomic_compare_and_exchange_acq (&cond->cond, newcond, NULL) != 0) /* Somebody else just initialized the condvar. */ diff --git a/nptl/old_pthread_cond_signal.c b/nptl/old_pthread_cond_signal.c index c646b4dd40..ae54209e4a 100644 --- a/nptl/old_pthread_cond_signal.c +++ b/nptl/old_pthread_cond_signal.c @@ -33,13 +33,18 @@ __pthread_cond_signal_2_0 (cond) { pthread_cond_t *newcond; +#if LLL_MUTEX_LOCK_INITIALIZER == 0 + newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1); + if (newcond == NULL) + return ENOMEM; +#else newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); if (newcond == NULL) return ENOMEM; - *newcond = (pthread_cond_t) PTHREAD_COND_INITIALIZER; - - atomic_write_barrier (); + /* Initialize the condvar. */ + (void) pthread_cond_init (newcond, NULL); +#endif if (atomic_compare_and_exchange_acq (&cond->cond, newcond, NULL) != 0) /* Somebody else just initialized the condvar. */ diff --git a/nptl/old_pthread_cond_timedwait.c b/nptl/old_pthread_cond_timedwait.c index ef8047e1b8..b30e182b40 100644 --- a/nptl/old_pthread_cond_timedwait.c +++ b/nptl/old_pthread_cond_timedwait.c @@ -35,13 +35,18 @@ __pthread_cond_timedwait_2_0 (cond, mutex, abstime) { pthread_cond_t *newcond; +#if LLL_MUTEX_LOCK_INITIALIZER == 0 + newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1); + if (newcond == NULL) + return ENOMEM; +#else newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); if (newcond == NULL) return ENOMEM; - *newcond = (pthread_cond_t) PTHREAD_COND_INITIALIZER; - - atomic_write_barrier (); + /* Initialize the condvar. */ + (void) pthread_cond_init (newcond, NULL); +#endif if (atomic_compare_and_exchange_acq (&cond->cond, newcond, NULL) != 0) /* Somebody else just initialized the condvar. */ diff --git a/nptl/old_pthread_cond_wait.c b/nptl/old_pthread_cond_wait.c index 3b54faca69..50505a265e 100644 --- a/nptl/old_pthread_cond_wait.c +++ b/nptl/old_pthread_cond_wait.c @@ -34,13 +34,18 @@ __pthread_cond_wait_2_0 (cond, mutex) { pthread_cond_t *newcond; +#if LLL_MUTEX_LOCK_INITIALIZER == 0 + newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1); + if (newcond == NULL) + return ENOMEM; +#else newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); if (newcond == NULL) return ENOMEM; - *newcond = (pthread_cond_t) PTHREAD_COND_INITIALIZER; - - atomic_write_barrier (); + /* Initialize the condvar. */ + (void) pthread_cond_init (newcond, NULL); +#endif if (atomic_compare_and_exchange_acq (&cond->cond, newcond, NULL) != 0) /* Somebody else just initialized the condvar. */ -- cgit 1.4.1