Fix usages of TEMP_FAILURE_RETRY(pthread_foo(...)).

pthread functions don't return -1 and set errno on failure, they return
a positive errno value instead.

Test: treehugger
Change-Id: I0097660e44c86c4c49d642e1169a30e43f9662bf
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index b4aa327..8737927 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -590,8 +590,10 @@
     const char* reason = "dex2oat watch dog thread waiting";
     CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_lock, (&mutex_), reason);
     while (!shutting_down_) {
-      int rc = TEMP_FAILURE_RETRY(pthread_cond_timedwait(&cond_, &mutex_, &timeout_ts));
-      if (rc == ETIMEDOUT) {
+      int rc = pthread_cond_timedwait(&cond_, &mutex_, &timeout_ts);
+      if (rc == EINTR) {
+        continue;
+      } else if (rc == ETIMEDOUT) {
         Fatal(StringPrintf("dex2oat did not finish after %" PRId64 " seconds",
                            timeout_in_milliseconds_/1000));
       } else if (rc != 0) {
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index b2ddff3..c11e3d1 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -1028,7 +1028,11 @@
   guard_.recursion_count_ = 0;
   timespec ts;
   InitTimeSpec(true, clock, ms, ns, &ts);
-  int rc = TEMP_FAILURE_RETRY(pthread_cond_timedwait(&cond_, &guard_.mutex_, &ts));
+  int rc;
+  while ((rc = pthread_cond_timedwait(&cond_, &guard_.mutex_, &ts)) == EINTR) {
+    continue;
+  }
+
   if (rc == ETIMEDOUT) {
     timed_out = true;
   } else if (rc != 0) {