• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- tsan_ignoreset.cpp ------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of ThreadSanitizer (TSan), a race detector.
10 //
11 //===----------------------------------------------------------------------===//
12 #include "tsan_ignoreset.h"
13 
14 namespace __tsan {
15 
16 const uptr IgnoreSet::kMaxSize;
17 
IgnoreSet()18 IgnoreSet::IgnoreSet()
19     : size_() {
20 }
21 
Add(u32 stack_id)22 void IgnoreSet::Add(u32 stack_id) {
23   if (size_ == kMaxSize)
24     return;
25   for (uptr i = 0; i < size_; i++) {
26     if (stacks_[i] == stack_id)
27       return;
28   }
29   stacks_[size_++] = stack_id;
30 }
31 
Reset()32 void IgnoreSet::Reset() {
33   size_ = 0;
34 }
35 
Size() const36 uptr IgnoreSet::Size() const {
37   return size_;
38 }
39 
At(uptr i) const40 u32 IgnoreSet::At(uptr i) const {
41   CHECK_LT(i, size_);
42   CHECK_LE(size_, kMaxSize);
43   return stacks_[i];
44 }
45 
46 }  // namespace __tsan
47