forked from urbit/vere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.h
38 lines (32 loc) · 1.28 KB
/
error.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
/// @file
#ifndef U3_ERROR_H
#define U3_ERROR_H
#include "manage.h"
/* Assert. Good to capture.
TODO: determine which u3_assert calls can rather call c3_dessert, i.e. in
public releases, which calls to u3_assert should abort and which should
no-op? If the latter, is the assert useful inter-development to validate
conditions we might accidentally break or not useful at all?
*/
#if defined(ASAN_ENABLED) && defined(__clang__)
# define u3_assert(x) \
do { \
if (!(x)) { \
u3m_bail(c3__oops); \
abort(); \
} \
} while(0)
#else
# define u3_assert(x) \
do { \
if (!(x)) { \
fflush(stderr); \
fprintf(stderr, "\rAssertion '%s' " \
"failed in %s:%d\r\n", \
#x, __FILE__, __LINE__); \
u3m_bail(c3__oops); \
abort(); \
} \
} while(0)
#endif /* if defined(ASAN_ENABLED) && defined(__clang__) */
#endif /* ifndef U3_ERROR_H */