Expand art::GetTid() to cover Mac OS.

Change-Id: I8d5cea26fe108d81c4bd83ba0e8e3ee290e90211
diff --git a/src/utils.cc b/src/utils.cc
index bfc2272..bf15bd7 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -20,6 +20,21 @@
 #include <sys/prctl.h>
 #endif
 
+#if defined(__APPLE__)
+// Mac OS doesn't have gettid(2).
+pid_t gettid() { return getpid(); }
+#else
+// Neither bionic nor glibc exposes gettid(2).
+#define __KERNEL__
+#include <linux/unistd.h>
+#ifdef _syscall0
+_syscall0(pid_t, gettid)
+#else
+pid_t gettid() { return syscall(__NR_gettid); }
+#endif
+#undef __KERNEL__
+#endif
+
 namespace art {
 
 bool ReadFileToString(const std::string& file_name, std::string* result) {
@@ -623,16 +638,8 @@
   return (suffix == ".dex");
 }
 
-}  // namespace art
+pid_t GetTid() {
+  return gettid();
+}
 
-// Neither bionic nor glibc exposes gettid(2).
-#define __KERNEL__
-#include <linux/unistd.h>
-namespace art {
-#ifdef _syscall0
-_syscall0(pid_t, GetTid)
-#else
-pid_t GetTid() { return syscall(__NR_gettid); }
-#endif
 }  // namespace art
-#undef __KERNEL__