1 //===-- tsan_mutexset.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 // MutexSet holds the set of mutexes currently held by a thread.
11 //===----------------------------------------------------------------------===//
12 #ifndef TSAN_MUTEXSET_H
13 #define TSAN_MUTEXSET_H
15 #include "tsan_defs.h"
21 // Holds limited number of mutexes.
22 // The oldest mutexes are discarded on overflow.
23 static const uptr kMaxSize
= 16;
32 // The 'id' is obtained from SyncVar::GetId().
33 void Add(u64 id
, bool write
, u64 epoch
);
34 void Del(u64 id
, bool write
);
35 void Remove(u64 id
); // Removes the mutex completely (if it's destroyed).
37 Desc
Get(uptr i
) const;
42 Desc descs_
[kMaxSize
];
45 void RemovePos(uptr i
);
48 // Go does not have mutexes, so do not spend memory and time.
49 // (Go sync.Mutex is actually a semaphore -- can be unlocked
50 // in different goroutine).
52 MutexSet::MutexSet() {}
53 void MutexSet::Add(u64 id
, bool write
, u64 epoch
) {}
54 void MutexSet::Del(u64 id
, bool write
) {}
55 void MutexSet::Remove(u64 id
) {}
56 void MutexSet::RemovePos(uptr i
) {}
57 uptr
MutexSet::Size() const { return 0; }
58 MutexSet::Desc
MutexSet::Get(uptr i
) const { return Desc(); }
63 #endif // TSAN_MUTEXSET_H