xref: /freebsd-src/contrib/llvm-project/compiler-rt/lib/tsan/rtl/tsan_ignoreset.cpp (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
168d75effSDimitry Andric //===-- tsan_ignoreset.cpp ------------------------------------------------===//
268d75effSDimitry Andric //
368d75effSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
468d75effSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
568d75effSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
668d75effSDimitry Andric //
768d75effSDimitry Andric //===----------------------------------------------------------------------===//
868d75effSDimitry Andric //
968d75effSDimitry Andric // This file is a part of ThreadSanitizer (TSan), a race detector.
1068d75effSDimitry Andric //
1168d75effSDimitry Andric //===----------------------------------------------------------------------===//
1268d75effSDimitry Andric #include "tsan_ignoreset.h"
1368d75effSDimitry Andric 
1468d75effSDimitry Andric namespace __tsan {
1568d75effSDimitry Andric 
1668d75effSDimitry Andric const uptr IgnoreSet::kMaxSize;
1768d75effSDimitry Andric 
IgnoreSet()1868d75effSDimitry Andric IgnoreSet::IgnoreSet()
1968d75effSDimitry Andric     : size_() {
2068d75effSDimitry Andric }
2168d75effSDimitry Andric 
Add(StackID stack_id)22*349cc55cSDimitry Andric void IgnoreSet::Add(StackID stack_id) {
2368d75effSDimitry Andric   if (size_ == kMaxSize)
2468d75effSDimitry Andric     return;
2568d75effSDimitry Andric   for (uptr i = 0; i < size_; i++) {
2668d75effSDimitry Andric     if (stacks_[i] == stack_id)
2768d75effSDimitry Andric       return;
2868d75effSDimitry Andric   }
2968d75effSDimitry Andric   stacks_[size_++] = stack_id;
3068d75effSDimitry Andric }
3168d75effSDimitry Andric 
At(uptr i) const32*349cc55cSDimitry Andric StackID IgnoreSet::At(uptr i) const {
3368d75effSDimitry Andric   CHECK_LT(i, size_);
3468d75effSDimitry Andric   CHECK_LE(size_, kMaxSize);
3568d75effSDimitry Andric   return stacks_[i];
3668d75effSDimitry Andric }
3768d75effSDimitry Andric 
3868d75effSDimitry Andric }  // namespace __tsan
39