|
|
@ -22,42 +22,31 @@ void AssertFailSoftImpl(); |
|
|
#define YUZU_NO_INLINE __attribute__((noinline)) |
|
|
#define YUZU_NO_INLINE __attribute__((noinline)) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
// Note: We use an immediately-invoked lambda that takes the caller's __func__ as a parameter. |
|
|
|
|
|
// This ensures logs show the real function name instead of the lambda's operator(). |
|
|
|
|
|
#define ASSERT(_a_) \ |
|
|
#define ASSERT(_a_) \ |
|
|
([&](const char* __assert_func) YUZU_NO_INLINE { \ |
|
|
|
|
|
|
|
|
([&]() YUZU_NO_INLINE { \ |
|
|
if (!(_a_)) [[unlikely]] { \ |
|
|
if (!(_a_)) [[unlikely]] { \ |
|
|
::Common::Log::FmtLogMessage(::Common::Log::Class::Debug, \ |
|
|
|
|
|
::Common::Log::Level::Critical, \ |
|
|
|
|
|
__FILE__, __LINE__, __assert_func, \ |
|
|
|
|
|
"Assertion failed"); \ |
|
|
|
|
|
|
|
|
LOG_CRITICAL(Debug, "Assert"); \ |
|
|
AssertFailSoftImpl(); \ |
|
|
AssertFailSoftImpl(); \ |
|
|
} \ |
|
|
} \ |
|
|
}(__func__)) |
|
|
|
|
|
|
|
|
}()) |
|
|
|
|
|
|
|
|
#define ASSERT_MSG(_a_, fmt, ...) \ |
|
|
|
|
|
([&](const char* __assert_func) YUZU_NO_INLINE { \ |
|
|
|
|
|
|
|
|
#define ASSERT_MSG(_a_, ...) \ |
|
|
|
|
|
([&]() YUZU_NO_INLINE { \ |
|
|
if (!(_a_)) [[unlikely]] { \ |
|
|
if (!(_a_)) [[unlikely]] { \ |
|
|
::Common::Log::FmtLogMessage(::Common::Log::Class::Debug, \ |
|
|
|
|
|
::Common::Log::Level::Critical, \ |
|
|
|
|
|
__FILE__, __LINE__, __assert_func, \ |
|
|
|
|
|
"Assertion failed: " fmt, ##__VA_ARGS__); \ |
|
|
|
|
|
|
|
|
LOG_CRITICAL(Debug, "Assert\n" __VA_ARGS__); \ |
|
|
AssertFailSoftImpl(); \ |
|
|
AssertFailSoftImpl(); \ |
|
|
} \ |
|
|
} \ |
|
|
}(__func__)) |
|
|
|
|
|
|
|
|
}()) |
|
|
|
|
|
|
|
|
#define UNREACHABLE() \ |
|
|
#define UNREACHABLE() \ |
|
|
do { \ |
|
|
do { \ |
|
|
::Common::Log::FmtLogMessage(::Common::Log::Class::Debug, ::Common::Log::Level::Critical, \ |
|
|
|
|
|
__FILE__, __LINE__, __func__, "Unreachable"); \ |
|
|
|
|
|
|
|
|
LOG_CRITICAL(Debug, "Unreachable"); \ |
|
|
AssertFatalImpl(); \ |
|
|
AssertFatalImpl(); \ |
|
|
} while (0) |
|
|
} while (0) |
|
|
|
|
|
|
|
|
#define UNREACHABLE_MSG(fmt, ...) \ |
|
|
|
|
|
|
|
|
#define UNREACHABLE_MSG(...) \ |
|
|
do { \ |
|
|
do { \ |
|
|
::Common::Log::FmtLogMessage(::Common::Log::Class::Debug, ::Common::Log::Level::Critical, \ |
|
|
|
|
|
__FILE__, __LINE__, __func__, \ |
|
|
|
|
|
"Unreachable: " fmt, ##__VA_ARGS__); \ |
|
|
|
|
|
|
|
|
LOG_CRITICAL(Debug, "Unreachable\n" __VA_ARGS__); \ |
|
|
AssertFatalImpl(); \ |
|
|
AssertFatalImpl(); \ |
|
|
} while (0) |
|
|
} while (0) |
|
|
|
|
|
|
|
|
@ -73,10 +62,10 @@ void AssertFailSoftImpl(); |
|
|
} while (0) |
|
|
} while (0) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#define UNIMPLEMENTED() ASSERT_MSG(false, "Unimplemented code path") |
|
|
|
|
|
|
|
|
#define UNIMPLEMENTED() ASSERT_MSG(false, "Unimplemented code!") |
|
|
#define UNIMPLEMENTED_MSG(...) ASSERT_MSG(false, __VA_ARGS__) |
|
|
#define UNIMPLEMENTED_MSG(...) ASSERT_MSG(false, __VA_ARGS__) |
|
|
|
|
|
|
|
|
#define UNIMPLEMENTED_IF(cond) ASSERT_MSG(!(cond), "Unimplemented code path") |
|
|
|
|
|
|
|
|
#define UNIMPLEMENTED_IF(cond) ASSERT_MSG(!(cond), "Unimplemented code!") |
|
|
#define UNIMPLEMENTED_IF_MSG(cond, ...) ASSERT_MSG(!(cond), __VA_ARGS__) |
|
|
#define UNIMPLEMENTED_IF_MSG(cond, ...) ASSERT_MSG(!(cond), __VA_ARGS__) |
|
|
|
|
|
|
|
|
// If the assert is ignored, execute _b_ |
|
|
// If the assert is ignored, execute _b_ |
|
|
@ -87,3 +76,12 @@ void AssertFailSoftImpl(); |
|
|
_b_ \ |
|
|
_b_ \ |
|
|
} \ |
|
|
} \ |
|
|
} while (0) |
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
// If the assert is ignored, execute _b_ |
|
|
|
|
|
#define ASSERT_OR_EXECUTE_MSG(_a_, _b_, ...) \ |
|
|
|
|
|
do { \ |
|
|
|
|
|
ASSERT_MSG(_a_, __VA_ARGS__); \ |
|
|
|
|
|
if (!(_a_)) [[unlikely]] { \ |
|
|
|
|
|
_b_ \ |
|
|
|
|
|
} \ |
|
|
|
|
|
} while (0) |