57ee563bc9
TEST=ci Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try;luci.dart.try:dart-sdk-mac-try;luci.dart.try:dart-sdk-mac-arm64-try;luci.dart.try:dart-sdk-win-try Change-Id: I9d4e7abe9541f74a67e469c4ba4ba3cecfaec431 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427280 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
48 lines
1.6 KiB
C++
48 lines
1.6 KiB
C++
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef RUNTIME_PLATFORM_NO_TSAN_H_
|
|
#define RUNTIME_PLATFORM_NO_TSAN_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <atomic>
|
|
|
|
namespace dart {
|
|
|
|
#if defined(__clang__)
|
|
// Clang does not honor no_sanitize(thread) for std::atomic, so we place
|
|
// the implementation in a separate compilation unit with TSAN disabled.
|
|
uintptr_t FetchAndRelaxedIgnoreRace(std::atomic<uintptr_t>* ptr,
|
|
uintptr_t value);
|
|
uintptr_t FetchOrRelaxedIgnoreRace(std::atomic<uintptr_t>* ptr,
|
|
uintptr_t value);
|
|
uintptr_t LoadRelaxedIgnoreRace(const std::atomic<uintptr_t>* ptr);
|
|
#else
|
|
#if defined(__GNUC__)
|
|
__attribute__((no_sanitize("thread")))
|
|
#endif
|
|
inline uintptr_t FetchAndRelaxedIgnoreRace(std::atomic<uintptr_t>* ptr,
|
|
uintptr_t value) {
|
|
return ptr->fetch_and(value, std::memory_order_relaxed);
|
|
}
|
|
#if defined(__GNUC__)
|
|
__attribute__((no_sanitize("thread")))
|
|
#endif
|
|
inline uintptr_t FetchOrRelaxedIgnoreRace(std::atomic<uintptr_t>* ptr,
|
|
uintptr_t value) {
|
|
return ptr->fetch_or(value, std::memory_order_relaxed);
|
|
}
|
|
#if defined(__GNUC__)
|
|
__attribute__((no_sanitize("thread")))
|
|
#endif
|
|
inline uintptr_t LoadRelaxedIgnoreRace(const std::atomic<uintptr_t>* ptr) {
|
|
return ptr->load(std::memory_order_relaxed);
|
|
}
|
|
#endif
|
|
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_PLATFORM_NO_TSAN_H_
|