Guard clock_gettime

clock_gettime is available on mac os starting from 10.12. On older
versions, let's use time(2).

Bug: 178124881
Test: watch a forrest run on mac
Change-Id: I60699cc013f090fe131642bf90afcfd3c6e9bdc6
diff --git a/libartbase/base/time_utils.cc b/libartbase/base/time_utils.cc
index 037d7b5..aeb7fa2 100644
--- a/libartbase/base/time_utils.cc
+++ b/libartbase/base/time_utils.cc
@@ -136,19 +136,24 @@
 #ifdef _WIN32
   time_t now = time(nullptr);
   localtime_s(&tmbuf, &now);
-  tm* ptm = &tmbuf;
   ns = 0;
 #else
-  timespec now;
-  clock_gettime(CLOCK_REALTIME, &now);
-  tm* ptm = localtime_r(&now.tv_sec, &tmbuf);
-  ns = now.tv_nsec;
+  if (__builtin_available(macOS 10.12, *)) {
+    timespec now;
+    clock_gettime(CLOCK_REALTIME, &now);
+    localtime_r(&now.tv_sec, &tmbuf);
+    ns = now.tv_nsec;
+  } else {
+    time_t now = time(nullptr);
+    localtime_r(&now, &tmbuf);
+    ns = 0;
+  }
 #endif
   char zone[16] = {};
-  strftime(zone, sizeof(zone), "%z", ptm);
+  strftime(zone, sizeof(zone), "%z", &tmbuf);
   return StringPrintf("%04d-%02d-%02d %02d:%02d:%02d.%09d%s",
-      ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday,
-      ptm->tm_hour, ptm->tm_min, ptm->tm_sec, ns, zone);
+      tmbuf.tm_year + 1900, tmbuf.tm_mon+1, tmbuf.tm_mday,
+      tmbuf.tm_hour, tmbuf.tm_min, tmbuf.tm_sec, ns, zone);
 }
 
 uint64_t MilliTime() {