summaryrefslogtreecommitdiff
path: root/src/common/assert.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/assert.h')
-rw-r--r--src/common/assert.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/common/assert.h b/src/common/assert.h
index cd9b819a9..70214efae 100644
--- a/src/common/assert.h
+++ b/src/common/assert.h
@@ -18,25 +18,29 @@
18// enough for our purposes. 18// enough for our purposes.
19template <typename Fn> 19template <typename Fn>
20#if defined(_MSC_VER) 20#if defined(_MSC_VER)
21 __declspec(noinline, noreturn) 21__declspec(noinline, noreturn)
22#elif defined(__GNUC__) 22#elif defined(__GNUC__)
23 __attribute__((noinline, noreturn, cold)) 23 __attribute__((noinline, noreturn, cold))
24#endif 24#endif
25static void assert_noinline_call(const Fn& fn) { 25 static void assert_noinline_call(const Fn& fn) {
26 fn(); 26 fn();
27 Crash(); 27 Crash();
28 exit(1); // Keeps GCC's mouth shut about this actually returning 28 exit(1); // Keeps GCC's mouth shut about this actually returning
29} 29}
30 30
31#define ASSERT(_a_) \ 31#define ASSERT(_a_) \
32 do if (!(_a_)) { assert_noinline_call([] { \ 32 do \
33 LOG_CRITICAL(Debug, "Assertion Failed!"); \ 33 if (!(_a_)) { \
34 }); } while (0) 34 assert_noinline_call([] { LOG_CRITICAL(Debug, "Assertion Failed!"); }); \
35 35 } \
36#define ASSERT_MSG(_a_, ...) \ 36 while (0)
37 do if (!(_a_)) { assert_noinline_call([&] { \ 37
38 LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); \ 38#define ASSERT_MSG(_a_, ...) \
39 }); } while (0) 39 do \
40 if (!(_a_)) { \
41 assert_noinline_call([&] { LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); }); \
42 } \
43 while (0)
40 44
41#define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!") 45#define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!")
42#define UNREACHABLE_MSG(...) ASSERT_MSG(false, __VA_ARGS__) 46#define UNREACHABLE_MSG(...) ASSERT_MSG(false, __VA_ARGS__)