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
15namespace __tsan {
16
17const uptr IgnoreSet::kMaxSize;
18
19IgnoreSet::IgnoreSet()
20    : size_() {
21}
22
23void 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
33void IgnoreSet::Reset() {
34  size_ = 0;
35}
36
37uptr IgnoreSet::Size() const {
38  return size_;
39}
40
41u32 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