diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73574905..bd0ed6bc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -291,9 +291,13 @@ target_link_libraries(dynarmic mp $<$:${llvm_libs}> ) + if (ARCHITECTURE_x86_64) target_link_libraries(dynarmic PRIVATE xbyak) endif() +if(ANDROID) + target_link_libraries(dynarmic PRIVATE log) +endif() if (DYNARMIC_ENABLE_CPU_FEATURE_DETECTION) target_compile_definitions(dynarmic PRIVATE DYNARMIC_ENABLE_CPU_FEATURE_DETECTION=1) endif() diff --git a/src/common/assert.h b/src/common/assert.h index edb0da3e..ce99d5da 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -8,6 +8,10 @@ #include +#ifdef ANDROID +#include +#endif + // For asserts we'd like to keep all the junk executed when an assert happens away from the // important code in the function. One way of doing this is to put all the relevant code inside a // lambda and force the compiler to not inline it. Unfortunately, MSVC seems to have no syntax to @@ -26,18 +30,32 @@ static void assert_noinline_call(const Fn& fn) { throw ""; } +#ifdef ANDROID +#define ASSERT(_a_) \ + do if (!(_a_)) { assert_noinline_call([] { \ + __android_log_print(ANDROID_LOG_FATAL, "Dynarmic", "%s", fmt::format("Assertion Failed!: {}\n", #_a_).c_str()); \ + }); } while (false) +#else #define ASSERT(_a_) \ do if (!(_a_)) { assert_noinline_call([] { \ fmt::print(stderr, "Assertion Failed!: {}\n", #_a_); \ }); } while (false) +#endif +#ifdef ANDROID +#define ASSERT_MSG(_a_, ...) \ + do if (!(_a_)) { assert_noinline_call([&] { \ + __android_log_print(ANDROID_LOG_FATAL, "Dynarmic", "%s", fmt::format("Assertion Failed!: {}\n", #_a_).c_str()); \ + __android_log_print(ANDROID_LOG_FATAL, "Dynarmic", "%s", fmt::format(__VA_ARGS__).c_str()); \ + }); } while (false) +#else #define ASSERT_MSG(_a_, ...) \ do if (!(_a_)) { assert_noinline_call([&] { \ fmt::print(stderr, "Assertion Failed!: {}\n", #_a_); \ fmt::print(stderr, "Message: " __VA_ARGS__); \ fmt::print(stderr, "\n"); \ }); } while (false) - +#endif #define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!") #define UNREACHABLE_MSG(...) ASSERT_MSG(false, __VA_ARGS__)