diff --git a/main_test.go b/main_test.go index 58ad63b9..607f109b 100644 --- a/main_test.go +++ b/main_test.go @@ -171,9 +171,6 @@ func TestCompiler(t *testing.T) { case "float.go", "math.go", "print.go": // Stuck in runtime.printfloat64. - case "goroutines.go": - // The main() never runs. - case "interface.go": // Several comparison tests fail. diff --git a/src/runtime/runtime_arm7tdmi.go b/src/runtime/runtime_arm7tdmi.go index 3938506b..3b383c32 100644 --- a/src/runtime/runtime_arm7tdmi.go +++ b/src/runtime/runtime_arm7tdmi.go @@ -28,8 +28,6 @@ var _sidata [0]byte //go:extern _edata var _edata [0]byte -func postinit() {} - // Entry point for Go. Initialize all packages and call main.main(). //export main func main() { diff --git a/src/runtime/runtime_atsamd21.go b/src/runtime/runtime_atsamd21.go index 32ed1cea..c4147c80 100644 --- a/src/runtime/runtime_atsamd21.go +++ b/src/runtime/runtime_atsamd21.go @@ -13,8 +13,6 @@ import ( type timeUnit int64 -func postinit() {} - //export Reset_Handler func main() { preinit() diff --git a/src/runtime/runtime_atsamd51.go b/src/runtime/runtime_atsamd51.go index ec704471..3561050b 100644 --- a/src/runtime/runtime_atsamd51.go +++ b/src/runtime/runtime_atsamd51.go @@ -12,8 +12,6 @@ import ( type timeUnit int64 -func postinit() {} - //export Reset_Handler func main() { arm.SCB.CPACR.Set(0) // disable FPU if it is enabled diff --git a/src/runtime/runtime_avr.go b/src/runtime/runtime_avr.go index 72b14106..75102044 100644 --- a/src/runtime/runtime_avr.go +++ b/src/runtime/runtime_avr.go @@ -42,6 +42,7 @@ var _ebss [0]byte //export main func main() { preinit() + initHardware() run() exit(0) } @@ -55,15 +56,13 @@ func preinit() { } } -func postinit() { - // Enable interrupts after initialization. - avr.Asm("sei") -} - -func init() { +func initHardware() { initUART() machine.InitMonotonicTimer() nextTimerRecalibrate = ticks() + timerRecalibrateInterval + + // Enable interrupts after initialization. + avr.Asm("sei") } func ticksToNanoseconds(ticks timeUnit) int64 { diff --git a/src/runtime/runtime_cortexm_qemu.go b/src/runtime/runtime_cortexm_qemu.go index 2d7e78f3..07eef706 100644 --- a/src/runtime/runtime_cortexm_qemu.go +++ b/src/runtime/runtime_cortexm_qemu.go @@ -15,8 +15,6 @@ type timeUnit int64 var timestamp timeUnit -func postinit() {} - //export Reset_Handler func main() { preinit() diff --git a/src/runtime/runtime_esp32xx.go b/src/runtime/runtime_esp32xx.go index 54dadab8..b3270ac3 100644 --- a/src/runtime/runtime_esp32xx.go +++ b/src/runtime/runtime_esp32xx.go @@ -14,8 +14,6 @@ func putchar(c byte) { machine.Serial.WriteByte(c) } -func postinit() {} - // Initialize .bss: zero-initialized global variables. // The .data section has already been loaded by the ROM bootloader. func clearbss() { diff --git a/src/runtime/runtime_esp8266.go b/src/runtime/runtime_esp8266.go index aa698aed..936b99a4 100644 --- a/src/runtime/runtime_esp8266.go +++ b/src/runtime/runtime_esp8266.go @@ -23,8 +23,6 @@ func putchar(c byte) { //export rom_i2c_writeReg func rom_i2c_writeReg(block, host_id, reg_add, data uint8) -func postinit() {} - //export main func main() { // Clear .bss section. .data has already been loaded by the ROM bootloader. diff --git a/src/runtime/runtime_fe310.go b/src/runtime/runtime_fe310.go index 33d8e483..c09dfe81 100644 --- a/src/runtime/runtime_fe310.go +++ b/src/runtime/runtime_fe310.go @@ -16,8 +16,6 @@ import ( type timeUnit int64 -func postinit() {} - //export main func main() { // Zero the PLIC enable bits on startup: they are not zeroed at reset. diff --git a/src/runtime/runtime_k210.go b/src/runtime/runtime_k210.go index dc8ee044..2fb4fec6 100644 --- a/src/runtime/runtime_k210.go +++ b/src/runtime/runtime_k210.go @@ -15,8 +15,6 @@ import ( type timeUnit int64 -func postinit() {} - //export main func main() { diff --git a/src/runtime/runtime_mimxrt1062.go b/src/runtime/runtime_mimxrt1062.go index 6c1212cb..8a9f2b01 100644 --- a/src/runtime/runtime_mimxrt1062.go +++ b/src/runtime/runtime_mimxrt1062.go @@ -16,8 +16,6 @@ var _svectors [0]byte //go:extern _flexram_cfg var _flexram_cfg [0]byte -func postinit() {} - //export Reset_Handler func main() { diff --git a/src/runtime/runtime_nintendoswitch.go b/src/runtime/runtime_nintendoswitch.go index 99cb3b0b..0267b541 100644 --- a/src/runtime/runtime_nintendoswitch.go +++ b/src/runtime/runtime_nintendoswitch.go @@ -43,8 +43,6 @@ var ( totalHeap = uint64(0) ) -func postinit() {} - func preinit() { // Unsafe to use heap here setupEnv() diff --git a/src/runtime/runtime_nrf.go b/src/runtime/runtime_nrf.go index 551078b8..dfbc76e1 100644 --- a/src/runtime/runtime_nrf.go +++ b/src/runtime/runtime_nrf.go @@ -15,8 +15,6 @@ type timeUnit int64 //go:linkname systemInit SystemInit func systemInit() -func postinit() {} - //export Reset_Handler func main() { if nrf.FPUPresent { diff --git a/src/runtime/runtime_nxpmk66f18.go b/src/runtime/runtime_nxpmk66f18.go index c54ab377..02a9bb59 100644 --- a/src/runtime/runtime_nxpmk66f18.go +++ b/src/runtime/runtime_nxpmk66f18.go @@ -226,8 +226,6 @@ func initInternal() { // analog_init(); } -func postinit() {} - func putchar(c byte) { machine.PutcharUART(machine.UART0, c) } diff --git a/src/runtime/runtime_rp2040.go b/src/runtime/runtime_rp2040.go index 4d615a14..38f6d304 100644 --- a/src/runtime/runtime_rp2040.go +++ b/src/runtime/runtime_rp2040.go @@ -53,8 +53,6 @@ func init() { machine.Serial.Configure(machine.UARTConfig{}) } -func postinit() {} - //export Reset_Handler func main() { preinit() diff --git a/src/runtime/runtime_stm32.go b/src/runtime/runtime_stm32.go index 08dde0dd..aabffa2a 100644 --- a/src/runtime/runtime_stm32.go +++ b/src/runtime/runtime_stm32.go @@ -6,8 +6,6 @@ import "device/arm" type timeUnit int64 -func postinit() {} - //export Reset_Handler func main() { preinit() diff --git a/src/runtime/runtime_tinygoriscv_qemu.go b/src/runtime/runtime_tinygoriscv_qemu.go index 04e41b81..8558f41e 100644 --- a/src/runtime/runtime_tinygoriscv_qemu.go +++ b/src/runtime/runtime_tinygoriscv_qemu.go @@ -15,8 +15,6 @@ type timeUnit int64 var timestamp timeUnit -func postinit() {} - //export main func main() { preinit() diff --git a/src/runtime/runtime_tinygowasm.go b/src/runtime/runtime_tinygowasm.go index 80eaa8d3..a5b1b3c8 100644 --- a/src/runtime/runtime_tinygowasm.go +++ b/src/runtime/runtime_tinygowasm.go @@ -22,8 +22,6 @@ func fd_write(id uint32, iovs *__wasi_iovec_t, iovs_len uint, nwritten *uint) (e //export proc_exit func proc_exit(exitcode uint32) -func postinit() {} - const ( putcharBufferSize = 120 stdout = 1 diff --git a/src/runtime/runtime_unix.go b/src/runtime/runtime_unix.go index 5b9161dd..fe8c0cac 100644 --- a/src/runtime/runtime_unix.go +++ b/src/runtime/runtime_unix.go @@ -65,8 +65,6 @@ type timespec struct { var stackTop uintptr -func postinit() {} - // Entry point for Go. Initialize all packages and call main.main(). //export main func main(argc int32, argv *unsafe.Pointer) int { diff --git a/src/runtime/runtime_windows.go b/src/runtime/runtime_windows.go index 6872992d..851f40f7 100644 --- a/src/runtime/runtime_windows.go +++ b/src/runtime/runtime_windows.go @@ -41,8 +41,6 @@ func __p___argc() *int32 //export __p___argv func __p___argv() **unsafe.Pointer -func postinit() {} - //export mainCRTStartup func mainCRTStartup() int { preinit() diff --git a/src/runtime/scheduler_any.go b/src/runtime/scheduler_any.go index e0597dc3..d8097915 100644 --- a/src/runtime/scheduler_any.go +++ b/src/runtime/scheduler_any.go @@ -22,7 +22,6 @@ func run() { initHeap() go func() { initAll() - postinit() callMain() schedulerDone = true }() diff --git a/src/runtime/scheduler_none.go b/src/runtime/scheduler_none.go index b037dae0..2086e422 100644 --- a/src/runtime/scheduler_none.go +++ b/src/runtime/scheduler_none.go @@ -23,7 +23,6 @@ func getSystemStackPointer() uintptr { func run() { initHeap() initAll() - postinit() callMain() }