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"
36 // This must be the last.
42 explicit Mutex(MutexType type
, StatType stat_type
);
54 atomic_uintptr_t state_
;
58 #if TSAN_COLLECT_STATS
63 void operator = (const Mutex
&);
66 typedef GenericScopedLock
<Mutex
> Lock
;
67 typedef GenericScopedReadLock
<Mutex
> ReadLock
;
69 class InternalDeadlockDetector
{
71 InternalDeadlockDetector();
72 void Lock(MutexType t
);
73 void Unlock(MutexType t
);
77 u64 locked_
[MutexTypeCount
];
80 void InitializeMutex();
82 // Checks that the current thread does not hold any runtime locks
83 // (e.g. when returning from an interceptor).
84 void CheckNoLocks(ThreadState
*thr
);
88 #endif // TSAN_MUTEX_H