1 //===-- tsan_mutex.h --------------------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of ThreadSanitizer (TSan), a race detector.
10 //===----------------------------------------------------------------------===//
14 #include "sanitizer_common/sanitizer_atomic.h"
15 #include "sanitizer_common/sanitizer_mutex.h"
16 #include "tsan_defs.h"
37 // This must be the last.
43 explicit Mutex(MutexType type
, StatType stat_type
);
55 atomic_uintptr_t state_
;
59 #if TSAN_COLLECT_STATS
64 void operator = (const Mutex
&);
67 typedef GenericScopedLock
<Mutex
> Lock
;
68 typedef GenericScopedReadLock
<Mutex
> ReadLock
;
70 class InternalDeadlockDetector
{
72 InternalDeadlockDetector();
73 void Lock(MutexType t
);
74 void Unlock(MutexType t
);
78 u64 locked_
[MutexTypeCount
];
81 void InitializeMutex();
83 // Checks that the current thread does not hold any runtime locks
84 // (e.g. when returning from an interceptor).
85 void CheckNoLocks(ThreadState
*thr
);
89 #endif // TSAN_MUTEX_H