1 //===-- tsan_mutex.h --------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of ThreadSanitizer (TSan), a race detector.
12 //===----------------------------------------------------------------------===//
16 #include "sanitizer_common/sanitizer_atomic.h"
17 #include "sanitizer_common/sanitizer_mutex.h"
18 #include "tsan_defs.h"
39 // This must be the last.
45 explicit Mutex(MutexType type, StatType stat_type);
57 atomic_uintptr_t state_;
61 #if TSAN_COLLECT_STATS
66 void operator = (const Mutex&);
69 typedef GenericScopedLock<Mutex> Lock;
70 typedef GenericScopedReadLock<Mutex> ReadLock;
72 class InternalDeadlockDetector {
74 InternalDeadlockDetector();
75 void Lock(MutexType t);
76 void Unlock(MutexType t);
80 u64 locked_[MutexTypeCount];
83 void InitializeMutex();
85 // Checks that the current thread does not hold any runtime locks
86 // (e.g. when returning from an interceptor).
87 void CheckNoLocks(ThreadState *thr);
91 #endif // TSAN_MUTEX_H