00001
00038 #ifndef ASSERT_H_INCLUDED
00039 #define ASSERT_H_INCLUDED
00040
00041 #include <debug.h>
00042
00053 #ifdef CONFIG_ASSERT
00054 # define ASSERT_ENABLED 1
00055 #else
00056 # define ASSERT_ENABLED 0
00057 #endif
00058
00068 #define abort() do { } while (ASSERT_ENABLED)
00069
00077 #ifdef CONFIG_ASSERT
00078 # define assert(condition) \
00079 do { \
00080 if (ASSERT_ENABLED && unlikely(!(condition))) { \
00081 cpu_irq_disable(); \
00082 dbg_printf_level(DEBUG_ASSERT, \
00083 "%s:%d: Assertion \"%s\" failed!\n", \
00084 __FILE__, __LINE__, #condition); \
00085 abort(); \
00086 } \
00087 } while (0)
00088 #else
00089 # define assert(condition)
00090 #endif
00091
00100 #define unhandled_case(value) \
00101 do { \
00102 if (ASSERT_ENABLED) { \
00103 dbg_printf_level(DEBUG_ASSERT, \
00104 "%s:%d: Unhandled case value %d\n", \
00105 __FILE__, __LINE__, (value)); \
00106 abort(); \
00107 } \
00108 } while (0)
00109
00110 ERROR_FUNC(build_assert_failed, "Build assertion failed");
00111
00118 #define build_assert(condition) \
00119 do { \
00120 if (!(condition)) \
00121 build_assert_failed(); \
00122 } while (0)
00123
00125
00126 #endif