stdlib: Move exit function to porting layer

This commit is contained in:
Ilya Matveev
2017-09-04 18:31:46 +03:00
committed by ilmat192
parent ea667ebc5c
commit c32b84efd1
6 changed files with 31 additions and 2 deletions
@@ -2,4 +2,6 @@ import kotlin.system.*
fun main(args: Array<String>) {
exitProcess(42)
@Suppress("UNREACHABLE_CODE")
throw RuntimeException("Exit function call returned normally")
}
@@ -214,6 +214,11 @@ fun handleExceptionContinuation(x: (Throwable) -> Unit): Continuation<Any?> = ob
@TaskAction
void executeTest() {
if (!enabled) {
println "Test is disabled: $name"
return
}
createOutputDirectory()
def program = buildExePath()
def suffix = targetManager.programSuffix
+7
View File
@@ -42,6 +42,9 @@ if (isBrowser()) {
},
flush: function () {
this.print(this.stdout);
},
exit: function(status) {
throw Error("Kotlin process called exit (" + status + ")");
}
};
} else {
@@ -49,6 +52,7 @@ if (isBrowser()) {
write: write,
print: print,
flush: function() {},
exit: quit
};
}
@@ -132,6 +136,9 @@ var konan_dependencies = {
Konan_abort: function(pointer) {
throw new Error("Konan_abort(" + utf8decode(toString(pointer)) + ")");
},
Konan_exit: function(status) {
runtime.exit(status);
},
Konan_js_arg_size: function(index) {
if (index >= global_arguments.length) return -1;
return global_arguments[index].length + 1; // + 1 for trailing zero.
+1 -1
View File
@@ -67,7 +67,7 @@ void Kotlin_interop_free(void* ptr) {
}
void Kotlin_system_exitProcess(KInt status) {
exit(status);
konan::exit(status);
}
} // extern "C"
+15 -1
View File
@@ -31,6 +31,11 @@
#include "Porting.h"
#ifdef KONAN_WASM
extern "C" void Konan_abort(const char*);
extern "C" void Konan_exit(int32_t status);
#endif
namespace konan {
// Console operations.
@@ -90,6 +95,16 @@ void abort() {
::abort();
}
#ifdef KONAN_WASM
void exit(int32_t status) {
Konan_exit(status);
}
#else
void exit(int32_t status) {
::exit(status);
}
#endif
// String/byte operations.
// memcpy/memmove are not here intentionally, as frequently implemented/optimized
// by C compiler.
@@ -235,7 +250,6 @@ long getpagesize() {
extern "C" {
#ifdef KONAN_WASM
extern void Konan_abort(const char*);
// TODO: get rid of these.
void _ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv(void) {
+1
View File
@@ -31,6 +31,7 @@ uint32_t consoleReadUtf8(void* utf8, uint32_t maxSizeBytes);
// Process control.
void abort();
void exit(int32_t status);
// String/byte operations.
// memcpy/memmove/memcmp are not here intentionally, as frequently implemented/optimized