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