Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make xbt_abort really silent on Windows.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 11 Apr 2014 08:57:45 +0000 (10:57 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 11 Apr 2014 09:13:27 +0000 (11:13 +0200)
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
src/xbt/xbt_main.c

index 390ef24..4b901a3 100644 (file)
@@ -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
index 3af5c03..4616949 100644 (file)
@@ -22,6 +22,9 @@
 #include "simgrid/sg_config.h"
 
 #include <stdio.h>
+#ifdef _XBT_WIN32
+#include <signal.h>
+#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();
+}