Logo AND Algorithmique Numérique Distribuée

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