Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
thread_sanitizer.h
Go to the documentation of this file.
1// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_PLATFORM_THREAD_SANITIZER_H_
6#define RUNTIME_PLATFORM_THREAD_SANITIZER_H_
7
8#include "platform/globals.h"
9
10#if __SANITIZE_THREAD__
11#define USING_THREAD_SANITIZER
12#elif defined(__has_feature)
13#if __has_feature(thread_sanitizer)
14#define USING_THREAD_SANITIZER
15#endif
16#endif
17
18#if defined(USING_THREAD_SANITIZER)
19#define NO_SANITIZE_THREAD __attribute__((no_sanitize("thread")))
20extern "C" void __tsan_acquire(void* addr);
21extern "C" void __tsan_release(void* addr);
22#else
23#define NO_SANITIZE_THREAD
24#endif
25
26#if defined(USING_THREAD_SANITIZER)
27#define DO_IF_TSAN(CODE) CODE
28#else
29#define DO_IF_TSAN(CODE)
30#endif
31
32#if defined(USING_THREAD_SANITIZER)
33#define DO_IF_NOT_TSAN(CODE)
34#else
35#define DO_IF_NOT_TSAN(CODE) CODE
36#endif
37
38// By default TSAN is enabled if this code is compiled under TSAN.
39//
40// Though in our AOT compiler we don't know whether the target AOT runtime will
41// use TSAN or not, so we'll rely on the build rules telling us that
42// information.
43#if defined(USING_THREAD_SANITIZER) && !defined(DART_PRECOMPILER) && \
44 !defined(TARGET_USES_THREAD_SANITIZER)
45#define TARGET_USES_THREAD_SANITIZER
46#endif
47
48#if defined(TARGET_USES_THREAD_SANITIZER)
49constexpr bool kTargetUsesThreadSanitizer = true;
50#else
51constexpr bool kTargetUsesThreadSanitizer = false;
52#endif
53
54#endif // RUNTIME_PLATFORM_THREAD_SANITIZER_H_
void __tsan_acquire(void *addr)
void __tsan_release(void *addr)
constexpr bool kTargetUsesThreadSanitizer