Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ac757041b2c1b2012a85781f926101c213124574
[simgrid.git] / include / xbt / asserts.h
1 /* $Id$ */
2 /*  xbt/asserts.h -- assertion mecanism                                     */
3
4 /* Copyright (c) 2004,2005 Martin Quinson. All rights reserved.             */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef _XBT_ASSERTS_H
10 #define _XBT_ASSERTS_H
11
12 #include "xbt/misc.h"
13   
14 SG_BEGIN_DECL()
15
16 /**
17  * \addtogroup XBT_error
18  * @{
19  */
20 #ifdef NDEBUG
21 #define xbt_assert(cond)
22 #define xbt_assert0(cond,msg)
23 #define xbt_assert1(cond,msg,a)
24 #define xbt_assert2(cond,msg,a,b)
25 #define xbt_assert3(cond,msg,a,b,c)
26 #define xbt_assert4(cond,msg,a,b,c,d)
27 #define xbt_assert5(cond,msg,a,b,c,d,e)
28 #define xbt_assert6(cond,msg,a,b,c,d,e,f)
29 #else
30      /** @brief The condition which failed will be displayed.
31          @hideinitializer  */
32 #define xbt_assert(cond)                  if (!(cond)) { CRITICAL1("Assertion %s failed", #cond); xbt_abort(); }
33      /** @hideinitializer  */
34 #define xbt_assert0(cond,msg)             if (!(cond)) { CRITICAL0(msg); xbt_abort(); }
35      /** @hideinitializer  */
36 #define xbt_assert1(cond,msg,a)           if (!(cond)) { CRITICAL1(msg,a); xbt_abort(); }
37      /** @hideinitializer  */
38 #define xbt_assert2(cond,msg,a,b)         if (!(cond)) { CRITICAL2(msg,a,b); xbt_abort(); }
39      /** @hideinitializer  */
40 #define xbt_assert3(cond,msg,a,b,c)       if (!(cond)) { CRITICAL3(msg,a,b,c); xbt_abort(); }
41      /** @hideinitializer  */
42 #define xbt_assert4(cond,msg,a,b,c,d)     if (!(cond)) { CRITICAL4(msg,a,b,c,d); xbt_abort(); }
43      /** @hideinitializer  */
44 #define xbt_assert5(cond,msg,a,b,c,d,e)   if (!(cond)) { CRITICAL5(msg,a,b,c,d,e); xbt_abort(); }
45      /** @hideinitializer  */
46 #define xbt_assert6(cond,msg,a,b,c,d,e,f) if (!(cond)) { CRITICAL6(msg,a,b,c,d,e,f); xbt_abort(); }
47 #endif
48      
49 void xbt_abort(void) _XBT_GNUC_NORETURN;
50 void xbt_die(const char *msg) _XBT_GNUC_NORETURN;
51
52 /** @} */     
53   
54 SG_END_DECL()
55
56 #endif /* _XBT_ASSERTS_H */