Xenomai API  2.6.5
assert.h
1 /*
2  * Copyright (C) 2006 Philippe Gerum <[email protected]>.
3  *
4  * Xenomai is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published
6  * by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  *
9  * Xenomai is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Xenomai; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  * 02111-1307, USA.
18  */
19 
20 #ifndef _XENO_NUCLEUS_ASSERT_H
21 #define _XENO_NUCLEUS_ASSERT_H
22 
23 #include <nucleus/types.h>
24 
25 #define XENO_DEBUG(subsystem) \
26  (CONFIG_XENO_OPT_DEBUG_##subsystem > 0)
27 
28 #define XENO_ASSERT(subsystem,cond,action) do { \
29  if (unlikely(XENO_DEBUG(subsystem) && !(cond))) { \
30  xnarch_trace_panic_freeze(); \
31  xnlogerr("assertion failed at %s:%d (%s)\n", \
32  __FILE__, __LINE__, (#cond)); \
33  xnarch_trace_panic_dump(); \
34  action; \
35  } \
36  } while(0)
37 
38 #define XENO_BUGON(subsystem,cond) \
39  do { \
40  if (unlikely(XENO_DEBUG(subsystem) && (cond))) \
41  xnpod_fatal("bug at %s:%d (%s)", \
42  __FILE__, __LINE__, (#cond)); \
43  } while(0)
44 
45 #ifndef CONFIG_XENO_OPT_DEBUG_QUEUES
46 #define CONFIG_XENO_OPT_DEBUG_QUEUES 0
47 #endif /* CONFIG_XENO_OPT_DEBUG_QUEUES */
48 #ifndef CONFIG_XENO_OPT_DEBUG_NUCLEUS
49 #define CONFIG_XENO_OPT_DEBUG_NUCLEUS 0
50 #endif /* CONFIG_XENO_OPT_DEBUG_NUCLEUS */
51 
52 #endif /* !_XENO_NUCLEUS_ASSERT_H */