| 1 | //===----------------------------------------------------------------------===// |
| 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 | /// \file |
| 10 | /// Internal declarations for the host ConcurrencySanitizer runtime. |
| 11 | /// |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef CSAN_H |
| 15 | #define CSAN_H |
| 16 | |
| 17 | #include "csan_defs.h" |
| 18 | #include "sanitizer_common/sanitizer_internal_defs.h" |
| 19 | |
| 20 | namespace __csan { |
| 21 | |
| 22 | using __sanitizer::s32; |
| 23 | using __sanitizer::u32; |
| 24 | using __sanitizer::u64; |
| 25 | using __sanitizer::uptr; |
| 26 | |
| 27 | struct Flags { |
| 28 | #define CSAN_FLAG(Type, Name, DefaultValue, Description) Type Name; |
| 29 | #include "csan_flags.inc" |
| 30 | #undef CSAN_FLAG |
| 31 | void SetDefaults(); |
| 32 | }; |
| 33 | |
| 34 | extern Flags flags_data; |
| 35 | inline Flags *flags() { return &flags_data; } |
| 36 | |
| 37 | void InitializeFlags(); |
| 38 | |
| 39 | enum ValueChange { kValueChangeMaybe, kValueChangeFalse, kValueChangeTrue }; |
| 40 | |
| 41 | static constexpr u32 kMaxStackFrames = 64; |
| 42 | |
| 43 | struct AccessInfo { |
| 44 | const volatile void *ptr; |
| 45 | uptr size; |
| 46 | int access_type; |
| 47 | u32 tid; |
| 48 | uptr pc; |
| 49 | uptr bp; |
| 50 | }; |
| 51 | |
| 52 | void RecordDataRace(); |
| 53 | void ReportKnownOrigin(const AccessInfo &AI, ValueChange VC, uptr PeerPC, |
| 54 | int PeerAccess, uptr PeerSize, u64 Old, u64 New); |
| 55 | void ReportUnknownOrigin(const AccessInfo &AI, u64 Old, u64 New); |
| 56 | |
| 57 | } // namespace __csan |
| 58 | |
| 59 | extern "C" { |
| 60 | SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE const char * |
| 61 | __csan_default_options(); |
| 62 | } |
| 63 | |
| 64 | #endif // CSAN_H |
| 65 | |