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
20namespace __csan {
21
22using __sanitizer::s32;
23using __sanitizer::u32;
24using __sanitizer::u64;
25using __sanitizer::uptr;
26
27struct 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
34extern Flags flags_data;
35inline Flags *flags() { return &flags_data; }
36
37void InitializeFlags();
38
39enum ValueChange { kValueChangeMaybe, kValueChangeFalse, kValueChangeTrue };
40
41static constexpr u32 kMaxStackFrames = 64;
42
43struct AccessInfo {
44 const volatile void *ptr;
45 uptr size;
46 int access_type;
47 u32 tid;
48 uptr pc;
49 uptr bp;
50};
51
52void RecordDataRace();
53void ReportKnownOrigin(const AccessInfo &AI, ValueChange VC, uptr PeerPC,
54 int PeerAccess, uptr PeerSize, u64 Old, u64 New);
55void ReportUnknownOrigin(const AccessInfo &AI, u64 Old, u64 New);
56
57} // namespace __csan
58
59extern "C" {
60SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE const char *
61__csan_default_options();
62}
63
64#endif // CSAN_H
65