-#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
-
-/** @brief re-throwing of an already caught exception (ie, pass it to the upper catch block)
- * @hideinitializer
- */
-#define RETHROW \
- do { \
- if (__xbt_ex_ctx()->ctx_mctx == NULL) \
- __xbt_ex_terminate((xbt_ex_t *)&(__xbt_ex_ctx()->ctx_ex)); \
- else \
- __ex_mctx_restore(__xbt_ex_ctx()->ctx_mctx); \
- abort();\
- } while(0)
-
-
-#ifndef DOXYGEN_SKIP
-#define _XBT_PRE_RETHROW \
- do { \
- char *_xbt_ex_internal_msg = __xbt_ex_ctx()->ctx_ex.msg; \
- __xbt_ex_ctx()->ctx_ex.msg = bprintf(
-#define _XBT_POST_RETHROW \
- _xbt_ex_internal_msg); \
- free(_xbt_ex_internal_msg); \
- RETHROW; \
- } while (0)
-#endif
-
-/** @brief like THROW0, but adding some details to the message of an existing exception
- * @hideinitializer
- */
-#define RETHROW0(msg) _XBT_PRE_RETHROW msg, _XBT_POST_RETHROW
-/** @brief like THROW1, but adding some details to the message of an existing exception
- * @hideinitializer
- */
-#define RETHROW1(msg,a) _XBT_PRE_RETHROW msg,a, _XBT_POST_RETHROW
-/** @brief like THROW2, but adding some details to the message of an existing exception
- * @hideinitializer
- */
-#define RETHROW2(msg,a,b) _XBT_PRE_RETHROW msg,a,b, _XBT_POST_RETHROW
-/** @brief like THROW3, but adding some details to the message of an existing exception
- * @hideinitializer
- */
-#define RETHROW3(msg,a,b,c) _XBT_PRE_RETHROW msg,a,b,c, _XBT_POST_RETHROW
-/** @brief like THROW4, but adding some details to the message of an existing exception
- * @hideinitializer
- */
-#define RETHROW4(msg,a,b,c,d) _XBT_PRE_RETHROW msg,a,b,c,d, _XBT_POST_RETHROW
-/** @brief like THROW5, but adding some details to the message of an existing exception
- * @hideinitializer
- */
-#define RETHROW5(msg,a,b,c,d,e) _XBT_PRE_RETHROW msg,a,b,c,d,e, _XBT_POST_RETHROW
-
-/** @brief Exception destructor */
-XBT_PUBLIC(void) xbt_ex_free(xbt_ex_t e);
-
-/** @brief Shows a backtrace of the current location */
-XBT_PUBLIC(void) xbt_backtrace_display_current(void);
-/** @brief Captures a backtrace for further use */
-XBT_PUBLIC(void) xbt_backtrace_current(xbt_ex_t * e);
-/** @brief Display a previously captured backtrace */
-XBT_PUBLIC(void) xbt_backtrace_display(xbt_ex_t * e);