summaryrefslogtreecommitdiffstats
path: root/runtime/base
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-03-31 10:03:07 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-03-31 10:03:08 +0000
commit8732bf96433bbc177de509390d285b2d5477c83d (patch)
tree3c8974efdff51311910e155b226a7e64060c7e7b /runtime/base
parent7f466c08888129a9923cb973a4dc73ee4a71574e (diff)
parent51b71028661092e8860cca4f8ca79848e03cdc2c (diff)
downloadart-8732bf96433bbc177de509390d285b2d5477c83d.zip
art-8732bf96433bbc177de509390d285b2d5477c83d.tar.gz
art-8732bf96433bbc177de509390d285b2d5477c83d.tar.bz2
Merge "Remove use of pthread_cond_timedwait_monotonic."
Diffstat (limited to 'runtime/base')
-rw-r--r--runtime/base/mutex.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 52a1672..fdd0249 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -649,7 +649,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
}
@@ -787,17 +793,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_;