stdlib: Move exit function to porting layer
This commit is contained in:
@@ -2,4 +2,6 @@ import kotlin.system.*
|
|||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
exitProcess(42)
|
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
|
@TaskAction
|
||||||
void executeTest() {
|
void executeTest() {
|
||||||
|
if (!enabled) {
|
||||||
|
println "Test is disabled: $name"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
createOutputDirectory()
|
createOutputDirectory()
|
||||||
def program = buildExePath()
|
def program = buildExePath()
|
||||||
def suffix = targetManager.programSuffix
|
def suffix = targetManager.programSuffix
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ if (isBrowser()) {
|
|||||||
},
|
},
|
||||||
flush: function () {
|
flush: function () {
|
||||||
this.print(this.stdout);
|
this.print(this.stdout);
|
||||||
|
},
|
||||||
|
exit: function(status) {
|
||||||
|
throw Error("Kotlin process called exit (" + status + ")");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@@ -49,6 +52,7 @@ if (isBrowser()) {
|
|||||||
write: write,
|
write: write,
|
||||||
print: print,
|
print: print,
|
||||||
flush: function() {},
|
flush: function() {},
|
||||||
|
exit: quit
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +136,9 @@ var konan_dependencies = {
|
|||||||
Konan_abort: function(pointer) {
|
Konan_abort: function(pointer) {
|
||||||
throw new Error("Konan_abort(" + utf8decode(toString(pointer)) + ")");
|
throw new Error("Konan_abort(" + utf8decode(toString(pointer)) + ")");
|
||||||
},
|
},
|
||||||
|
Konan_exit: function(status) {
|
||||||
|
runtime.exit(status);
|
||||||
|
},
|
||||||
Konan_js_arg_size: function(index) {
|
Konan_js_arg_size: function(index) {
|
||||||
if (index >= global_arguments.length) return -1;
|
if (index >= global_arguments.length) return -1;
|
||||||
return global_arguments[index].length + 1; // + 1 for trailing zero.
|
return global_arguments[index].length + 1; // + 1 for trailing zero.
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ void Kotlin_interop_free(void* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Kotlin_system_exitProcess(KInt status) {
|
void Kotlin_system_exitProcess(KInt status) {
|
||||||
exit(status);
|
konan::exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|||||||
@@ -31,6 +31,11 @@
|
|||||||
|
|
||||||
#include "Porting.h"
|
#include "Porting.h"
|
||||||
|
|
||||||
|
#ifdef KONAN_WASM
|
||||||
|
extern "C" void Konan_abort(const char*);
|
||||||
|
extern "C" void Konan_exit(int32_t status);
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace konan {
|
namespace konan {
|
||||||
|
|
||||||
// Console operations.
|
// Console operations.
|
||||||
@@ -90,6 +95,16 @@ void abort() {
|
|||||||
::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.
|
// String/byte operations.
|
||||||
// memcpy/memmove are not here intentionally, as frequently implemented/optimized
|
// memcpy/memmove are not here intentionally, as frequently implemented/optimized
|
||||||
// by C compiler.
|
// by C compiler.
|
||||||
@@ -235,7 +250,6 @@ long getpagesize() {
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#ifdef KONAN_WASM
|
#ifdef KONAN_WASM
|
||||||
extern void Konan_abort(const char*);
|
|
||||||
|
|
||||||
// TODO: get rid of these.
|
// TODO: get rid of these.
|
||||||
void _ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv(void) {
|
void _ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv(void) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ uint32_t consoleReadUtf8(void* utf8, uint32_t maxSizeBytes);
|
|||||||
|
|
||||||
// Process control.
|
// Process control.
|
||||||
void abort();
|
void abort();
|
||||||
|
void exit(int32_t status);
|
||||||
|
|
||||||
// String/byte operations.
|
// String/byte operations.
|
||||||
// memcpy/memmove/memcmp are not here intentionally, as frequently implemented/optimized
|
// memcpy/memmove/memcmp are not here intentionally, as frequently implemented/optimized
|
||||||
|
|||||||
Reference in New Issue
Block a user