diff options
author | Narayan Kamath <narayan@google.com> | 2014-03-04 11:57:09 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-03-20 10:11:13 +0000 |
commit | 51b71028661092e8860cca4f8ca79848e03cdc2c (patch) | |
tree | ebb78fc3f6af61ba5d015ddaf0d28d6c3cbbbac1 /runtime | |
parent | c5db77cce4138ac1f473872a06d230d876374337 (diff) | |
download | art-51b71028661092e8860cca4f8ca79848e03cdc2c.zip art-51b71028661092e8860cca4f8ca79848e03cdc2c.tar.gz art-51b71028661092e8860cca4f8ca79848e03cdc2c.tar.bz2 |
Remove use of pthread_cond_timedwait_monotonic.
Use posix compliant pthread_condattr_setclock instead.
Also, remove usage of HAVE_TIMEDWAIT_MONOTONIC and replace
it with a specific reference to the only supported platform
that doesn't have it.
Change-Id: I933f05c5b4965bab88ccd8e3e26c91549ed4184d
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/base/mutex.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc index fdf5763..532e6c4 100644 --- a/runtime/base/mutex.cc +++ b/runtime/base/mutex.cc @@ -650,7 +650,13 @@ ConditionVariable::ConditionVariable(const char* name, Mutex& guard) sequence_ = 0; num_waiters_ = 0; #else - CHECK_MUTEX_CALL(pthread_cond_init, (&cond_, NULL)); + pthread_condattr_t cond_attrs; + CHECK_MUTEX_CALL(pthread_condattr_init(&cond_attrs)); +#if !defined(__APPLE__) + // Apple doesn't have CLOCK_MONOTONIC or pthread_condattr_setclock. + CHECK_MUTEX_CALL(pthread_condattr_setclock(&cond_attrs, CLOCK_MONOTONIC)); +#endif + CHECK_MUTEX_CALL(pthread_cond_init, (&cond_, &cond_attrs)); #endif } @@ -788,17 +794,15 @@ void ConditionVariable::TimedWait(Thread* self, int64_t ms, int32_t ns) { CHECK_GE(guard_.num_contenders_, 0); guard_.num_contenders_--; #else -#ifdef HAVE_TIMEDWAIT_MONOTONIC -#define TIMEDWAIT pthread_cond_timedwait_monotonic +#if !defined(__APPLE__) int clock = CLOCK_MONOTONIC; #else -#define TIMEDWAIT pthread_cond_timedwait int clock = CLOCK_REALTIME; #endif guard_.recursion_count_ = 0; timespec ts; InitTimeSpec(true, clock, ms, ns, &ts); - int rc = TEMP_FAILURE_RETRY(TIMEDWAIT(&cond_, &guard_.mutex_, &ts)); + int rc = TEMP_FAILURE_RETRY(pthread_cond_timedwait(&cond_, &guard_.mutex_, &ts)); if (rc != 0 && rc != ETIMEDOUT) { errno = rc; PLOG(FATAL) << "TimedWait failed for " << name_; |