Luna/kernel/include/assert.h

16 lines
890 B
C
Raw Normal View History

2022-09-05 14:13:51 +00:00
#pragma once
#include "log/Log.h"
2022-09-10 16:42:40 +00:00
#include "panic/hang.h"
2022-09-05 14:13:51 +00:00
2022-09-10 16:42:40 +00:00
#define __call_assert_fail(...) \
kerrorln(__VA_ARGS__); \
hang();
2022-09-05 14:13:51 +00:00
2022-09-10 16:42:40 +00:00
#define ASSERT(expr) \
do { \
if (!(expr)) { __call_assert_fail("Assertion failed at %s, line %d: %s", __FILE__, __LINE__, #expr) } \
} while (0)
2022-09-05 14:13:51 +00:00
2022-09-14 16:54:40 +00:00
#define TODO(message) __call_assert_fail("TODO at %s, line %d: %s", __FILE__, __LINE__, message)
#define PANIC(message) __call_assert_fail("PANIC at %s, line %d: %s", __FILE__, __LINE__, message)