From: Jason Dillaman Date: Thu, 30 Apr 2015 17:26:41 +0000 (-0400) Subject: common: add valgrind.h convenience wrapper X-Git-Tag: v0.94.4~77^2~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7b85c7bfe599644eb29e6b1e03733da4774c2eac;p=ceph.git common: add valgrind.h convenience wrapper Conditionally support helgrind annotations if valgrind support is enabled during the build. Signed-off-by: Jason Dillaman (cherry picked from commit 650ad32d74a24d248dd8e19bff1bbd31f0bb224b) --- diff --git a/configure.ac b/configure.ac index cbed5a553d3d..6c8f1349baa2 100644 --- a/configure.ac +++ b/configure.ac @@ -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. diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 78afd5e9d88a..620e55000359 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -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 index 000000000000..2aa3fb5380ac --- /dev/null +++ b/src/common/valgrind.h @@ -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 +#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