-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpanic.h
23 lines (20 loc) · 792 Bytes
/
panic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once
#include <errno.h>
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define panic(format, ...) \
do { \
printf("panic at %s:%d\n", __FILE__, __LINE__); \
printf(format, __VA_ARGS__); \
printf("\n"); \
__builtin_trap(); \
} while (0)
#define panic_errno() \
do { \
printf("panic at %s:%d\n", __FILE__, __LINE__); \
perror(strerror(errno)); \
printf("\n"); \
__builtin_trap(); \
} while (0)