-#define xbt_throw(c,v,m) \
- (( __xbt_ex_ctx()->ctx_shielding > 0 \
- || (__xbt_ex_ctx()->ctx_deferring > 0 && __xbt_ex_ctx()->ctx_deferred == 1)) ? 0 : \
- (__xbt_ex_ctx()->ctx_ex.msg = bprintf(m), \
- __xbt_ex_ctx()->ctx_ex.category = (c), \
- __xbt_ex_ctx()->ctx_ex.value = (v), \
- __xbt_ex_ctx()->ctx_ex.host = (char*)NULL, \
- __xbt_ex_ctx()->ctx_ex.procname = strdup(xbt_procname()), \
- __xbt_ex_ctx()->ctx_ex.file = (char*)__FILE__, \
- __xbt_ex_ctx()->ctx_ex.line = __LINE__, \
- __xbt_ex_ctx()->ctx_ex.func = (char*)_XBT_FUNCTION, \
- __xbt_ex_ctx()->ctx_deferred = 1, \
- (__xbt_ex_ctx()->ctx_deferring > 0 ? 0 : \
- (__xbt_ex_ctx()->ctx_mctx == NULL \
- ? (__xbt_ex_terminate((ex_t *)&(__xbt_ex_ctx()->ctx_ex)), -1) \
- : (__ex_mctx_restore(__xbt_ex_ctx()->ctx_mctx), 1) ))))
+
+#define _THROW(c,v,m) \
+ do { /* change this sequence into one block */ \
+ ex_ctx_t *_throw_ctx = __xbt_ex_ctx(); \
+ /* build the exception */ \
+ _throw_ctx->ctx_ex.msg = (m); \
+ _throw_ctx->ctx_ex.category = (xbt_errcat_t)(c); \
+ _throw_ctx->ctx_ex.value = (v); \
+ _throw_ctx->ctx_ex.remote = 0; \
+ _throw_ctx->ctx_ex.host = (char*)NULL; \
+ _throw_ctx->ctx_ex.procname = (char*)xbt_procname(); \
+ _throw_ctx->ctx_ex.pid = (*xbt_getpid)(); \
+ _throw_ctx->ctx_ex.file = (char*)__FILE__; \
+ _throw_ctx->ctx_ex.line = __LINE__; \
+ _throw_ctx->ctx_ex.func = (char*)_XBT_FUNCTION; \
+ _throw_ctx->ctx_ex.bt_strings = NULL; \
+ xbt_backtrace_current( (xbt_ex_t *) &(_throw_ctx->ctx_ex) ); \
+ DO_THROW(_throw_ctx->ctx_ex); \
+ } while (0)
+/* __xbt_ex_ctx()->ctx_ex.used = backtrace((void**)__xbt_ex_ctx()->ctx_ex.bt,XBT_BACKTRACE_SIZE); */
+
+/** @brief Builds and throws an exception with a string taking no arguments
+ @hideinitializer */
+#define THROW0(c,v,m) _THROW(c,v,(m?bprintf(m):NULL))
+/** @brief Builds and throws an exception with a string taking one argument
+ @hideinitializer */
+#define THROW1(c,v,m,a1) _THROW(c,v,bprintf(m,a1))
+/** @brief Builds and throws an exception with a string taking two arguments
+ @hideinitializer */
+#define THROW2(c,v,m,a1,a2) _THROW(c,v,bprintf(m,a1,a2))
+/** @brief Builds and throws an exception with a string taking three arguments
+ @hideinitializer */
+#define THROW3(c,v,m,a1,a2,a3) _THROW(c,v,bprintf(m,a1,a2,a3))
+/** @brief Builds and throws an exception with a string taking four arguments
+ @hideinitializer */
+#define THROW4(c,v,m,a1,a2,a3,a4) _THROW(c,v,bprintf(m,a1,a2,a3,a4))
+/** @brief Builds and throws an exception with a string taking five arguments
+ @hideinitializer */
+#define THROW5(c,v,m,a1,a2,a3,a4,a5) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5))
+/** @brief Builds and throws an exception with a string taking six arguments
+ @hideinitializer */
+#define THROW6(c,v,m,a1,a2,a3,a4,a5,a6) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5,a6))
+/** @brief Builds and throws an exception with a string taking seven arguments
+ @hideinitializer */
+#define THROW7(c,v,m,a1,a2,a3,a4,a5,a6,a7) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5,a6,a7))
+
+#define THROW_IMPOSSIBLE THROW0(unknown_error,0,"The Impossible Did Happen (yet again)")
+#define THROW_UNIMPLEMENTED THROW1(unknown_error,0,"Function %s unimplemented",_XBT_FUNCTION)
+
+#ifndef NDEBUG
+# define DIE_IMPOSSIBLE xbt_assert0(0,"The Impossible Did Happen (yet again)")
+#else
+# define DIE_IMPOSSIBLE exit(1);
+#endif