corn/include/panic.h

14 lines
471 B
C

#pragma once
#define _PANIC_STR(x) _PANIC_STR2(x)
#define _PANIC_STR2(x) #x
#define panic(msg, ...) _panic_impl(_PANIC_STR(__LINE__), __FILE__, msg, ## __VA_ARGS__)
#define kassert(val, msg, ...) do { if (!(val)) { panic(msg, ## __VA_ARGS__); } } while(0)
__attribute__((noreturn,format(printf, 3, 4)))
void _panic_impl(char *line, char *file, char *msg, ...);
__attribute__((noreturn,format(printf, 3, 4)))
void _panic_interrupt(void *ip, void *bp, char *msg, ...);