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"
34 // This must be the last.
40 explicit Mutex(MutexType type
, StatType stat_type
);
52 atomic_uintptr_t state_
;
56 #if TSAN_COLLECT_STATS
61 void operator = (const Mutex
&);
64 typedef GenericScopedLock
<Mutex
> Lock
;
65 typedef GenericScopedReadLock
<Mutex
> ReadLock
;
67 class InternalDeadlockDetector
{
69 InternalDeadlockDetector();
70 void Lock(MutexType t
);
71 void Unlock(MutexType t
);
75 u64 locked_
[MutexTypeCount
];
78 void InitializeMutex();
80 // Checks that the current thread does not hold any runtime locks
81 // (e.g. when returning from an interceptor).
82 void CheckNoLocks(ThreadState
*thr
);
86 #endif // TSAN_MUTEX_H