4 /* GCC lets us add "attributes" to functions, function
5 parameters, etc. to indicate their properties.
6 See the GCC manual for details. */
7 #define UNUSED __attribute__ ((unused))
8 #define NO_RETURN __attribute__ ((noreturn))
9 #define NO_INLINE __attribute__ ((noinline))
10 #define PRINTF_FORMAT(FMT, FIRST) __attribute__ ((format (printf, FMT, FIRST)))
12 /* Halts the OS, printing the source file name, line number, and
13 function name, plus a user-specific message. */
14 #define PANIC(...) debug_panic (__FILE__, __LINE__, __func__, __VA_ARGS__)
16 void debug_panic (const char *file, int line, const char *function,
17 const char *message, ...) PRINTF_FORMAT (4, 5) NO_RETURN;
18 void debug_backtrace (void);
24 /* This is outside the header guard so that debug.h may be
25 included multiple times with different settings of NDEBUG. */
30 #define ASSERT(CONDITION) \
31 if (CONDITION) { } else { \
32 PANIC ("assertion `%s' failed.", #CONDITION); \
34 #define NOT_REACHED() PANIC ("executed an unreachable statement");
36 #define ASSERT(CONDITION) ((void) 0)
37 #define NOT_REACHED() for (;;)
38 #endif /* lib/debug.h */