aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2025-12-01 05:06:57 +0100
committercrueter <crueter@eden-emu.dev>2025-12-01 05:06:57 +0100
commit97054357d271dddabbe6bd1f123507ad36563018 (patch)
tree68641564c9f1438e77a76de4229cb8e3d19ef36d /src
parent941caf31cefce5212a562425f71cda20fbfa6c9b (diff)
[common] asserts now display expression of assert (#2997)
Easiest change in the world, will help to pinpoint asserts quicker, it's just a relatively small thing so doesn't even need testing. Signed-off-by: lizzie lizzie@eden-emu.dev Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2997 Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src')
-rw-r--r--src/common/assert.h40
1 files changed, 10 insertions, 30 deletions
diff --git a/src/common/assert.h b/src/common/assert.h
index 93965c2ec9..8edb020695 100644
--- a/src/common/assert.h
+++ b/src/common/assert.h
@@ -22,33 +22,21 @@ void AssertFailSoftImpl();
#define YUZU_NO_INLINE __attribute__((noinline))
#endif
-#define ASSERT(_a_) \
- ([&]() YUZU_NO_INLINE { \
- if (!(_a_)) [[unlikely]] { \
- LOG_CRITICAL(Debug, "Assert"); \
- AssertFailSoftImpl(); \
- } \
- }())
-
#define ASSERT_MSG(_a_, ...) \
([&]() YUZU_NO_INLINE { \
if (!(_a_)) [[unlikely]] { \
- LOG_CRITICAL(Debug, "Assert\n" __VA_ARGS__); \
- AssertFailSoftImpl(); \
+ LOG_CRITICAL(Debug, __FILE__ ": assert\n" __VA_ARGS__); \
+ AssertFailSoftImpl(); \
} \
}())
-
-#define UNREACHABLE() \
- do { \
- LOG_CRITICAL(Debug, "Unreachable"); \
- AssertFatalImpl(); \
- } while (0)
+#define ASSERT(_a_) ASSERT_MSG(_a_, "{}", #_a_)
#define UNREACHABLE_MSG(...) \
do { \
- LOG_CRITICAL(Debug, "Unreachable\n" __VA_ARGS__); \
- AssertFatalImpl(); \
+ LOG_CRITICAL(Debug, __FILE__ ": unreachable\n" __VA_ARGS__); \
+ AssertFatalImpl(); \
} while (0)
+#define UNREACHABLE() UNREACHABLE_MSG("")
#ifdef _DEBUG
#define DEBUG_ASSERT(_a_) ASSERT(_a_)
@@ -69,19 +57,11 @@ void AssertFailSoftImpl();
#define UNIMPLEMENTED_IF_MSG(cond, ...) ASSERT_MSG(!(cond), __VA_ARGS__)
// If the assert is ignored, execute _b_
-#define ASSERT_OR_EXECUTE(_a_, _b_) \
- do { \
- ASSERT(_a_); \
- if (!(_a_)) [[unlikely]] { \
- _b_ \
- } \
- } 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_ \
- } \
+ if (!(_a_)) { _b_ } \
} while (0)
+
+// If the assert is ignored, execute _b_
+#define ASSERT_OR_EXECUTE(_a_, _b_) ASSERT_OR_EXECUTE_MSG(_a_, _b_, "{}", #_a_)