38 lines
961 B
C
38 lines
961 B
C
#pragma once
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
|
|
#ifndef NDEBUG
|
|
#define debug(...) printf(__VA_ARGS__)
|
|
#define debug_info(...) \
|
|
do{debug("[INFO] "); debug(__VA_ARGS__);}while(0)
|
|
#define debug_ok(...) \
|
|
do{debug("[OK] "); debug(__VA_ARGS__);}while(0)
|
|
#define debug_warning(...) \
|
|
do{debug("[WARN] "); debug(__VA_ARGS__);}while(0)
|
|
#define debug_error(...) \
|
|
do{debug("[ERROR] "); debug(__VA_ARGS__);}while(0)
|
|
#else
|
|
#define debug(...)
|
|
#define debug_info(...)
|
|
#define debug_ok(...)
|
|
#define debug_warning(...)
|
|
#define debug_error(...)
|
|
#endif
|
|
|
|
#define S(x) #x
|
|
#define S_(x) S(x)
|
|
#define S__LINE__ S_(__LINE__)
|
|
|
|
#define PANIC(...) \
|
|
do { \
|
|
debug("\n\nKERNEL PANIC!\n%s:%d\n", __FILE__, __LINE__); \
|
|
debug(__VA_ARGS__); \
|
|
debug("\n"); \
|
|
volatile int _override = 0; \
|
|
while(1) { \
|
|
__asm__("panic_breakpoint_" S__LINE__ ":"); \
|
|
if(_override) break; \
|
|
} \
|
|
}while(0)
|