From fc35d943e1d39d2511d0aa870be417d2bc714d6b Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 11 Apr 2014 10:57:45 +0200 Subject: [PATCH] Make xbt_abort really silent on Windows. Another option was to make a call to _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT) but it seems that it's currently not supported by mingw. Moreover, make xbt_abort a real function. --- include/xbt/sysdep.h | 12 +----------- src/xbt/xbt_main.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/include/xbt/sysdep.h b/include/xbt/sysdep.h index 390ef24a7d..4b901a3592 100644 --- a/include/xbt/sysdep.h +++ b/include/xbt/sysdep.h @@ -31,17 +31,7 @@ SG_BEGIN_DECL() * @{ */ /** @brief Kill the program in silence */ -#ifdef COVERAGE -/* Call __gcov_flush on abort when compiling with coverage options. */ -#define xbt_abort() \ - do { \ - extern void __gcov_flush(void); \ - __gcov_flush(); \ - abort(); \ - } while (0) -#else -#define xbt_abort() abort() -#endif +XBT_PUBLIC(void) xbt_abort(void) _XBT_GNUC_NORETURN; /** * @brief Kill the program with an error message diff --git a/src/xbt/xbt_main.c b/src/xbt/xbt_main.c index 3af5c0371d..4616949b7c 100644 --- a/src/xbt/xbt_main.c +++ b/src/xbt/xbt_main.c @@ -22,6 +22,9 @@ #include "simgrid/sg_config.h" #include +#ifdef _XBT_WIN32 +#include +#endif XBT_LOG_NEW_CATEGORY(xbt, "All XBT categories (simgrid toolbox)"); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module, xbt, "module handling"); @@ -166,3 +169,21 @@ XBT_PUBLIC(void) xbt_free_ref(void *d) { free(*(void **) d); } + +/** @brief Kill the program in silence */ +void xbt_abort(void) +{ +#ifdef COVERAGE + /* Call __gcov_flush on abort when compiling with coverage options. */ + extern void __gcov_flush(void); + __gcov_flush(); +#endif +#ifdef _XBT_WIN32 + /* It was said *in silence*. We don't want to see the error message printed + * by the Microsoft's implementation of abort(). */ + raise(SIGABRT); + signal(SIGABRT, SIG_DFL); + raise(SIGABRT); +#endif + abort(); +} -- 2.20.1