]> 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>
Thu, 4 Jun 2015 20:49:51 +0000 (16:49 -0400)
Conditionally support helgrind annotations if valgrind support is
enabled during the build.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
configure.ac
src/common/Makefile.am
src/common/valgrind.h [new file with mode: 0644]

index f4ac2cd1c78c0cb3033cc301e1c4f02746980c63..5b98fb4e06f044e514f810a36732407cfcb32152 100644 (file)
@@ -1154,11 +1154,14 @@ 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])]),
+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
 
 dnl systemd-libexec-dir
 AC_SUBST(systemd_libexec_dir)
index 785b94ba633947c1d740c4acdd5f94f75383f388..8c985c7c09d92ab8da2091574ccce16923b48a8d 100644 (file)
@@ -233,7 +233,8 @@ noinst_HEADERS += \
        common/Initialize.h \
        common/ContextCompletion.h \
        common/bit_vector.hpp \
-       common/SubProcess.h
+       common/SubProcess.h \
+       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