1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2025-07-31 22:00:58 -04:00

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 unsigned long multiboot2_magic,
const struct KernAux_Multiboot2 *const multiboot2_info const struct KernAux_Multiboot2 *const multiboot2_info
) { ) {
kernaux_assert_cb = kernaux_assert_fn;
if (multiboot2_magic != KERNAUX_MULTIBOOT2_MAGIC) { if (multiboot2_magic != KERNAUX_MULTIBOOT2_MAGIC) {
panic("Multiboot 2 magic number is invalid."); panic("Multiboot 2 magic number is invalid.");
} }

View file

@ -13,3 +13,13 @@ void halt()
{ {
panic("Kernel main function returned."); 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 #ifndef KERNEL_INCLUDED_PANIC
#define KERNEL_INCLUDED_PANIC 1 #define KERNEL_INCLUDED_PANIC 1
void panic(const char *s); #include <kernaux/assert.h>
#define assert(cond, s) { if (!(cond)) { panic(s); } } #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 #endif