76 lines · c
1//===-- sanitizer/rtsan_interface.h -----------------------------*- C++ -*-===//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-exception6//7//===----------------------------------------------------------------------===//8//9// This file is a part of RealtimeSanitizer.10//11// Public interface header.12//===----------------------------------------------------------------------===//13 14#ifndef SANITIZER_RTSAN_INTERFACE_H15#define SANITIZER_RTSAN_INTERFACE_H16 17#include <sanitizer/common_interface_defs.h>18 19#ifdef __cplusplus20extern "C" {21#endif // __cplusplus22 23// Disable all RTSan error reporting.24// Must be paired with a call to `__rtsan_enable`25void SANITIZER_CDECL __rtsan_disable(void);26 27// Re-enable all RTSan error reporting.28// Must follow a call to `__rtsan_disable`.29void SANITIZER_CDECL __rtsan_enable(void);30 31#ifdef __cplusplus32} // extern "C"33 34namespace __rtsan {35#if defined(__has_feature) && __has_feature(realtime_sanitizer)36 37class ScopedDisabler {38public:39 ScopedDisabler() { __rtsan_disable(); }40 ~ScopedDisabler() { __rtsan_enable(); }41 42#if __cplusplus >= 201103L43 ScopedDisabler(const ScopedDisabler &) = delete;44 ScopedDisabler &operator=(const ScopedDisabler &) = delete;45 ScopedDisabler(ScopedDisabler &&) = delete;46 ScopedDisabler &operator=(ScopedDisabler &&) = delete;47#else48private:49 ScopedDisabler(const ScopedDisabler &);50 ScopedDisabler &operator=(const ScopedDisabler &);51#endif // __cplusplus >= 201103L52};53 54#else55 56class ScopedDisabler {57public:58 ScopedDisabler() {}59#if __cplusplus >= 201103L60 ScopedDisabler(const ScopedDisabler &) = delete;61 ScopedDisabler &operator=(const ScopedDisabler &) = delete;62 ScopedDisabler(ScopedDisabler &&) = delete;63 ScopedDisabler &operator=(ScopedDisabler &&) = delete;64#else65private:66 ScopedDisabler(const ScopedDisabler &);67 ScopedDisabler &operator=(const ScopedDisabler &);68#endif // __cplusplus >= 201103L69};70 71#endif // defined(__has_feature) && __has_feature(realtime_sanitizer)72} // namespace __rtsan73#endif // __cplusplus74 75#endif // SANITIZER_RTSAN_INTERFACE_H76