* This module is a small ISO-C++ style exception handling library
* for use in the ISO-C language. It allows you to use the paradigm
* of throwing and catching exceptions in order to reduce the amount
* This module is a small ISO-C++ style exception handling library
* for use in the ISO-C language. It allows you to use the paradigm
* of throwing and catching exceptions in order to reduce the amount
* These features are brought to you by a modified version of the libex
* library, one of the numerous masterpiece of Ralf S. Engelschall.
*
* These features are brought to you by a modified version of the libex
* library, one of the numerous masterpiece of Ralf S. Engelschall.
*
* @section XBT_ex_intro DESCRIPTION
*
* In SimGrid, an exception is a triple <\a msg , \a category , \a value>
* @section XBT_ex_intro DESCRIPTION
*
* In SimGrid, an exception is a triple <\a msg , \a category , \a value>
* following code which shows some pitfalls and contains many errors (assuming
* a mallocex() function which throws an exception if malloc(3) fails):
*
* following code which shows some pitfalls and contains many errors (assuming
* a mallocex() function which throws an exception if malloc(3) fails):
*
(ctx)->ctx_ex.value = 0; \
(ctx)->ctx_ex.host = NULL; \
(ctx)->ctx_ex.procname = NULL; \
(ctx)->ctx_ex.value = 0; \
(ctx)->ctx_ex.host = NULL; \
(ctx)->ctx_ex.procname = NULL; \
do { /* change this sequence into one block */ \
/* build the exception */ \
__xbt_ex_ctx()->ctx_ex.msg = (m); \
do { /* change this sequence into one block */ \
/* build the exception */ \
__xbt_ex_ctx()->ctx_ex.msg = (m); \
__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_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; \
/* deal with the exception */ \
if (__xbt_ex_ctx()->ctx_mctx == NULL) \
__xbt_ex_terminate((xbt_ex_t *)&(__xbt_ex_ctx()->ctx_ex)); /* not catched */\
/* deal with the exception */ \
if (__xbt_ex_ctx()->ctx_mctx == NULL) \
__xbt_ex_terminate((xbt_ex_t *)&(__xbt_ex_ctx()->ctx_ex)); /* not catched */\
#define THROW6(c,v,m,a1,a2,a3,a4,a5,a6) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5,a6))
#define THROW_IMPOSSIBLE THROW0(unknown_error,0,"The Impossible Did Happen (yet again)")
#define THROW6(c,v,m,a1,a2,a3,a4,a5,a6) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5,a6))
#define THROW_IMPOSSIBLE THROW0(unknown_error,0,"The Impossible Did Happen (yet again)")
#define THROW_UNIMPLEMENTED THROW1(unknown_error,0,"Function %s unimplemented",__FUNCTION__)
#define THROW_UNIMPLEMENTED THROW1(unknown_error,0,"Function %s unimplemented",__FUNCTION__)