diff --git a/Kconfig b/Kconfig index e7b515f..66cce9d 100644 --- a/Kconfig +++ b/Kconfig @@ -1,6 +1,6 @@ mainmenu "Zinnia Kernel Configuration" -source "device/Kconfig" +source "dev/Kconfig" config KERNEL_FLAVOR string "Kernel flavor name" diff --git a/kernel/include/kernel/assert.h b/kernel/include/kernel/assert.h new file mode 100644 index 0000000..2310fe1 --- /dev/null +++ b/kernel/include/kernel/assert.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +// Like the standard C assert, but also active in debug builds. +#define kassert(expr, msg, ...) \ + ({ \ + if (__unlikely(!(expr))) { \ + panic( \ + "In function \"%s\" (%s:%u):\n" \ + "Assertion \"%s\" failed!\n" msg, \ + __FUNCTION__, \ + __FILE__, \ + __LINE__, \ + #expr, \ + ##__VA_ARGS__ \ + ); \ + } \ + }) + +#ifndef NDEBUG +#define debug_assert(...) kassert(__VA_ARGS__) +#else +#define debug_assert(...) ((void)0) +#endif