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#include <stdlib.h> /* abort */
27
28#ifndef NDEBUG
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
45void _trace(const char *p_File,
46 const unsigned int p_Line,
47 const char *p_CompilDate,
48 const char *p_CompilTime, const char *p_Function);
49
63void _trace_msg(const char *p_File,
64 const unsigned int p_Line,
65 const char *p_CompilDate,
66 const char *p_CompilTime,
67 const char *p_Function, const char *p_Message);
68
83void _trace_dynmsg(const char *p_File,
84 const unsigned int p_Line,
85 const char *p_CompilDate,
86 const char *p_CompilTime,
87 const char *p_Function, const char *p_Format, ...
88 );
89
90#ifdef __cplusplus
91}
92#endif
93
94# endif /* NDEBUG */
95
103#ifndef NDEBUG
104#define ASSERT(condition) \
105 if (!(condition)) { \
106 _trace_dynmsg(__FILE__,__LINE__, __DATE__, __TIME__, __func__,"Assertion failed (%s)" , #condition); \
107 abort(); \
108 }
109#else /* NDEBUG */
110#define ASSERT(condition)
111#endif /* NDEBUG */
112
118#ifndef NDEBUG
119#define DBG_TRACE \
120 _trace(__FILE__,__LINE__, __DATE__, __TIME__, __func__)
121#else /* NDEBUG */
122#define DBG_TRACE
123#endif /* NDEBUG */
124
130#ifndef NDEBUG
131#define DBG_MSG(msg) \
132 _trace_msg(__FILE__,__LINE__, __DATE__, __TIME__, __func__,msg)
133#else /* NDEBUG */
134#define DBG_MSG(msg)
135#endif /* NDEBUG */
136
142#ifndef NDEBUG
143#define DBG_ITRACE(inst) \
144 _trace_msg(__FILE__,__LINE__, __DATE__, __TIME__, __func__,#inst), \
145 inst
146#else /* NDEBUG */
147#define DBG_ITRACE(inst) inst
148#endif /* NDEBUG */
149
155#ifndef NDEBUG
156#define DBG_PRINTF(p_Format, ...) \
157 _trace_dynmsg(__FILE__,__LINE__, __DATE__, __TIME__, __func__, p_Format, __VA_ARGS__)
158#else /* NDEBUG */
159#define DBG_PRINTF(p_Format, ...)
160#endif /* NDEBUG */
161
162#endif /* _ASSERT_H */
163
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