Clean up Mutex a little and add the missing pieces for Mac OS.

This -- as you'd expect, given that we're fine on bionic and glibc --
didn't find any bugs. But it's another step towards completeness and
lets me rule out Mac pthread_mutex_t weirdness as a potential cause of
our Mac dex2oat crashes.

Change-Id: If3f4aacf8dbc7c7b9fd6b8932bc01616ccf86b47
diff --git a/src/utils.cc b/src/utils.cc
index 190cf4a..01fdac2 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -40,6 +40,7 @@
 
 #if defined(__APPLE__)
 #include "AvailabilityMacros.h"
+#include <sys/syscall.h>
 #endif
 
 #if defined(__linux__)
@@ -50,8 +51,9 @@
 
 pid_t GetTid() {
 #if defined(__APPLE__)
-  // Mac OS doesn't have gettid(2).
-  return getpid();
+  // gettid(2) returns -1 on Darwin, but thread_selfid(2) works, and seems to be what their
+  // pthreads implementation uses.
+  return syscall(SYS_thread_selfid);
 #else
   // Neither bionic nor glibc exposes gettid(2).
   return syscall(__NR_gettid);