runtime: refactor initialization code

Let each target handle its own initialization/finalization sequence
instead of providing one in the runtime with hooks for memory
initialization etc. This is much more flexible although it causes a
little bit of code duplication.
This commit is contained in:
Ayke van Laethem
2018-10-08 14:49:33 +02:00
parent 96f07243a4
commit 8982b8df83
6 changed files with 29 additions and 33 deletions
+10 -3
View File
@@ -24,10 +24,17 @@ type timespec struct {
const CLOCK_MONOTONIC_RAW = 4
func preinit() {
}
// Entry point for Go. Initialize all packages and call main.main().
//go:export main
func main() int {
// Run initializers of all packages.
initAll()
func postinit() {
// Compiler-generated wrapper to main.main().
mainWrapper()
// For libc compatibility.
return 0
}
func putchar(c byte) {