Merge "Try to work around Mac OS 10.5 lossage." into ics-mr1-plus-art
diff --git a/src/mutex.cc b/src/mutex.cc
index 71b0ba8..da1ba7a 100644
--- a/src/mutex.cc
+++ b/src/mutex.cc
@@ -112,6 +112,13 @@
 }
 
 #if !defined(NDEBUG)
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED < 1060
+// Mac OS 10.5 didn't have anything we could implement GetTid() with. One thing we could try would
+// be using pthread_t instead of the actual tid; this would be acceptable in most places, and more
+// portable. 10.5 is already obsolete, though, so doing so would probably be all pain for no gain.
+void Mutex::AssertHeld() {}
+void Mutex::AssertNotHeld() {}
+#else
 void Mutex::AssertHeld() {
   DCHECK_EQ(GetOwner(), static_cast<uint64_t>(GetTid()));
 }
@@ -120,6 +127,7 @@
   DCHECK_NE(GetOwner(), static_cast<uint64_t>(GetTid()));
 }
 #endif
+#endif
 
 uint64_t Mutex::GetOwner() {
 #if defined(__BIONIC__)
diff --git a/src/utils.cc b/src/utils.cc
index 01fdac2..9a12b93 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -50,10 +50,14 @@
 namespace art {
 
 pid_t GetTid() {
-#if defined(__APPLE__)
-  // gettid(2) returns -1 on Darwin, but thread_selfid(2) works, and seems to be what their
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+  // Darwin has a gettid(2), but it does something completely unrelated to tids.
+  // There is a thread_selfid(2) that does what we want though, and it seems to be what their
   // pthreads implementation uses.
   return syscall(SYS_thread_selfid);
+#elif defined(__APPLE__)
+  // On Mac OS 10.5 (which the build servers are still running) there was nothing usable.
+  return getpid();
 #else
   // Neither bionic nor glibc exposes gettid(2).
   return syscall(__NR_gettid);