]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: add valgrind.h convenience wrapper
authorJason Dillaman <dillaman@redhat.com>
Thu, 30 Apr 2015 17:26:41 +0000 (13:26 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 28 Jul 2015 20:34:22 +0000 (16:34 -0400)
Conditionally support helgrind annotations if valgrind support is
enabled during the build.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 650ad32d74a24d248dd8e19bff1bbd31f0bb224b)

configure.ac
src/common/Makefile.am
src/common/valgrind.h [new file with mode: 0644]

index cbed5a553d3d19a71115ea0151510f84020877ab..6c8f1349baa2d5a1a391380355e21ec95f8d4c1a 100644 (file)
@@ -1117,6 +1117,19 @@ AM_COND_IF([WITH_BABELTRACE], [
     AC_MSG_ERROR([babeltrace/ctf/events.h not found (libbabeltrace-ctf-dev, libbabeltrace-devel)]))
 ])
 
+dnl check for valgrind
+AC_ARG_ENABLE([valgrind],
+              [AS_HELP_STRING([--enable-valgrind], [enable valgrind unit tests])],
+              [enable_valgrind=$enableval], [enable_valgrind=])
+AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes)
+AS_IF(
+  [test "x$HAVE_VALGRIND" = "x"], AS_IF([test "x$enable_valgrind" = "xyes"], [AC_MSG_ERROR([valgrind not found])]),
+  [test "x$enable_valgrind" = "x"], [enable_valgrind=yes])
+
+AM_CONDITIONAL([VALGRIND_ENABLED], [test "x$enable_valgrind" = "xyes"])
+if test "x$enable_valgrind" = "xyes"; then
+  AC_CHECK_HEADERS([valgrind/helgrind.h])
+fi
 
 
 # Checks for typedefs, structures, and compiler characteristics.
index 78afd5e9d88a42ff5a50339b2d1a5e16933f0376..620e550003591eee840ee79d0e69dfe0b936efae 100644 (file)
@@ -233,7 +233,8 @@ noinst_HEADERS += \
        common/Cycles.h \
        common/Initialize.h \
        common/ContextCompletion.h \
-       common/bit_vector.hpp
+       common/bit_vector.hpp \
+       common/valgrind.h
 
 if ENABLE_XIO
 noinst_HEADERS += \
diff --git a/src/common/valgrind.h b/src/common/valgrind.h
new file mode 100644 (file)
index 0000000..2aa3fb5
--- /dev/null
@@ -0,0 +1,15 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_VALGRIND_H
+#define CEPH_VALGRIND_H
+
+#ifdef HAVE_VALGRIND_HELGRIND_H
+  #include <valgrind/helgrind.h>
+#else
+  #define ANNOTATE_HAPPENS_AFTER(x)             do {} while (0)
+  #define ANNOTATE_HAPPENS_BEFORE_FORGET_ALL(x) ANNOTATE_HAPPENS_AFTER(x)
+  #define ANNOTATE_HAPPENS_BEFORE(x)            ANNOTATE_HAPPENS_AFTER(x)
+#endif
+
+#endif // CEPH_VALGRIND_H