generalize -scheduler=none to support most platforms

Этот коммит содержится в:
Jaden Weiss 2020-02-07 17:17:38 -05:00 коммит произвёл Ayke
родитель 5089d1a5a7
коммит 5d869f6042
12 изменённых файлов: 48 добавлений и 40 удалений

Просмотреть файл

@ -30,20 +30,16 @@ var _sidata [0]byte
//go:extern _edata //go:extern _edata
var _edata [0]byte var _edata [0]byte
func postinit() {}
// Entry point for Go. Initialize all packages and call main.main(). // Entry point for Go. Initialize all packages and call main.main().
//go:export main //go:export main
func main() { func main() {
// Initialize .data and .bss sections. // Initialize .data and .bss sections.
preinit() preinit()
// Run initializers of all packages. // Run program.
initAll() run()
// Compiler-generated call to main.main().
go callMain()
// Run the scheduler.
scheduler()
} }
func preinit() { func preinit() {

Просмотреть файл

@ -13,12 +13,12 @@ import (
type timeUnit int64 type timeUnit int64
func postinit() {}
//go:export Reset_Handler //go:export Reset_Handler
func main() { func main() {
preinit() preinit()
initAll() run()
go callMain()
scheduler()
abort() abort()
} }

Просмотреть файл

@ -12,12 +12,12 @@ import (
type timeUnit int64 type timeUnit int64
func postinit() {}
//go:export Reset_Handler //go:export Reset_Handler
func main() { func main() {
preinit() preinit()
initAll() run()
go callMain()
scheduler()
abort() abort()
} }

Просмотреть файл

@ -39,9 +39,7 @@ var _ebss [0]byte
//go:export main //go:export main
func main() { func main() {
preinit() preinit()
initAll() run()
postinit()
callMain()
abort() abort()
} }

Просмотреть файл

@ -17,12 +17,12 @@ const tickMicros = 1
var timestamp timeUnit var timestamp timeUnit
func postinit() {}
//go:export Reset_Handler //go:export Reset_Handler
func main() { func main() {
preinit() preinit()
initAll() run()
go callMain()
scheduler()
arm.SemihostingCall(arm.SemihostingReportException, arm.SemihostingApplicationExit) arm.SemihostingCall(arm.SemihostingReportException, arm.SemihostingApplicationExit)
abort() abort()
} }

Просмотреть файл

@ -31,6 +31,8 @@ var _sidata [0]byte
//go:extern _edata //go:extern _edata
var _edata [0]byte var _edata [0]byte
func postinit() {}
//go:export main //go:export main
func main() { func main() {
// Zero the PLIC enable bits on startup: they are not zeroed at reset. // Zero the PLIC enable bits on startup: they are not zeroed at reset.
@ -51,9 +53,7 @@ func main() {
preinit() preinit()
initPeripherals() initPeripherals()
initAll() run()
go callMain()
scheduler()
abort() abort()
} }

Просмотреть файл

@ -17,13 +17,13 @@ const tickMicros = 1024 * 32
//go:linkname systemInit SystemInit //go:linkname systemInit SystemInit
func systemInit() func systemInit()
func postinit() {}
//go:export Reset_Handler //go:export Reset_Handler
func main() { func main() {
systemInit() systemInit()
preinit() preinit()
initAll() run()
go callMain()
scheduler()
abort() abort()
} }

Просмотреть файл

@ -4,11 +4,11 @@ package runtime
type timeUnit int64 type timeUnit int64
func postinit() {}
//go:export Reset_Handler //go:export Reset_Handler
func main() { func main() {
preinit() preinit()
initAll() run()
go callMain()
scheduler()
abort() abort()
} }

Просмотреть файл

@ -45,17 +45,12 @@ type timespec struct {
const CLOCK_MONOTONIC_RAW = 4 const CLOCK_MONOTONIC_RAW = 4
func postinit() {}
// Entry point for Go. Initialize all packages and call main.main(). // Entry point for Go. Initialize all packages and call main.main().
//go:export main //go:export main
func main() int { func main() int {
// Run initializers of all packages. run()
initAll()
// Compiler-generated call to main.main().
go callMain()
// Run scheduler.
scheduler()
// For libc compatibility. // For libc compatibility.
return 0 return 0

Просмотреть файл

@ -18,11 +18,11 @@ type wasiIOVec struct {
//export fd_write //export fd_write
func fd_write(id uint32, iovs *wasiIOVec, iovs_len uint, nwritten *uint) (errno uint) func fd_write(id uint32, iovs *wasiIOVec, iovs_len uint, nwritten *uint) (errno uint)
func postinit() {}
//export _start //export _start
func _start() { func _start() {
initAll() run()
go callMain()
scheduler()
} }
// Using global variables to avoid heap allocation. // Using global variables to avoid heap allocation.

Просмотреть файл

@ -10,3 +10,14 @@ func sleep(duration int64) {
addSleepTask(task.Current(), duration) addSleepTask(task.Current(), duration)
task.Pause() task.Pause()
} }
// run is called by the program entry point to execute the go program.
// With a scheduler, init and the main function are invoked in a goroutine before starting the scheduler.
func run() {
initAll()
postinit()
go func() {
callMain()
}()
scheduler()
}

Просмотреть файл

@ -12,3 +12,11 @@ func sleep(duration int64) {
func getSystemStackPointer() uintptr { func getSystemStackPointer() uintptr {
return getCurrentStackPointer() return getCurrentStackPointer()
} }
// run is called by the program entry point to execute the go program.
// With the "none" scheduler, init and the main function are invoked directly.
func run() {
initAll()
postinit()
callMain()
}