From bb3f7c8ab90e91a81db69564c228e5bde2c21f60 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 20 Feb 2020 10:14:27 -0800 Subject: [PATCH] kern: fix building without debugging turned on --- .../include/mesosphere/kern_debug_log.hpp | 4 ++-- .../include/mesosphere/kern_panic.hpp | 17 ++++++++++++----- .../board/nintendo/nx/kern_k_system_control.cpp | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/libraries/libmesosphere/include/mesosphere/kern_debug_log.hpp b/libraries/libmesosphere/include/mesosphere/kern_debug_log.hpp index 85a707904..94aaabf66 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_debug_log.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_debug_log.hpp @@ -49,6 +49,6 @@ namespace ams::kern { #define MESOSPHERE_LOG(fmt, ...) MESOSPHERE_RELEASE_LOG((fmt), ## __VA_ARGS__) #define MESOSPHERE_VLOG(fmt, vl) MESOSPHERE_RELEASE_VLOG((fmt), (vl)) #else -#define MESOSPHERE_LOG(fmt, ...) -#define MESOSPHERE_VLOG(fmt, vl) +#define MESOSPHERE_LOG(fmt, ...) do { MESOSPHERE_UNUSED(fmt); MESOSPHERE_UNUSED(__VA_ARGS__); } while (0) +#define MESOSPHERE_VLOG(fmt, vl) do { MESOSPHERE_UNUSED(fmt); MESOSPHERE_UNUSED(vl); } while (0) #endif diff --git a/libraries/libmesosphere/include/mesosphere/kern_panic.hpp b/libraries/libmesosphere/include/mesosphere/kern_panic.hpp index 4e1717c11..fb6252124 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_panic.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_panic.hpp @@ -19,15 +19,22 @@ namespace ams::kern { - NORETURN void Panic(const char *file, int line, const char *format, ...) __attribute__((format(printf, 3, 4))); - NORETURN void Panic(); + template + ALWAYS_INLINE void UnusedImpl(ArgTypes... args) { + (static_cast(args), ...); + } + + NORETURN NOINLINE void Panic(const char *file, int line, const char *format, ...) __attribute__((format(printf, 3, 4))); + NORETURN NOINLINE void Panic(); } +#define MESOSPHERE_UNUSED(...) ::ams::kern::UnusedImpl(__VA_ARGS__) + #ifdef MESOSPHERE_ENABLE_DEBUG_PRINT -#define MESOSPHERE_PANIC(...) ::ams::kern::Panic(__FILE__, __LINE__, __VA_ARGS__) +#define MESOSPHERE_PANIC(...) do { ::ams::kern::Panic(__FILE__, __LINE__, __VA_ARGS__); } while(0) #else -#define MESOSPHERE_PANIC(...) ::ams::kern::Panic() +#define MESOSPHERE_PANIC(...) do { MESOSPHERE_UNUSED(__VA_ARGS__); ::ams::kern::Panic(); } while(0) #endif #ifdef MESOSPHERE_ENABLE_ASSERTIONS @@ -58,7 +65,7 @@ namespace ams::kern { #define MESOSPHERE_AUDIT(expr) do { static_cast(expr); } while (0) #endif -#define MESOSPHERE_TODO(arg) ({ constexpr const char *__mesosphere_todo = arg; MESOSPHERE_PANIC("TODO (%s): %s\n", __PRETTY_FUNCTION__, __mesosphere_todo); }) +#define MESOSPHERE_TODO(arg) ({ constexpr const char *__mesosphere_todo = arg; static_cast(__mesosphere_todo); MESOSPHERE_PANIC("TODO (%s): %s\n", __PRETTY_FUNCTION__, __mesosphere_todo); }) #define MESOSPHERE_TODO_IMPLEMENT() MESOSPHERE_TODO("Implement") #define MESOSPHERE_ABORT() MESOSPHERE_PANIC("Abort()\n"); diff --git a/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp b/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp index 46788d815..4a2aff49d 100644 --- a/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp +++ b/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp @@ -322,7 +322,7 @@ namespace ams::kern::board::nintendo::nx { void KSystemControl::StopSystem() { if (g_call_smc_on_panic) { /* Display a panic screen via secure monitor. */ - /* TODO: Enable in release: smc::Panic(0xF00); */ + smc::Panic(0xF00); } while (true) { /* ... */ } }