Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
And now, a syntaxically correct version of my 'cleanup' (sorry)
[simgrid.git] / include / xbt / ex.h
1 /* $Id$ */
2
3 /* ex - Exception Handling (modified to fit into SimGrid from OSSP version) */
4
5 /*  Copyright (c) 2005-2006 Martin Quinson                                  */
6 /*  Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com>       */
7 /*  Copyright (c) 2002-2004 The OSSP Project <http://www.ossp.org/>         */
8 /*  Copyright (c) 2002-2004 Cable & Wireless <http://www.cw.com/>           */
9 /*  All rights reserved.                                                    */
10
11 /* This program is free software; you can redistribute it and/or modify it
12   * under the terms of the license (GNU LGPL) which comes with this package. */
13
14 #ifndef __XBT_EX_H__
15 #define __XBT_EX_H__
16
17 #include <xbt/sysdep.h>
18 #include <xbt/misc.h>
19
20 /* do not include execinfo.h directly since it's not always available. 
21    Instead, copy the parts we need (and fake when it's not there) */
22 extern int backtrace (void **__array, int __size);
23
24 /* required ISO-C standard facilities */
25 #include <errno.h>
26 #include <stdio.h>
27
28
29 /*-*-* Emergency debuging: define this when the exceptions get crazy *-*-*/
30 #undef __EX_MAYDAY
31
32 #ifdef __EX_MAYDAY
33 int gras_os_getpid(void);
34 #  define MAYDAY_SAVE(m)    printf("%d %s:%d save %p\n",                \
35                                    gras_os_getpid(),__FILE__,__LINE__,  \
36                                    (m)->jb                              \
37                                   ),
38 #  define MAYDAY_RESTORE(m) printf("%d %s:%d restore %p\n",             \
39                                    gras_os_getpid(),__FILE__,__LINE__,  \
40                                    (m)->jb                              \
41                                   ),
42 #  define MAYDAY_CATCH(e)   printf("%d %s:%d Catched '%s'\n",           \
43                                    gras_os_getpid(),__FILE__,__LINE__,  \
44                                    e.msg                                \
45                                   ),
46 #else
47 #  define MAYDAY_SAVE(m)
48 #  define MAYDAY_RESTORE(m)
49 #  define MAYDAY_CATCH(e)
50 #endif
51
52 /*-*-* end of debugging stuff *-*-*/
53
54
55 /* the machine context */
56 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
57 #include "xbt/win32_context.h"
58
59 #elif defined(__EX_MCTX_MCSC__)
60 #include <ucontext.h>            /* POSIX.1 ucontext(3) */
61 #define __ex_mctx_struct         ucontext_t uc;
62 #define __ex_mctx_save(mctx)     (getcontext(&(mctx)->uc) == 0)
63 #define __ex_mctx_restored(mctx) /* noop */
64 #define __ex_mctx_restore(mctx)  (void)setcontext(&(mctx)->uc)
65
66 #elif defined(__EX_MCTX_SSJLJ__)
67 #include <setjmp.h>              /* POSIX.1 sigjmp_buf(3) */
68 #define __ex_mctx_struct         sigjmp_buf jb;
69 #define __ex_mctx_save(mctx)     (sigsetjmp((mctx)->jb, 1) == 0)
70 #define __ex_mctx_restored(mctx) /* noop */
71 #define __ex_mctx_restore(mctx)  (void)siglongjmp((mctx)->jb, 1)
72
73 #elif defined(__EX_MCTX_SJLJ__) || !defined(__EX_MCTX_CUSTOM__) || defined(__EX_MAYDAY)
74 #include <setjmp.h>              /* ISO-C jmp_buf(3) */
75 #define __ex_mctx_struct         jmp_buf jb;
76 #define __ex_mctx_save(mctx)     ( MAYDAY_SAVE(mctx) setjmp((mctx)->jb) == 0)
77 #define __ex_mctx_restored(mctx) /* noop */
78 #define __ex_mctx_restore(mctx)  ( MAYDAY_RESTORE(mctx) (void)longjmp((mctx)->jb, 1))
79 #endif
80
81 /* declare the machine context type */
82 typedef struct { __ex_mctx_struct } __ex_mctx_t;
83
84 /** @addtogroup XBT_ex
85  *  @brief A set of macros providing exception a la C++ in ANSI C (grounding feature)
86  *
87  * This module is a small ISO-C++ style exception handling library
88  * for use in the ISO-C language. It allows you to use the paradigm 
89  * of throwing and catching exceptions in order to reduce the amount
90  * of error handling code without hindering program robustness.
91  *               
92  * This is achieved by directly transferring exceptional return codes
93  * (and the program control flow) from the location where the exception
94  * is raised (throw point) to the location where it is handled (catch
95  * point) -- usually from a deeply nested sub-routine to a parent 
96  * routine. All intermediate routines no longer have to make sure that 
97  * the exceptional return codes from sub-routines are correctly passed 
98  * back to the parent.
99  *
100  * These features are brought to you by a modified version of the libex 
101  * library, one of the numerous masterpiece of Ralf S. Engelschall.
102  *
103  * \htmlonly <div class="toc">\endhtmlonly
104  *
105  * @section XBT_ex_toc TABLE OF CONTENTS
106  *
107  *  - \ref XBT_ex_intro
108  *  - \ref XBT_ex_base
109  *  - \ref XBT_ex_pitfalls
110  *
111  * \htmlonly </div> \endhtmlonly
112  *
113  * @section XBT_ex_intro DESCRIPTION
114  * 
115  * In SimGrid, an exception is a triple <\a msg , \a category , \a value> 
116  * where \a msg is a human-readable text describing the exceptional 
117  * condition, \a code an integer describing what went wrong and \a value
118  * providing a sort of sub-category. (this is different in the original libex).
119  *
120  * @section XBT_ex_base BASIC USAGE
121  *
122  * \em TRY \b TRIED_BLOCK [\em CLEANUP \b CLEANUP_BLOCK] \em CATCH (variable) \b CATCH_BLOCK
123  *
124  * This is the primary syntactical construct provided. It is modeled after the
125  * ISO-C++ try-catch clause and should sound familiar to most of you.
126  *
127  * Any exception thrown directly from the TRIED_BLOCK block or from called
128  * subroutines is caught. Cleanups which must be done after this block
129  * (whenever an exception arised or not) should be placed into the optionnal
130  * CLEANUP_BLOCK. The code dealing with the exceptions when they arise should
131  * be placed into the (mandatory) CATCH_BLOCK.
132  *
133  * 
134  * In absence of exception, the control flow goes into the blocks TRIED_BLOCK
135  * and CLEANUP_BLOCK (if present); The CATCH_BLOCK block is then ignored. 
136  *
137  * When an exception is thrown, the control flow goes through the following
138  * blocks: TRIED_BLOCK (up to the statement throwing the exception),
139  * CLEANUP_BLOCK (if any) and CATCH_BLOCK. The exception is stored in a
140  * variable for inspection inside the CATCH_BLOCK. This variable must be
141  * declared in the outter scope, but its value is only valid within the
142  * CATCH_BLOCK block. 
143  *
144  * Some notes:
145  *  - TRY, CLEANUP and CATCH cannot be used separately, they work
146  *    only in combination and form a language clause as a whole.
147  *  - In contrast to the syntax of other languages (such as C++ or Jave) there
148  *    is only one CATCH block and not multiple ones (all exceptions are
149  *    of the same \em xbt_ex_t C type). 
150  *  - the variable of CATCH can naturally be reused in subsequent 
151  *    CATCH clauses.
152  *  - it is possible to nest TRY clauses.
153  *
154  * The TRY block is a regular ISO-C language statement block, but
155  * 
156  * <center><b>it is not
157  * allowed to jump into it via "goto" or longjmp(3) or out of it via "break",
158  * "return", "goto" or longjmp(3)</b>.</center>
159  *
160  * This is because there is some hidden setup and
161  * cleanup that needs to be done regardless of whether an exception is
162  * caught. Bypassing these steps will break the exception handling facility.
163  * The symptom are likely to be a segfault at the next exception raising point,  
164  * ie far away from the point where you did the mistake. If you suspect
165  * that kind of error in your code, have a look at the little script
166  * <tt>tools/xbt_exception_checker</tt> in the CVS. It extracts all the TRY
167  * blocks from a set of C files you give it and display them (and only
168  * them) on the standard output. You can then grep for the forbidden 
169  * keywords on that output.
170  *   
171  * The CLEANUP and CATCH blocks are regular ISO-C language statement
172  * blocks without any restrictions. You are even allowed to throw (and, in the
173  * CATCH block, to re-throw) exceptions.
174  *
175  * There is one subtle detail you should remember about TRY blocks:
176  * Variables used in the CLEANUP or CATCH clauses must be declared with
177  * the storage class "volatile", otherwise they might contain outdated
178  * information if an exception is thrown.
179  *
180  *
181  * This is because you usually do not know which commands in the TRY
182  * were already successful before the exception was thrown (logically speaking)
183  * and because the underlying ISO-C setjmp(3) facility applies those
184  * restrictions (technically speaking). As a matter of fact, value changes
185  * between the TRY and the THROW may be discarded if you forget the
186  * "volatile" keyword. 
187  * 
188  * \section XBT_ex_pitfalls PROGRAMMING PITFALLS 
189  *
190  * Exception handling is a very elegant and efficient way of dealing with
191  * exceptional situation. Nevertheless it requires additional discipline in
192  * programming and there are a few pitfalls one must be aware of. Look the
193  * following code which shows some pitfalls and contains many errors (assuming
194  * a mallocex() function which throws an exception if malloc(3) fails):
195  *
196  * \dontinclude ex.c
197  * \skip BAD_EXAMPLE
198  * \until end_of_bad_example
199  *
200  * This example raises a few issues:
201  *  -# \b variable \b scope \n
202  *     Variables which are used in the CLEANUP or CATCH clauses must be
203  *     declared before the TRY clause, otherwise they only exist inside the
204  *     TRY block. In the example above, cp1, cp2 and cp3 only exist in the
205  *     TRY block and are invisible from the CLEANUP and CATCH
206  *     blocks.
207  *  -# \b variable \b initialization \n
208  *     Variables which are used in the CLEANUP or CATCH clauses must
209  *     be initialized before the point of the first possible THROW is
210  *     reached. In the example above, CLEANUP would have trouble using cp3
211  *     if mallocex() throws a exception when allocating a TOOBIG buffer.
212  *  -# \b volatile \b variable \n
213  *     Variables which are used in the CLEANUP or CATCH clauses MUST BE
214  *     DECLARED AS "volatile", otherwise they might contain outdated
215  *     information when an exception is thrown. 
216  *  -# \b clean \b before \b catch \n
217  *     The CLEANUP clause is not only place before the CATCH clause in
218  *     the source code, it also occures before in the control flow. So,
219  *     resources being cleaned up cannot be used in the CATCH block. In the
220  *     example, c3 gets freed before the printf placed in CATCH.
221  *  -# \b variable \b uninitialization \n
222  *     If resources are passed out of the scope of the
223  *     TRY/CLEANUP/CATCH construct, they naturally shouldn't get
224  *     cleaned up. The example above does free(3) cp1 in CLEANUP although
225  *     its value was affected to globalcontext->first, invalidating this
226  *     pointer.
227
228  * The following is fixed version of the code (annotated with the pitfall items
229  * for reference): 
230  *
231  * \skip GOOD_EXAMPLE
232  * \until end_of_good_example
233  *
234  * @{
235  */
236
237 /* we need this symbol here, even if it breaks a bit the module separation */
238 long int gras_os_getpid(void);
239
240 /** @brief different kind of errors */
241 typedef enum {
242   unknown_error=0,  /**< unknown error */
243   arg_error,        /**< Invalid argument */
244   mismatch_error,   /**< The provided ID does not match */
245   not_found_error,  /**< The searched element was not found */
246   
247   system_error,   /**< a syscall did fail */
248   network_error,  /**< error while sending/receiving data */
249   timeout_error,  /**< not quick enough, dude */
250   thread_error    /**< error while [un]locking */
251 } xbt_errcat_t;
252
253 const char * xbt_ex_catname(xbt_errcat_t cat);
254
255 /** @brief Structure describing an exception */
256 typedef struct {
257   char        *msg;      /**< human readable message */
258   xbt_errcat_t category; /**< category like HTTP (what went wrong) */
259   int          value;    /**< like errno (why did it went wrong) */
260   /* throw point */
261   short int remote; /**< whether it was raised remotely */
262   char *host;     /**< NULL locally thrown exceptions; full hostname if remote ones */
263   /* FIXME: host should be hostname:port[#thread] */
264   char *procname; /**< Name of the process who thrown this */
265   long int pid;   /**< PID of the process who thrown this */
266   char *file;     /**< Thrown point */
267   int   line;     /**< Thrown point */
268   char *func;     /**< Thrown point */
269   /* Backtrace */
270   int   used;
271   char **bt_strings; /* only filed on display (or before the network propagation) */
272   void *bt[XBT_BACKTRACE_SIZE];
273 } xbt_ex_t;
274
275 /* declare the context type (private) */
276 typedef struct {
277     __ex_mctx_t  *ctx_mctx;     /* permanent machine context of enclosing try/catch */
278     volatile int ctx_caught;    /* temporary flag whether exception was caught */
279     volatile xbt_ex_t ctx_ex;   /* temporary exception storage */
280 } ex_ctx_t;
281
282 /* the static and dynamic initializers for a context structure */
283 #define XBT_CTX_INITIALIZER \
284     { NULL, 0, { /* content */ NULL, unknown_error, 0, \
285                  /* throw point*/ 0,NULL, NULL,0, NULL, 0, NULL,\
286                  /* backtrace */ 0,NULL,{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} } }
287 #define XBT_CTX_INITIALIZE(ctx) \
288     do { \
289         (ctx)->ctx_mctx          = NULL; \
290         (ctx)->ctx_caught        = 0;    \
291         (ctx)->ctx_ex.msg        = NULL; \
292         (ctx)->ctx_ex.category   = 0;    \
293         (ctx)->ctx_ex.value      = 0;    \
294         (ctx)->ctx_ex.remote     = 0;    \
295         (ctx)->ctx_ex.host       = NULL; \
296         (ctx)->ctx_ex.procname   = NULL; \
297         (ctx)->ctx_ex.pid        = 0;    \
298         (ctx)->ctx_ex.file       = NULL; \
299         (ctx)->ctx_ex.line       = 0;    \
300         (ctx)->ctx_ex.func       = NULL; \
301         (ctx)->ctx_ex.bt[0]      = NULL; \
302         (ctx)->ctx_ex.bt[1]      = NULL; \
303         (ctx)->ctx_ex.bt[2]      = NULL; \
304         (ctx)->ctx_ex.bt[3]      = NULL; \
305         (ctx)->ctx_ex.bt[4]      = NULL; \
306         (ctx)->ctx_ex.bt[5]      = NULL; \
307         (ctx)->ctx_ex.bt[6]      = NULL; \
308         (ctx)->ctx_ex.bt[7]      = NULL; \
309         (ctx)->ctx_ex.bt[8]      = NULL; \
310         (ctx)->ctx_ex.bt[9]      = NULL; \
311         (ctx)->ctx_ex.used       = 0; \
312         (ctx)->ctx_ex.bt_strings = NULL; \
313     } while (0)
314
315 /* the exception context */
316 typedef ex_ctx_t *(*ex_ctx_cb_t)(void);
317 extern ex_ctx_cb_t __xbt_ex_ctx;
318 extern ex_ctx_t *__xbt_ex_ctx_default(void);
319
320 /* the termination handler */
321 typedef void (*ex_term_cb_t)(xbt_ex_t *);
322 extern ex_term_cb_t __xbt_ex_terminate;
323 extern void __xbt_ex_terminate_default(xbt_ex_t *e);
324
325 /** @brief Introduce a block where exception may be dealed with 
326  *  @hideinitializer
327  */
328 #define TRY \
329     { \
330         ex_ctx_t *__xbt_ex_ctx_ptr = __xbt_ex_ctx(); \
331         int __ex_cleanup = 0; \
332         __ex_mctx_t *__ex_mctx_en; \
333         __ex_mctx_t __ex_mctx_me; \
334         __ex_mctx_en = __xbt_ex_ctx_ptr->ctx_mctx; \
335         __xbt_ex_ctx_ptr->ctx_mctx = &__ex_mctx_me; \
336         if (__ex_mctx_save(&__ex_mctx_me)) { \
337             if (1)
338
339 /** @brief optional(!) block for cleanup 
340  *  @hideinitializer
341  */
342 #define CLEANUP \
343             else { \
344             } \
345             __xbt_ex_ctx_ptr->ctx_caught = 0; \
346         } else { \
347             __ex_mctx_restored(&__ex_mctx_me); \
348             __xbt_ex_ctx_ptr->ctx_caught = 1; \
349         } \
350         __xbt_ex_ctx_ptr->ctx_mctx = __ex_mctx_en; \
351         __ex_cleanup = 1; \
352         if (1) { \
353             if (1)
354
355 #ifndef DOXYGEN_SKIP
356 #  ifdef __cplusplus
357 #    define XBT_EX_T_CPLUSPLUSCAST (xbt_ex_t&)
358 #  else
359 #    define XBT_EX_T_CPLUSPLUSCAST 
360 #  endif
361 #endif
362
363 /** @brief the block for catching (ie, deal with) an exception 
364  *  @hideinitializer
365  */
366 #define CATCH(e) \
367             else { \
368             } \
369             if (!(__ex_cleanup)) \
370                 __xbt_ex_ctx_ptr->ctx_caught = 0; \
371         } else { \
372             if (!(__ex_cleanup)) { \
373                 __ex_mctx_restored(&__ex_mctx_me); \
374                 __xbt_ex_ctx_ptr->ctx_caught = 1; \
375             } \
376         } \
377         __xbt_ex_ctx_ptr->ctx_mctx = __ex_mctx_en; \
378     } \
379     if (   !(__xbt_ex_ctx()->ctx_caught) \
380         || ((e) = XBT_EX_T_CPLUSPLUSCAST __xbt_ex_ctx()->ctx_ex, MAYDAY_CATCH(e) 0)) { \
381     } \
382     else
383
384 #define DO_THROW(e) \
385      /* deal with the exception */                                             \
386      if (__xbt_ex_ctx()->ctx_mctx == NULL)                                     \
387        __xbt_ex_terminate((xbt_ex_t *)&(e)); /* not catched */\
388      else                                                                      \
389        __ex_mctx_restore(__xbt_ex_ctx()->ctx_mctx); /* catched somewhere */    \
390      abort()/* nope, stupid GCC, we won't survive a THROW (this won't be reached) */
391
392 /** @brief Helper macro for THROWS0-6
393  *  @hideinitializer
394  *
395  *  @param c: category code (integer)
396  *  @param v: value (integer)
397  *  @param m: message text
398  *
399  * If called from within a TRY/CATCH construct, this exception 
400  * is copied into the CATCH relevant variable program control flow 
401  * is derouted to the CATCH (after the optional sg_cleanup). 
402  *
403  * If no TRY/CATCH construct embeeds this call, the program calls
404  * abort(3). 
405  *
406  * The THROW can be performed everywhere, including inside TRY, 
407  * CLEANUP and CATCH blocks.
408  */
409
410 #define _THROW(c,v,m) \
411   do { /* change this sequence into one block */                              \
412      /* build the exception */                                                \
413      __xbt_ex_ctx()->ctx_ex.msg      = (m);                                   \
414      __xbt_ex_ctx()->ctx_ex.category = (xbt_errcat_t)(c);                     \
415      __xbt_ex_ctx()->ctx_ex.value    = (v);                                   \
416      __xbt_ex_ctx()->ctx_ex.remote   = 0;                                     \
417      __xbt_ex_ctx()->ctx_ex.host     = (char*)NULL;                           \
418      __xbt_ex_ctx()->ctx_ex.procname = (char*)xbt_procname();                 \
419      __xbt_ex_ctx()->ctx_ex.pid      = gras_os_getpid();                      \
420      __xbt_ex_ctx()->ctx_ex.file     = (char*)__FILE__;                       \
421      __xbt_ex_ctx()->ctx_ex.line     = __LINE__;                              \
422      __xbt_ex_ctx()->ctx_ex.func     = (char*)_XBT_FUNCTION;                  \
423      __xbt_ex_ctx()->ctx_ex.used     = backtrace((void**)__xbt_ex_ctx()->ctx_ex.bt,XBT_BACKTRACE_SIZE);\
424      __xbt_ex_ctx()->ctx_ex.bt_strings = NULL; \
425      DO_THROW(__xbt_ex_ctx()->ctx_ex);\
426   } while (0)
427
428 /** @brief Builds and throws an exception with a string taking no arguments
429     @hideinitializer */
430 #define THROW0(c,v,m)                   _THROW(c,v,(m?bprintf(m):NULL))
431 /** @brief Builds and throws an exception with a string taking one argument
432     @hideinitializer */
433 #define THROW1(c,v,m,a1)                _THROW(c,v,bprintf(m,a1))
434 /** @brief Builds and throws an exception with a string taking two arguments
435     @hideinitializer */
436 #define THROW2(c,v,m,a1,a2)             _THROW(c,v,bprintf(m,a1,a2))
437 /** @brief Builds and throws an exception with a string taking three arguments
438     @hideinitializer */
439 #define THROW3(c,v,m,a1,a2,a3)          _THROW(c,v,bprintf(m,a1,a2,a3))
440 /** @brief Builds and throws an exception with a string taking four arguments
441     @hideinitializer */
442 #define THROW4(c,v,m,a1,a2,a3,a4)       _THROW(c,v,bprintf(m,a1,a2,a3,a4))
443 /** @brief Builds and throws an exception with a string taking five arguments
444     @hideinitializer */
445 #define THROW5(c,v,m,a1,a2,a3,a4,a5)    _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5))
446 /** @brief Builds and throws an exception with a string taking six arguments
447     @hideinitializer */
448 #define THROW6(c,v,m,a1,a2,a3,a4,a5,a6) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5,a6))
449 /** @brief Builds and throws an exception with a string taking seven arguments
450     @hideinitializer */
451 #define THROW7(c,v,m,a1,a2,a3,a4,a5,a6,a7) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5,a6,a7))
452
453 #define THROW_IMPOSSIBLE     THROW0(unknown_error,0,"The Impossible Did Happen (yet again)")
454 #define THROW_UNIMPLEMENTED  THROW1(unknown_error,0,"Function %s unimplemented",_XBT_FUNCTION)
455
456 #ifndef NDEBUG
457 #  define DIE_IMPOSSIBLE       xbt_assert0(0,"The Impossible Did Happen (yet again)")
458 #else
459 #  define DIE_IMPOSSIBLE       exit(1);
460 #endif
461
462 /** @brief re-throwing of an already caught exception (ie, pass it to the upper catch block) 
463  *  @hideinitializer
464  */
465 #define RETHROW \
466   do { \
467    if (__xbt_ex_ctx()->ctx_mctx == NULL) \
468      __xbt_ex_terminate((xbt_ex_t *)&(__xbt_ex_ctx()->ctx_ex)); \
469    else \
470      __ex_mctx_restore(__xbt_ex_ctx()->ctx_mctx); \
471    abort();\
472   } while(0)
473
474
475 #ifndef DOXYGEN_SKIP
476 #define _XBT_PRE_RETHROW \
477   do {                                                               \
478     char *_xbt_ex_internal_msg = __xbt_ex_ctx()->ctx_ex.msg;         \
479     __xbt_ex_ctx()->ctx_ex.msg = bprintf(
480 #define _XBT_POST_RETHROW \
481  _xbt_ex_internal_msg); \
482     free(_xbt_ex_internal_msg);                                      \
483     RETHROW;                                                         \
484   } while (0)
485 #endif
486
487 /** @brief like THROW0, but adding some details to the message of an existing exception
488  *  @hideinitializer
489  */
490 #define RETHROW0(msg)           _XBT_PRE_RETHROW msg,          _XBT_POST_RETHROW
491 /** @brief like THROW1, but adding some details to the message of an existing exception
492  *  @hideinitializer
493  */
494 #define RETHROW1(msg,a)         _XBT_PRE_RETHROW msg,a,        _XBT_POST_RETHROW
495 /** @brief like THROW2, but adding some details to the message of an existing exception
496  *  @hideinitializer
497  */
498 #define RETHROW2(msg,a,b)       _XBT_PRE_RETHROW msg,a,b,      _XBT_POST_RETHROW
499 /** @brief like THROW3, but adding some details to the message of an existing exception
500  *  @hideinitializer
501  */
502 #define RETHROW3(msg,a,b,c)     _XBT_PRE_RETHROW msg,a,b,c,    _XBT_POST_RETHROW
503 /** @brief like THROW4, but adding some details to the message of an existing exception
504  *  @hideinitializer
505  */
506 #define RETHROW4(msg,a,b,c,d)   _XBT_PRE_RETHROW msg,a,b,c,d,  _XBT_POST_RETHROW
507 /** @brief like THROW5, but adding some details to the message of an existing exception
508  *  @hideinitializer
509  */
510 #define RETHROW5(msg,a,b,c,d,e) _XBT_PRE_RETHROW msg,a,b,c,d,e, _XBT_POST_RETHROW
511
512 /** @brief Exception destructor */
513 void xbt_ex_free(xbt_ex_t e);
514
515 void xbt_ex_display(xbt_ex_t *e);
516 void xbt_backtrace_display(void);
517
518 /** @} */
519 #endif /* __XBT_EX_H__ */
520