27 lines
639 B
C
27 lines
639 B
C
#pragma once
|
|
|
|
#include <common/compiler.h>
|
|
#include <kernel/panic.h>
|
|
|
|
// Like the standard C assert, but also active in debug builds.
|
|
#define assert(expr, msg, ...) \
|
|
do { \
|
|
if (__unlikely(!(expr))) { \
|
|
panic( \
|
|
"In function \"%s\" (%s:%u):\n" \
|
|
"Assertion \"%s\" failed!\n" msg, \
|
|
__FUNCTION__, \
|
|
__FILE__, \
|
|
__LINE__, \
|
|
#expr, \
|
|
##__VA_ARGS__ \
|
|
); \
|
|
} \
|
|
} while (0)
|
|
|
|
#ifndef NDEBUG
|
|
#define debug_assert(...) assert(__VA_ARGS__)
|
|
#else
|
|
#define debug_assert(...) ((void)0)
|
|
#endif
|