]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libsanitizer/tsan/tsan_mutexset.h
1 //===-- tsan_mutexset.h -----------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file is a part of ThreadSanitizer (TSan), a race detector.
11 // MutexSet holds the set of mutexes currently held by a thread.
12 //===----------------------------------------------------------------------===//
13 #ifndef TSAN_MUTEXSET_H
14 #define TSAN_MUTEXSET_H
16 #include "tsan_defs.h"
22 // Holds limited number of mutexes.
23 // The oldest mutexes are discarded on overflow.
24 static const uptr kMaxSize
= 16;
33 // The 'id' is obtained from SyncVar::GetId().
34 void Add(u64 id
, bool write
, u64 epoch
);
35 void Del(u64 id
, bool write
);
36 void Remove(u64 id
); // Removes the mutex completely (if it's destroyed).
38 Desc
Get(uptr i
) const;
40 void operator=(const MutexSet
&other
) {
41 internal_memcpy(this, &other
, sizeof(*this));
47 Desc descs_
[kMaxSize
];
50 void RemovePos(uptr i
);
51 MutexSet(const MutexSet
&);
54 // Go does not have mutexes, so do not spend memory and time.
55 // (Go sync.Mutex is actually a semaphore -- can be unlocked
56 // in different goroutine).
58 MutexSet::MutexSet() {}
59 void MutexSet::Add(u64 id
, bool write
, u64 epoch
) {}
60 void MutexSet::Del(u64 id
, bool write
) {}
61 void MutexSet::Remove(u64 id
) {}
62 void MutexSet::RemovePos(uptr i
) {}
63 uptr
MutexSet::Size() const { return 0; }
64 MutexSet::Desc
MutexSet::Get(uptr i
) const { return Desc(); }
69 #endif // TSAN_MUTEXSET_H