From: Arnaud Giersch Date: Wed, 30 Jan 2019 22:36:05 +0000 (+0100) Subject: Define coverage_checkpoint(). X-Git-Tag: v3_22~435 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ac71236c9e7f701eaf63fad82567b52c0351bb9a Define coverage_checkpoint(). It's defined as an alias for __gcov_flush() when coverage is enabled, or a no-op otherwise. --- diff --git a/src/include/xbt/coverage.h b/src/include/xbt/coverage.h new file mode 100644 index 0000000000..c301f4157a --- /dev/null +++ b/src/include/xbt/coverage.h @@ -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 + +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 diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index 32ac1d2eb1..a573123518 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -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); diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 52346543cb..525280cb55 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -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