- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# include/assert.h

Go to the documentation of this file.

    00001
    00041 #ifndef ASSERT_H_INCLUDED
    00042 #define ASSERT_H_INCLUDED
    00043
    00044 #include <debug.h>
    00045
    00046 #ifdef CONFIG_ASSERT
    00047 # define ASSERT_ENABLED 1
    00048 #else
    00049 # define ASSERT_ENABLED 0
    00050 #endif
    00051
    00052 #define abort()         do { } while (ASSERT_ENABLED)
    00053
    00061 #define assert(condition)                                               \
    00062         do {                                                            \
    00063                 if (ASSERT_ENABLED && unlikely(!(condition))) {         \
    00064                         dbg_printf_level(DEBUG_ASSERT,                  \
    00065                                 "%s:%d: Assertion \"%s\" failed!\n",    \
    00066                                 __FILE__, __LINE__, #condition);        \
    00067                         abort();                                        \
    00068                 }                                                       \
    00069         } while (0)
    00070
    00079 #define unhandled_case(value)                                           \
    00080         do {                                                            \
    00081                 if (ASSERT_ENABLED) {                                   \
    00082                         dbg_printf_level(DEBUG_ASSERT,                  \
    00083                                 "%s:%d: Unhandled case value %d\n",     \
    00084                                 __FILE__, __LINE__, (value));           \
    00085                         abort();                                        \
    00086                 }                                                       \
    00087         } while (0)
    00088
    00097 #define build_assert(condition)                                         \
    00098         do {                                                            \
    00099                 char build_assert_test[2 * !!(condition) - 1];          \
    00100                 (void)sizeof(build_assert_test);                        \
    00101         } while (0)
    00102
    00103 #endif /* ASSERT_H_INCLUDED */