1 //===-- tsan_mutexset.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 // MutexSet holds the set of mutexes currently held by a thread.
13 //===----------------------------------------------------------------------===//
14 #ifndef TSAN_MUTEXSET_H
15 #define TSAN_MUTEXSET_H
17 #include "tsan_defs.h"
23 // Holds limited number of mutexes.
24 // The oldest mutexes are discarded on overflow.
25 static const uptr kMaxSize = 16;
34 // The 'id' is obtained from SyncVar::GetId().
35 void Add(u64 id, bool write, u64 epoch);
36 void Del(u64 id, bool write);
37 void Remove(u64 id); // Removes the mutex completely (if it's destroyed).
39 Desc Get(uptr i) const;
41 void operator=(const MutexSet &other) {
42 internal_memcpy(this, &other, sizeof(*this));
48 Desc descs_[kMaxSize];
51 void RemovePos(uptr i);
52 MutexSet(const MutexSet&);
55 // Go does not have mutexes, so do not spend memory and time.
56 // (Go sync.Mutex is actually a semaphore -- can be unlocked
57 // in different goroutine).
59 MutexSet::MutexSet() {}
60 void MutexSet::Add(u64 id, bool write, u64 epoch) {}
61 void MutexSet::Del(u64 id, bool write) {}
62 void MutexSet::Remove(u64 id) {}
63 void MutexSet::RemovePos(uptr i) {}
64 uptr MutexSet::Size() const { return 0; }
65 MutexSet::Desc MutexSet::Get(uptr i) const { return Desc(); }
70 #endif // TSAN_MUTEXSET_H