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"
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