1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

goruntime: split bootstrap symbols into conditionally compiled files

Due to some changes in the runtime init functions between go 1.7 and
later versions (e.g. runtime.modulesInit() defined after go 1.7), the
kernel code that bootstraps the go runtime had to be split into separate
files which are conditionally compiled using +build flags.
This commit is contained in:
Achilleas Anagnostopoulos 2018-03-23 07:20:22 +00:00
parent 4e3567f8a1
commit 8d0c44921b
3 changed files with 59 additions and 22 deletions

View File

@ -27,27 +27,6 @@ var (
prngSeed = 0xdeadc0de prngSeed = 0xdeadc0de
) )
//go:linkname algInit runtime.alginit
func algInit()
//go:linkname modulesInit runtime.modulesinit
func modulesInit()
//go:linkname typeLinksInit runtime.typelinksinit
func typeLinksInit()
//go:linkname itabsInit runtime.itabsinit
func itabsInit()
//go:linkname mallocInit runtime.mallocinit
func mallocInit()
//go:linkname mSysStatInc runtime.mSysStatInc
func mSysStatInc(*uint64, uintptr)
//go:linkname procResize runtime.procresize
func procResize(int32) uintptr
// initGoPackages is an alias to main.init which recursively calls the init() // initGoPackages is an alias to main.init which recursively calls the init()
// methods in all imported packages. Unless this function is called, things like // methods in all imported packages. Unless this function is called, things like
// package errors will not be properly initialized causing various problems when // package errors will not be properly initialized causing various problems when
@ -184,7 +163,7 @@ func getRandomData(r []byte) {
func Init() *kernel.Error { func Init() *kernel.Error {
mallocInitFn() mallocInitFn()
algInitFn() // setup hash implementation for map keys algInitFn() // setup hash implementation for map keys
modulesInitFn() // provides activeModules modulesInitFn() // provides activeModules (go 1.8+)
typeLinksInitFn() // uses maps, activeModules typeLinksInitFn() // uses maps, activeModules
itabsInitFn() // uses activeModules itabsInitFn() // uses activeModules

View File

@ -0,0 +1,30 @@
// +build go1.7,!go1.8
package goruntime
import (
_ "unsafe" // required for go:linkname
)
//go:linkname algInit runtime.alginit
func algInit()
//go:linkname typeLinksInit runtime.typelinksinit
func typeLinksInit()
//go:linkname itabsInit runtime.itabsinit
func itabsInit()
//go:linkname mallocInit runtime.mallocinit
func mallocInit()
//go:linkname mSysStatInc runtime.mSysStatInc
func mSysStatInc(*uint64, uintptr)
//go:linkname procResize runtime.procresize
func procResize(int32) uintptr
// modulesInit is defined on go1.8 so just declare an empty
// stub for go 1.7 to keep the compiler happy.
func modulesInit() {
}

View File

@ -0,0 +1,28 @@
// +build go1.8
package goruntime
import (
_ "unsafe" // required for go:linkname
)
//go:linkname algInit runtime.alginit
func algInit()
//go:linkname modulesInit runtime.modulesinit
func modulesInit()
//go:linkname typeLinksInit runtime.typelinksinit
func typeLinksInit()
//go:linkname itabsInit runtime.itabsinit
func itabsInit()
//go:linkname mallocInit runtime.mallocinit
func mallocInit()
//go:linkname mSysStatInc runtime.mSysStatInc
func mSysStatInc(*uint64, uintptr)
//go:linkname procResize runtime.procresize
func procResize(int32) uintptr