diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_bench.cpp b/compiler-rt/lib/tsan/tests/rtl/tsan_bench.cpp --- a/compiler-rt/lib/tsan/tests/rtl/tsan_bench.cpp +++ b/compiler-rt/lib/tsan/tests/rtl/tsan_bench.cpp @@ -89,7 +89,7 @@ } TEST(DISABLED_BENCH, MutexLocal) { - Mutex m; + UserMutex m; ScopedThread().Create(m); for (int i = 0; i < 50; i++) { ScopedThread t; diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_mop.cpp b/compiler-rt/lib/tsan/tests/rtl/tsan_mop.cpp --- a/compiler-rt/lib/tsan/tests/rtl/tsan_mop.cpp +++ b/compiler-rt/lib/tsan/tests/rtl/tsan_mop.cpp @@ -65,7 +65,7 @@ } TEST(ThreadSanitizer, WriteThenLockedRead) { - Mutex m(Mutex::RW); + UserMutex m(UserMutex::RW); MainThread t0; t0.Create(m); MemLoc l; @@ -84,7 +84,7 @@ } TEST(ThreadSanitizer, LockedWriteThenRead) { - Mutex m(Mutex::RW); + UserMutex m(UserMutex::RW); MainThread t0; t0.Create(m); MemLoc l; diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_mutex.cpp b/compiler-rt/lib/tsan/tests/rtl/tsan_mutex.cpp --- a/compiler-rt/lib/tsan/tests/rtl/tsan_mutex.cpp +++ b/compiler-rt/lib/tsan/tests/rtl/tsan_mutex.cpp @@ -20,7 +20,7 @@ TEST(ThreadSanitizer, BasicMutex) { ScopedThread t; - Mutex m; + UserMutex m; t.Create(m); t.Lock(m); @@ -38,7 +38,7 @@ TEST(ThreadSanitizer, BasicSpinMutex) { ScopedThread t; - Mutex m(Mutex::Spin); + UserMutex m(UserMutex::Spin); t.Create(m); t.Lock(m); @@ -56,7 +56,7 @@ TEST(ThreadSanitizer, BasicRwMutex) { ScopedThread t; - Mutex m(Mutex::RW); + UserMutex m(UserMutex::RW); t.Create(m); t.Lock(m); @@ -92,7 +92,7 @@ } TEST(ThreadSanitizer, Mutex) { - Mutex m; + UserMutex m; MainThread t0; t0.Create(m); @@ -108,7 +108,7 @@ } TEST(ThreadSanitizer, SpinMutex) { - Mutex m(Mutex::Spin); + UserMutex m(UserMutex::Spin); MainThread t0; t0.Create(m); @@ -124,7 +124,7 @@ } TEST(ThreadSanitizer, RwMutex) { - Mutex m(Mutex::RW); + UserMutex m(UserMutex::RW); MainThread t0; t0.Create(m); @@ -150,7 +150,7 @@ TEST(ThreadSanitizer, StaticMutex) { // Emulates statically initialized mutex. - Mutex m; + UserMutex m; m.StaticInit(); { ScopedThread t1, t2; diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_test_util.h b/compiler-rt/lib/tsan/tests/rtl/tsan_test_util.h --- a/compiler-rt/lib/tsan/tests/rtl/tsan_test_util.h +++ b/compiler-rt/lib/tsan/tests/rtl/tsan_test_util.h @@ -28,7 +28,7 @@ void operator = (const MemLoc&); }; -class Mutex { +class UserMutex { public: enum Type { Normal, @@ -40,8 +40,8 @@ #endif }; - explicit Mutex(Type type = Normal); - ~Mutex(); + explicit UserMutex(Type type = Normal); + ~UserMutex(); void Init(); void StaticInit(); // Emulates static initialization (tsan invisible). @@ -59,8 +59,8 @@ bool alive_; const Type type_; - Mutex(const Mutex&); - void operator = (const Mutex&); + UserMutex(const UserMutex &); + void operator=(const UserMutex &); }; // A thread is started in CTOR and joined in DTOR. @@ -100,14 +100,14 @@ void Call(void(*pc)()); void Return(); - void Create(const Mutex &m); - void Destroy(const Mutex &m); - void Lock(const Mutex &m); - bool TryLock(const Mutex &m); - void Unlock(const Mutex &m); - void ReadLock(const Mutex &m); - bool TryReadLock(const Mutex &m); - void ReadUnlock(const Mutex &m); + void Create(const UserMutex &m); + void Destroy(const UserMutex &m); + void Lock(const UserMutex &m); + bool TryLock(const UserMutex &m); + void Unlock(const UserMutex &m); + void ReadLock(const UserMutex &m); + bool TryReadLock(const UserMutex &m); + void ReadUnlock(const UserMutex &m); void Memcpy(void *dst, const void *src, int size, bool expect_race = false); void Memset(void *dst, int val, int size, bool expect_race = false); diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cpp b/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cpp --- a/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cpp +++ b/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cpp @@ -90,16 +90,11 @@ MemLoc::~MemLoc() { } -Mutex::Mutex(Type type) - : alive_() - , type_(type) { -} +UserMutex::UserMutex(Type type) : alive_(), type_(type) {} -Mutex::~Mutex() { - CHECK(!alive_); -} +UserMutex::~UserMutex() { CHECK(!alive_); } -void Mutex::Init() { +void UserMutex::Init() { CHECK(!alive_); alive_ = true; if (type_ == Normal) @@ -114,7 +109,7 @@ CHECK(0); } -void Mutex::StaticInit() { +void UserMutex::StaticInit() { CHECK(!alive_); CHECK(type_ == Normal); alive_ = true; @@ -122,7 +117,7 @@ memcpy(mtx_, &tmp, sizeof(tmp)); } -void Mutex::Destroy() { +void UserMutex::Destroy() { CHECK(alive_); alive_ = false; if (type_ == Normal) @@ -135,7 +130,7 @@ CHECK_EQ(__interceptor_pthread_rwlock_destroy((pthread_rwlock_t*)mtx_), 0); } -void Mutex::Lock() { +void UserMutex::Lock() { CHECK(alive_); if (type_ == Normal) CHECK_EQ(__interceptor_pthread_mutex_lock((pthread_mutex_t*)mtx_), 0); @@ -147,7 +142,7 @@ CHECK_EQ(__interceptor_pthread_rwlock_wrlock((pthread_rwlock_t*)mtx_), 0); } -bool Mutex::TryLock() { +bool UserMutex::TryLock() { CHECK(alive_); if (type_ == Normal) return __interceptor_pthread_mutex_trylock((pthread_mutex_t*)mtx_) == 0; @@ -160,7 +155,7 @@ return false; } -void Mutex::Unlock() { +void UserMutex::Unlock() { CHECK(alive_); if (type_ == Normal) CHECK_EQ(__interceptor_pthread_mutex_unlock((pthread_mutex_t*)mtx_), 0); @@ -172,19 +167,19 @@ CHECK_EQ(__interceptor_pthread_rwlock_unlock((pthread_rwlock_t*)mtx_), 0); } -void Mutex::ReadLock() { +void UserMutex::ReadLock() { CHECK(alive_); CHECK(type_ == RW); CHECK_EQ(__interceptor_pthread_rwlock_rdlock((pthread_rwlock_t*)mtx_), 0); } -bool Mutex::TryReadLock() { +bool UserMutex::TryReadLock() { CHECK(alive_); CHECK(type_ == RW); return __interceptor_pthread_rwlock_tryrdlock((pthread_rwlock_t*)mtx_) == 0; } -void Mutex::ReadUnlock() { +void UserMutex::ReadUnlock() { CHECK(alive_); CHECK(type_ == RW); CHECK_EQ(__interceptor_pthread_rwlock_unlock((pthread_rwlock_t*)mtx_), 0); @@ -310,28 +305,28 @@ __tsan_func_exit(); break; case Event::MUTEX_CREATE: - static_cast(ev->ptr)->Init(); + static_cast(ev->ptr)->Init(); break; case Event::MUTEX_DESTROY: - static_cast(ev->ptr)->Destroy(); + static_cast(ev->ptr)->Destroy(); break; case Event::MUTEX_LOCK: - static_cast(ev->ptr)->Lock(); + static_cast(ev->ptr)->Lock(); break; case Event::MUTEX_TRYLOCK: - ev->res = static_cast(ev->ptr)->TryLock(); + ev->res = static_cast(ev->ptr)->TryLock(); break; case Event::MUTEX_UNLOCK: - static_cast(ev->ptr)->Unlock(); + static_cast(ev->ptr)->Unlock(); break; case Event::MUTEX_READLOCK: - static_cast(ev->ptr)->ReadLock(); + static_cast(ev->ptr)->ReadLock(); break; case Event::MUTEX_TRYREADLOCK: - ev->res = static_cast(ev->ptr)->TryReadLock(); + ev->res = static_cast(ev->ptr)->TryReadLock(); break; case Event::MUTEX_READUNLOCK: - static_cast(ev->ptr)->ReadUnlock(); + static_cast(ev->ptr)->ReadUnlock(); break; case Event::MEMCPY: __interceptor_memcpy(ev->ptr, (void*)ev->arg, ev->arg2); @@ -440,44 +435,44 @@ impl_->send(&event); } -void ScopedThread::Create(const Mutex &m) { +void ScopedThread::Create(const UserMutex &m) { Event event(Event::MUTEX_CREATE, &m); impl_->send(&event); } -void ScopedThread::Destroy(const Mutex &m) { +void ScopedThread::Destroy(const UserMutex &m) { Event event(Event::MUTEX_DESTROY, &m); impl_->send(&event); } -void ScopedThread::Lock(const Mutex &m) { +void ScopedThread::Lock(const UserMutex &m) { Event event(Event::MUTEX_LOCK, &m); impl_->send(&event); } -bool ScopedThread::TryLock(const Mutex &m) { +bool ScopedThread::TryLock(const UserMutex &m) { Event event(Event::MUTEX_TRYLOCK, &m); impl_->send(&event); return event.res; } -void ScopedThread::Unlock(const Mutex &m) { +void ScopedThread::Unlock(const UserMutex &m) { Event event(Event::MUTEX_UNLOCK, &m); impl_->send(&event); } -void ScopedThread::ReadLock(const Mutex &m) { +void ScopedThread::ReadLock(const UserMutex &m) { Event event(Event::MUTEX_READLOCK, &m); impl_->send(&event); } -bool ScopedThread::TryReadLock(const Mutex &m) { +bool ScopedThread::TryReadLock(const UserMutex &m) { Event event(Event::MUTEX_TRYREADLOCK, &m); impl_->send(&event); return event.res; } -void ScopedThread::ReadUnlock(const Mutex &m) { +void ScopedThread::ReadUnlock(const UserMutex &m) { Event event(Event::MUTEX_READUNLOCK, &m); impl_->send(&event); }