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
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 @@
   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 @@
   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_;