Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define coverage_checkpoint().
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 30 Jan 2019 22:36:05 +0000 (23:36 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 31 Jan 2019 08:48:21 +0000 (09:48 +0100)
It's defined as an alias for __gcov_flush() when coverage is enabled, or a
no-op otherwise.

src/include/xbt/coverage.h [new file with mode: 0644]
src/xbt/xbt_main.cpp
tools/cmake/DefinePackages.cmake

diff --git a/src/include/xbt/coverage.h b/src/include/xbt/coverage.h
new file mode 100644 (file)
index 0000000..c301f41
--- /dev/null
@@ -0,0 +1,22 @@
+/* Copyright (c) 2019. The SimGrid Team. All rights reserved.               */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef COVERAGE_H
+#define COVERAGE_H
+
+#include <xbt/base.h>
+
+SG_BEGIN_DECL()
+
+#ifdef COVERAGE
+extern void __gcov_flush();
+#define coverage_checkpoint() __gcov_flush()
+#else
+#define coverage_checkpoint() (void)0
+#endif
+
+SG_END_DECL()
+
+#endif
index 32ac1d2..a573123 100644 (file)
@@ -12,6 +12,7 @@
 #include "src/internal_config.h"
 #include "src/xbt_modinter.h" /* prototype of other module's init/exit in XBT */
 #include "xbt/config.hpp"
+#include "xbt/coverage.h"
 #include "xbt/dynar.h"
 #include "xbt/log.h"
 #include "xbt/log.hpp"
@@ -146,17 +147,11 @@ void xbt_free_ref(void *d)
   xbt_free(*(void**)d);
 }
 
-#ifdef COVERAGE
-extern "C" void __gcov_flush(); // used in xbt_abort()
-#endif
-
 /** @brief Kill the program in silence */
 void xbt_abort()
 {
-#ifdef COVERAGE
   /* Call __gcov_flush on abort when compiling with coverage options. */
-  __gcov_flush();
-#endif
+  coverage_checkpoint();
 #ifdef _WIN32
   /* We said *in silence*. We don't want to see the error message printed by Microsoft's implementation of abort(). */
   raise(SIGABRT);
index 5234654..525280c 100644 (file)
@@ -7,6 +7,7 @@ set(EXTRA_DIST
   src/include/mc/mc.h
   src/include/simgrid/sg_config.hpp
   src/include/surf/surf.hpp
+  src/include/xbt/coverage.h
   src/include/xbt/parmap.hpp
   src/include/xbt/mmalloc.h
   src/include/catch.hpp