Use libkernaux asserts

This commit is contained in:
Alex Kotov 2021-12-15 04:53:05 +05:00
parent 49c3a635d3
commit 4a34caba5c
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 16 additions and 1 deletions

View File

@ -28,6 +28,8 @@ void main(
const unsigned long multiboot2_magic,
const struct KernAux_Multiboot2 *const multiboot2_info
) {
kernaux_assert_cb = kernaux_assert_fn;
if (multiboot2_magic != KERNAUX_MULTIBOOT2_MAGIC) {
panic("Multiboot 2 magic number is invalid.");
}

View File

@ -13,3 +13,13 @@ void halt()
{
panic("Kernel main function returned.");
}
void kernaux_assert_fn(
const char *const file,
const int line,
const char *const str
) {
kernaux_console_printf("[FAIL] assertion failed: %s:%u: %s\n",
file, line, str);
kernaux_arch_i386_hang();
}

View File

@ -1,8 +1,11 @@
#ifndef KERNEL_INCLUDED_PANIC
#define KERNEL_INCLUDED_PANIC 1
void panic(const char *s);
#include <kernaux/assert.h>
#define assert(cond, s) { if (!(cond)) { panic(s); } }
void panic(const char *s);
void kernaux_assert_fn(const char *file, int line, const char *str);
#endif