Browse Source

revert asser.h

pull/2950/head
unknown 4 months ago
parent
commit
9e8ff92eb8
  1. 50
      src/common/assert.h

50
src/common/assert.h

@ -1,8 +1,8 @@
// SPDX-FileCopyrightText: Copyright2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText:2013 Dolphin Emulator Project
// SPDX-FileCopyrightText:2014 Citra Emulator Project
// SPDX-FileCopyrightText: 2013 Dolphin Emulator Project
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@ -22,42 +22,31 @@ void AssertFailSoftImpl();
#define YUZU_NO_INLINE __attribute__((noinline))
#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_) \
([&](const char* __assert_func) YUZU_NO_INLINE { \
([&]() YUZU_NO_INLINE { \
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(); \
} \
}(__func__))
}())
#define ASSERT_MSG(_a_, fmt, ...) \
([&](const char* __assert_func) YUZU_NO_INLINE { \
#define ASSERT_MSG(_a_, ...) \
([&]() YUZU_NO_INLINE { \
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(); \
} \
}(__func__))
}())
#define UNREACHABLE() \
do { \
::Common::Log::FmtLogMessage(::Common::Log::Class::Debug, ::Common::Log::Level::Critical, \
__FILE__, __LINE__, __func__, "Unreachable"); \
LOG_CRITICAL(Debug, "Unreachable"); \
AssertFatalImpl(); \
} while (0)
#define UNREACHABLE_MSG(fmt, ...) \
#define UNREACHABLE_MSG(...) \
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(); \
} while (0)
@ -73,10 +62,10 @@ void AssertFailSoftImpl();
} while (0)
#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_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__)
// If the assert is ignored, execute _b_
@ -87,3 +76,12 @@ void AssertFailSoftImpl();
_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_ \
} \
} while (0)
Loading…
Cancel
Save