tsan_ignoreset.cc 978 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. namespace __tsan {
  13. const uptr IgnoreSet::kMaxSize;
  14. IgnoreSet::IgnoreSet()
  15. : size_() {
  16. }
  17. void IgnoreSet::Add(u32 stack_id) {
  18. if (size_ == kMaxSize)
  19. return;
  20. for (uptr i = 0; i < size_; i++) {
  21. if (stacks_[i] == stack_id)
  22. return;
  23. }
  24. stacks_[size_++] = stack_id;
  25. }
  26. void IgnoreSet::Reset() {
  27. size_ = 0;
  28. }
  29. uptr IgnoreSet::Size() const {
  30. return size_;
  31. }
  32. u32 IgnoreSet::At(uptr i) const {
  33. CHECK_LT(i, size_);
  34. CHECK_LE(size_, kMaxSize);
  35. return stacks_[i];
  36. }
  37. } // namespace __tsan