diff options
| author | 2015-05-12 02:52:31 -0300 | |
|---|---|---|
| committer | 2015-05-12 02:52:31 -0300 | |
| commit | c8eae338a8de614e175498408fcde8aa97736a54 (patch) | |
| tree | f6aaea49eb4c5618a08265ea637817d94cca4507 | |
| parent | Common: Remove async logging (diff) | |
| download | yuzu-c8eae338a8de614e175498408fcde8aa97736a54.tar.gz yuzu-c8eae338a8de614e175498408fcde8aa97736a54.tar.xz yuzu-c8eae338a8de614e175498408fcde8aa97736a54.zip | |
Common: Use the log system to print assert messages
| -rw-r--r-- | src/common/assert.h | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/common/assert.h b/src/common/assert.h index 4f26c63e9..7b7d8bf28 100644 --- a/src/common/assert.h +++ b/src/common/assert.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <cstdlib> | 8 | #include <cstdlib> |
| 9 | 9 | ||
| 10 | #include "common/common_funcs.h" | 10 | #include "common/common_funcs.h" |
| 11 | #include "common/logging/log.h" | ||
| 11 | 12 | ||
| 12 | // For asserts we'd like to keep all the junk executed when an assert happens away from the | 13 | // For asserts we'd like to keep all the junk executed when an assert happens away from the |
| 13 | // important code in the function. One way of doing this is to put all the relevant code inside a | 14 | // important code in the function. One way of doing this is to put all the relevant code inside a |
| @@ -28,19 +29,14 @@ static void assert_noinline_call(const Fn& fn) { | |||
| 28 | exit(1); // Keeps GCC's mouth shut about this actually returning | 29 | exit(1); // Keeps GCC's mouth shut about this actually returning |
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | // TODO (yuriks) allow synchronous logging so we don't need printf | ||
| 32 | #define ASSERT(_a_) \ | 32 | #define ASSERT(_a_) \ |
| 33 | do if (!(_a_)) { assert_noinline_call([] { \ | 33 | do if (!(_a_)) { assert_noinline_call([] { \ |
| 34 | fprintf(stderr, "Assertion Failed!\n\n Line: %d\n File: %s\n Time: %s\n", \ | 34 | LOG_CRITICAL(Debug, "Assertion Failed!"); \ |
| 35 | __LINE__, __FILE__, __TIME__); \ | ||
| 36 | }); } while (0) | 35 | }); } while (0) |
| 37 | 36 | ||
| 38 | #define ASSERT_MSG(_a_, ...) \ | 37 | #define ASSERT_MSG(_a_, ...) \ |
| 39 | do if (!(_a_)) { assert_noinline_call([&] { \ | 38 | do if (!(_a_)) { assert_noinline_call([&] { \ |
| 40 | fprintf(stderr, "Assertion Failed!\n\n Line: %d\n File: %s\n Time: %s\n", \ | 39 | LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); \ |
| 41 | __LINE__, __FILE__, __TIME__); \ | ||
| 42 | fprintf(stderr, __VA_ARGS__); \ | ||
| 43 | fprintf(stderr, "\n"); \ | ||
| 44 | }); } while (0) | 40 | }); } while (0) |
| 45 | 41 | ||
| 46 | #define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!") | 42 | #define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!") |