10b57cec5SDimitry Andric //===-- Valgrind.cpp - Implement Valgrind communication ---------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // Defines Valgrind communication methods, if HAVE_VALGRIND_VALGRIND_H is 100b57cec5SDimitry Andric // defined. If we have valgrind.h but valgrind isn't running, its macros are 110b57cec5SDimitry Andric // no-ops. 120b57cec5SDimitry Andric // 130b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 140b57cec5SDimitry Andric 15*1fd87a68SDimitry Andric #include <stddef.h> 160b57cec5SDimitry Andric #include "llvm/Support/Valgrind.h" 170b57cec5SDimitry Andric #include "llvm/Config/config.h" 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric #if HAVE_VALGRIND_VALGRIND_H 200b57cec5SDimitry Andric #include <valgrind/valgrind.h> 210b57cec5SDimitry Andric RunningOnValgrind()220b57cec5SDimitry Andricbool llvm::sys::RunningOnValgrind() { 230b57cec5SDimitry Andric return RUNNING_ON_VALGRIND; 240b57cec5SDimitry Andric } 250b57cec5SDimitry Andric ValgrindDiscardTranslations(const void * Addr,size_t Len)260b57cec5SDimitry Andricvoid llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) { 270b57cec5SDimitry Andric VALGRIND_DISCARD_TRANSLATIONS(Addr, Len); 280b57cec5SDimitry Andric } 290b57cec5SDimitry Andric 300b57cec5SDimitry Andric #else // !HAVE_VALGRIND_VALGRIND_H 310b57cec5SDimitry Andric RunningOnValgrind()320b57cec5SDimitry Andricbool llvm::sys::RunningOnValgrind() { 330b57cec5SDimitry Andric return false; 340b57cec5SDimitry Andric } 350b57cec5SDimitry Andric ValgrindDiscardTranslations(const void * Addr,size_t Len)360b57cec5SDimitry Andricvoid llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) { 370b57cec5SDimitry Andric } 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric #endif // !HAVE_VALGRIND_VALGRIND_H 40