ART: Fix missing CLOCK_MONOTONIC on Mac

Fix the Mac build.

Bug: 31455788
Test: m
Change-Id: I03e927c28fe62abc1b14ea799190d00a081f33f7
diff --git a/runtime/openjdkjvmti/ti_timers.cc b/runtime/openjdkjvmti/ti_timers.cc
index ce4f551..24fb041 100644
--- a/runtime/openjdkjvmti/ti_timers.cc
+++ b/runtime/openjdkjvmti/ti_timers.cc
@@ -33,7 +33,11 @@
 
 #include <limits>
 
+#ifndef __APPLE__
 #include <time.h>
+#else
+#include <sys/time.h>
+#endif
 #include <unistd.h>
 
 #include "art_jvmti.h"
@@ -70,10 +74,18 @@
     return ERR(NULL_POINTER);
   }
 
+#ifndef __APPLE__
   // Use the same implementation as System.nanoTime.
   struct timespec now;
   clock_gettime(CLOCK_MONOTONIC, &now);
   *nanos_ptr = now.tv_sec * 1000000000LL + now.tv_nsec;
+#else
+  // No CLOCK_MONOTONIC support on older Mac OS.
+  struct timeval t;
+  t.tv_sec = t.tv_usec = 0;
+  gettimeofday(&t, NULL);
+  *nanos_ptr = static_cast<jlong>(t.tv_sec)*1000000000LL + static_cast<jlong>(t.tv_usec)*1000LL;
+#endif
 
   return ERR(NONE);
 }