1 //===--- rtsan.cpp - Realtime Sanitizer -------------------------*- 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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 //===----------------------------------------------------------------------===// 10 11 #include <rtsan/rtsan.h> 12 #include <rtsan/rtsan_context.h> 13 #include <rtsan/rtsan_interceptors.h> 14 15 using namespace __rtsan; 16 17 bool __rtsan::rtsan_initialized; 18 bool __rtsan::rtsan_init_is_running; 19 20 extern "C" { 21 __rtsan_init()22SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_init() { 23 CHECK(!rtsan_init_is_running); 24 if (rtsan_initialized) 25 return; 26 rtsan_init_is_running = true; 27 28 InitializeInterceptors(); 29 30 rtsan_init_is_running = false; 31 rtsan_initialized = true; 32 } 33 __rtsan_realtime_enter()34SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_realtime_enter() { 35 __rtsan::GetContextForThisThread().RealtimePush(); 36 } 37 __rtsan_realtime_exit()38SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_realtime_exit() { 39 __rtsan::GetContextForThisThread().RealtimePop(); 40 } 41 __rtsan_off()42SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_off() { 43 __rtsan::GetContextForThisThread().BypassPush(); 44 } 45 __rtsan_on()46SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_on() { 47 __rtsan::GetContextForThisThread().BypassPop(); 48 } 49 50 } // extern "C" 51