diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2012-02-08 19:58:37 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2012-02-08 19:58:37 +0000 |
commit | 461c56569f6feec66d6a9978728393a3c3ad5a9d (patch) | |
tree | 496546de2c73435a02462643fbc03c64fa549641 /winsup/cygwin/thread.cc | |
parent | 30c66cea49843469a9084d04ad0dea631baa27f3 (diff) | |
download | newlib-461c56569f6feec66d6a9978728393a3c3ad5a9d.zip newlib-461c56569f6feec66d6a9978728393a3c3ad5a9d.tar.gz newlib-461c56569f6feec66d6a9978728393a3c3ad5a9d.tar.bz2 |
* thread.cc (__pthread_cond_wait_init): New static function replacing
__pthread_cond_dowait. Only check and potentially initialize cond and
mutex, drop call to (*cond)->wait.
(pthread_cond_timedwait): Replace call to __pthread_cond_dowait with
separate calls to __pthread_cond_wait_init and (*cond)->wait to be
able to initialize cond before accessing its clock_id member.
(pthread_cond_wait): Ditto (more or less).
Diffstat (limited to 'winsup/cygwin/thread.cc')
-rw-r--r-- | winsup/cygwin/thread.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 901155a..5425a93 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -2746,8 +2746,7 @@ pthread_cond_signal (pthread_cond_t *cond) } static int -__pthread_cond_dowait (pthread_cond_t *cond, pthread_mutex_t *mutex, - PLARGE_INTEGER waitlength) +__pthread_cond_wait_init (pthread_cond_t *cond, pthread_mutex_t *mutex) { if (!pthread_mutex::is_good_object (mutex)) return EINVAL; @@ -2759,7 +2758,7 @@ __pthread_cond_dowait (pthread_cond_t *cond, pthread_mutex_t *mutex, if (!pthread_cond::is_good_object (cond)) return EINVAL; - return (*cond)->wait (*mutex, waitlength); + return 0; } extern "C" int @@ -2775,6 +2774,10 @@ pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, pthread_testcancel (); + int err = __pthread_cond_wait_init (cond, mutex); + if (err) + return err; + /* According to SUSv3, the abstime value must be checked for validity. */ if (abstime->tv_sec < 0 || abstime->tv_nsec < 0 @@ -2803,7 +2806,7 @@ pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, timeout.QuadPart *= -1LL; break; } - return __pthread_cond_dowait (cond, mutex, &timeout); + return (*cond)->wait (*mutex, &timeout); } extern "C" int @@ -2811,7 +2814,10 @@ pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) { pthread_testcancel (); - return __pthread_cond_dowait (cond, mutex, NULL); + int err = __pthread_cond_wait_init (cond, mutex); + if (err) + return err; + return (*cond)->wait (*mutex, NULL); } extern "C" int |