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/mutex.h b/src/mutex.h
index 02d127f..b019f68 100644
--- a/src/mutex.h
+++ b/src/mutex.h
@@ -49,41 +49,24 @@
void Unlock();
- const char* GetName() {
- return name_.c_str();
- }
-
- pthread_mutex_t* GetImpl() {
- return &mutex_;
- }
-
- MutexRank GetRank() const {
- return rank_;
- }
-
- void AssertHeld() {
-#if !defined(__APPLE__)
- DCHECK_EQ(GetOwner(), GetTid());
+#if !defined(NDEBUG)
+ void AssertHeld();
+ void AssertNotHeld();
+#else
+ void AssertHeld() {}
+ void AssertNotHeld() {}
#endif
- }
- void AssertNotHeld() {
-#if !defined(__APPLE__)
- DCHECK_NE(GetOwner(), GetTid());
-#endif
- }
-
- pid_t GetOwner();
+ uint64_t GetOwner();
private:
- static pid_t GetTid();
-
uint32_t GetDepth();
pthread_mutex_t mutex_;
std::string name_;
MutexRank rank_;
+ friend class ConditionVariable;
friend class MutexTester;
DISALLOW_COPY_AND_ASSIGN(Mutex);
};