From a6c119c3cd64e0857cbd20f6a2572bc5bd4dc7c0 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Mon, 21 Dec 2020 18:52:14 +0500 Subject: [PATCH] [runtime] Old impl of RuntimeAssert for backward compatibility --- kotlin-native/runtime/src/main/cpp/KAssert.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kotlin-native/runtime/src/main/cpp/KAssert.cpp b/kotlin-native/runtime/src/main/cpp/KAssert.cpp index 224f6cd7336..96df6e11abc 100644 --- a/kotlin-native/runtime/src/main/cpp/KAssert.cpp +++ b/kotlin-native/runtime/src/main/cpp/KAssert.cpp @@ -30,3 +30,16 @@ RUNTIME_NORETURN void RuntimeAssertFailed(const char* location, const char* form // TODO: Write the stacktrace. konan::abort(); } + +// TODO: this function is not used by runtime, but apparently there are +// third-party libraries that use it (despite the fact it is not a public API). +// Keeping the function here for now for backward compatibility, to be removed later. +RUNTIME_NORETURN void RuntimeAssertFailed(const char* location, const char* message) { + char buf[1024]; + if (location != nullptr) + konan::snprintf(buf, sizeof(buf), "%s: runtime assert: %s\n", location, message); + else + konan::snprintf(buf, sizeof(buf), "runtime assert: %s\n", message); + konan::consoleErrorUtf8(buf, konan::strnlen(buf, sizeof(buf))); + konan::abort(); +}