3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
valgrind.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_VALGRIND_HH
25#define DUMUX_VALGRIND_HH
26#warning "This header is deprecated and will be removed after release 3.3"
27
28#if ! HAVE_VALGRIND
29namespace Valgrind
30{
31bool boolBlubb(bool value) { return value; }
32void voidBlubb() { }
33
34#define SetUndefined(t) voidBlubb()
35#define SetDefined(t) voidBlubb()
36#define CheckDefined(t) boolBlubb(true)
37#define SetNoAccess(t) voidBlubb()
38#define Running() boolBlubb(false)
39}
40#else
41
42#include <valgrind/memcheck.h>
43
44namespace Valgrind
45{
50inline bool Running()
51{
52#if !defined NDEBUG && HAVE_VALGRIND
53 return RUNNING_ON_VALGRIND;
54#else
55 return false;
56#endif
57}
58
59
72template <class T>
73inline bool CheckDefined(const T &value)
74{
75#if !defined NDEBUG && HAVE_VALGRIND
76 unsigned int tmp = VALGRIND_CHECK_MEM_IS_DEFINED(&value, sizeof(T));
77 return tmp == 0;
78#else
79 return true;
80#endif
81}
82
83template <class T>
84inline bool CheckDefined(const T *value, int size)
85{
86#if !defined NDEBUG && HAVE_VALGRIND
87 unsigned int tmp = VALGRIND_CHECK_MEM_IS_DEFINED(value, size*sizeof(T));
88 return tmp == 0;
89#else
90 return true;
91#endif
92}
93
102template <class T>
103inline void SetUndefined(const T &value)
104{
105#if !defined NDEBUG && HAVE_VALGRIND
106 VALGRIND_MAKE_MEM_UNDEFINED(&value, sizeof(T));
107#endif
108}
109
110template <class T>
111inline void SetUndefined(const T *value, int size)
112{
113#if !defined NDEBUG && HAVE_VALGRIND
114 VALGRIND_MAKE_MEM_UNDEFINED(value, size*sizeof(T));
115#endif
116}
117
126template <class T>
127inline void SetDefined(const T &value)
128{
129#if !defined NDEBUG && HAVE_VALGRIND
130 VALGRIND_MAKE_MEM_DEFINED(&value, sizeof(T));
131#endif
132}
133
134template <class T>
135inline void SetDefined(const T *value, int n)
136{
137#if !defined NDEBUG && HAVE_VALGRIND
138 VALGRIND_MAKE_MEM_DEFINED(value, n*sizeof(T));
139#endif
140}
141
150template <class T>
151inline void SetNoAccess(const T &value)
152{
153#if !defined NDEBUG && HAVE_VALGRIND
154 VALGRIND_MAKE_MEM_NOACCESS(&value, sizeof(T));
155#endif
156}
157
158template <class T>
159inline void SetNoAccess(const T *value, int n)
160{
161#if !defined NDEBUG && HAVE_VALGRIND
162 VALGRIND_MAKE_MEM_NOACCESS(value, n*sizeof(T));
163#endif
164}
165
166} // end namespace Valgrind
167
168#endif // HAVE_VALGRIND
169
170#endif
bool CheckDefined(const T &value)
Make valgrind complain if the object occupied by an object is undefined.
Definition: valgrind.hh:73
bool Running()
Returns whether the program is running under Valgrind or not.
Definition: valgrind.hh:50
void SetDefined(const T &value)
Make the memory on which an object resides defined.
Definition: valgrind.hh:127
void SetUndefined(const T &value)
Make the memory on which an object resides undefined.
Definition: valgrind.hh:103
void SetNoAccess(const T &value)
Make valgrind complain if an object's memory is accessed.
Definition: valgrind.hh:151
Definition: valgrind.hh:45