2024-02-27 22:10:34 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
2024-09-09 10:23:16 +00:00
|
|
|
#include "common/arch.h"
|
2024-02-27 22:10:34 +00:00
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/logging/backend.h"
|
|
|
|
|
2024-09-09 10:23:16 +00:00
|
|
|
#if defined(ARCH_X86_64)
|
2024-02-27 22:10:34 +00:00
|
|
|
#define Crash() __asm__ __volatile__("int $3")
|
2024-09-09 10:23:16 +00:00
|
|
|
#elif defined(ARCH_ARM64)
|
|
|
|
#define Crash() __asm__ __volatile__("brk 0")
|
|
|
|
#else
|
|
|
|
#error "Missing Crash() implementation for target CPU architecture."
|
|
|
|
#endif
|
2024-02-27 22:10:34 +00:00
|
|
|
|
|
|
|
void assert_fail_impl() {
|
|
|
|
Common::Log::Stop();
|
2024-05-16 12:55:50 +00:00
|
|
|
std::fflush(stdout);
|
2024-02-27 22:10:34 +00:00
|
|
|
Crash();
|
|
|
|
}
|
|
|
|
|
|
|
|
[[noreturn]] void unreachable_impl() {
|
|
|
|
Common::Log::Stop();
|
2024-05-21 22:35:12 +00:00
|
|
|
std::fflush(stdout);
|
2024-02-27 22:10:34 +00:00
|
|
|
Crash();
|
|
|
|
throw std::runtime_error("Unreachable code");
|
|
|
|
}
|
2024-09-08 19:50:32 +00:00
|
|
|
|
|
|
|
void assert_fail_debug_msg(const char* msg) {
|
|
|
|
LOG_CRITICAL(Debug, "Assertion Failed!\n{}", msg);
|
|
|
|
assert_fail_impl();
|
|
|
|
}
|