Work around a bionic bug until I can fix bionic.
Also remove the Thread::pthread_ field, which isn't really needed. We also
don't need to update the TLS pointer to our Thread*, because the
address will be the same in the child anyway.
Change-Id: I595832a682a03ccdbb510e8e9ce0a32d5c6526b3
diff --git a/src/mutex.cc b/src/mutex.cc
index 27bb627..ee096a3 100644
--- a/src/mutex.cc
+++ b/src/mutex.cc
@@ -67,8 +67,16 @@
}
pid_t Mutex::GetOwner() {
-#ifdef __BIONIC__
+#if defined(__BIONIC__)
return static_cast<pid_t>((mutex_.value >> 16) & 0xffff);
+#elif defined(__GLIBC__)
+ struct __attribute__((__may_alias__)) glibc_pthread_t {
+ int lock;
+ unsigned int count;
+ int owner;
+ // ...other stuff we don't care about.
+ };
+ return reinterpret_cast<glibc_pthread_t*>(&mutex_)->owner;
#else
UNIMPLEMENTED(FATAL);
return 0;