• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- tsan_ignoreset.cc -------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of ThreadSanitizer (TSan), a race detector.
11 //
12 //===----------------------------------------------------------------------===//
13 #include "tsan_ignoreset.h"
14 
15 namespace __tsan {
16 
17 const uptr IgnoreSet::kMaxSize;
18 
IgnoreSet()19 IgnoreSet::IgnoreSet()
20     : size_() {
21 }
22 
Add(u32 stack_id)23 void IgnoreSet::Add(u32 stack_id) {
24   if (size_ == kMaxSize)
25     return;
26   for (uptr i = 0; i < size_; i++) {
27     if (stacks_[i] == stack_id)
28       return;
29   }
30   stacks_[size_++] = stack_id;
31 }
32 
Reset()33 void IgnoreSet::Reset() {
34   size_ = 0;
35 }
36 
Size() const37 uptr IgnoreSet::Size() const {
38   return size_;
39 }
40 
At(uptr i) const41 u32 IgnoreSet::At(uptr i) const {
42   CHECK_LT(i, size_);
43   CHECK_LE(size_, kMaxSize);
44   return stacks_[i];
45 }
46 
47 }  // namespace __tsan
48