-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathprelude.h
55 lines (47 loc) · 1.17 KB
/
prelude.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <inttypes.h>
#ifndef OC_NO_BACKTRACE
#include <stdlib.h>
#include <execinfo.h>
#endif
typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef float f32;
typedef double f64;
const char* __asan_default_options() { return "detect_leaks=0"; }
void dump_backtrace() {
#ifndef OC_NO_BACKTRACE
void *array[40];
size_t size = backtrace(array, 40);
char **strings = backtrace_symbols(array, size);
printf("\nBacktrace:\n");
for (size_t i = size-1; i > 0; i--) {
printf("%s\n", strings[i]);
}
free(strings);
#endif
}
#ifdef __APPLE__
#define oc_trap __builtin_debugtrap
#else
#define oc_trap __builtin_trap
#endif
void ae_assert_fail(char *dbg_msg, char *msg) {
dump_backtrace();
printf("--------------------------------------------------------------------------------\n");
printf("%s\n", dbg_msg);
if (msg) {
printf(" Message: %s\n", msg);
}
printf("--------------------------------------------------------------------------------\n");
fflush(stdout);
oc_trap();
}