mkernel 0.0.2
Micro-kernel framework, everything as a module
assert.h
Go to the documentation of this file.
1
19#ifndef __ASSERT_H__
20#define __ASSERT_H__
21
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
26#ifndef NDEBUG
27#include <stdlib.h> /* abort */
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
44void _trace(const char *p_File,
45 const unsigned int p_Line,
46 const char *p_CompilDate,
47 const char *p_CompilTime, const char *p_Function);
48
62void _trace_msg(const char *p_File,
63 const unsigned int p_Line,
64 const char *p_CompilDate,
65 const char *p_CompilTime,
66 const char *p_Function, const char *p_Message);
67
82void _trace_dynmsg(const char *p_File,
83 const unsigned int p_Line,
84 const char *p_CompilDate,
85 const char *p_CompilTime,
86 const char *p_Function, const char *p_Format, ...
87 );
88
89#ifdef __cplusplus
90}
91#endif
92
93# endif /* NDEBUG */
94
102#ifndef NDEBUG
103#define ASSERT(condition) \
104 if (!(condition)) { \
105 _trace_dynmsg(__FILE__,__LINE__, __DATE__, __TIME__, __func__,"Assertion failed (%s)" , #condition); \
106 abort(); \
107 }
108#else /* NDEBUG */
109#define ASSERT(condition)
110#endif /* NDEBUG */
111
117#ifndef NDEBUG
118#define DBG_TRACE \
119 _trace(__FILE__,__LINE__, __DATE__, __TIME__, __func__)
120#else /* NDEBUG */
121#define DBG_TRACE
122#endif /* NDEBUG */
123
129#ifndef NDEBUG
130#define DBG_MSG(msg) \
131 _trace_msg(__FILE__,__LINE__, __DATE__, __TIME__, __func__,msg)
132#else /* NDEBUG */
133#define DBG_MSG(msg)
134#endif /* NDEBUG */
135
141#ifndef NDEBUG
142#define DBG_ITRACE(inst) \
143 _trace_msg(__FILE__,__LINE__, __DATE__, __TIME__, __func__,#inst), \
144 inst
145#else /* NDEBUG */
146#define DBG_ITRACE(inst) inst
147#endif /* NDEBUG */
148
154#ifndef NDEBUG
155#define DBG_PRINTF(p_Format, ...) \
156 _trace_dynmsg(__FILE__,__LINE__, __DATE__, __TIME__, __func__, p_Format, __VA_ARGS__)
157#else /* NDEBUG */
158#define DBG_PRINTF(p_Format, ...)
159#endif /* NDEBUG */
160
161#endif /* _ASSERT_H */
162
void _trace_dynmsg(const char *p_File, const unsigned int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function, const char *p_Format,...)
Print a debug trace (checkpoint) with a formatted message.
Definition: assert.c:101
void _trace_msg(const char *p_File, const unsigned int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function, const char *p_Message)
Print a debug trace (checkpoint) with a static message.
Definition: assert.c:87
void _trace(const char *p_File, const unsigned int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function)
Print a debug trace (checkpoint)
Definition: assert.c:75