1//===-- Valgrind.cpp - Implement Valgrind communication ---------*- 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// Defines Valgrind communication methods if valgrind.h is available. If we
10// have valgrind.h but valgrind isn't running, its macros are no-ops.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/Support/Valgrind.h"
15#include <stddef.h>
16
17#if __has_include(<valgrind/valgrind.h>)
18#include <valgrind/valgrind.h>
19
20bool llvm::sys::RunningOnValgrind() {
21 return RUNNING_ON_VALGRIND;
22}
23
24void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) {
25 VALGRIND_DISCARD_TRANSLATIONS(Addr, Len);
26}
27
28#else
29
30bool llvm::sys::RunningOnValgrind() {
31 return false;
32}
33
34void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) {
35}
36
37#endif
38