mirror of
https://github.com/tailix/kernel.git
synced 2024-11-27 11:24:34 -05:00
Use libkernaux asserts
This commit is contained in:
parent
49c3a635d3
commit
4a34caba5c
3 changed files with 16 additions and 1 deletions
|
@ -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.");
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue