mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: parse auxv for page size on netbsd
Decode AT_PAGESZ to determine physPageSize on netbsd. Also rename vdso_none.go to auxv_none.go which matches its purpose more closely. Akin to CL 99780 which did the same for freebsd. Change-Id: Iea4322f861ff0f3515e9051585dbb442f024326b Reviewed-on: https://go-review.googlesource.com/102677 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
a44c72823c
commit
4ff4e50725
2 changed files with 36 additions and 1 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
// +build !linux
|
// +build !linux
|
||||||
// +build !darwin
|
// +build !darwin
|
||||||
// +build !freebsd
|
// +build !freebsd
|
||||||
|
// +build !netbsd
|
||||||
|
|
||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
|
|
@ -6,6 +6,7 @@ package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime/internal/atomic"
|
"runtime/internal/atomic"
|
||||||
|
"runtime/internal/sys"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -223,7 +224,9 @@ func netbsdMstart() {
|
||||||
|
|
||||||
func osinit() {
|
func osinit() {
|
||||||
ncpu = getncpu()
|
ncpu = getncpu()
|
||||||
|
if physPageSize == 0 {
|
||||||
physPageSize = getPageSize()
|
physPageSize = getPageSize()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var urandom_dev = []byte("/dev/urandom\x00")
|
var urandom_dev = []byte("/dev/urandom\x00")
|
||||||
|
|
@ -325,3 +328,34 @@ func sigdelset(mask *sigset, i int) {
|
||||||
|
|
||||||
func (c *sigctxt) fixsigcode(sig uint32) {
|
func (c *sigctxt) fixsigcode(sig uint32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sysargs(argc int32, argv **byte) {
|
||||||
|
n := argc + 1
|
||||||
|
|
||||||
|
// skip over argv, envp to get to auxv
|
||||||
|
for argv_index(argv, n) != nil {
|
||||||
|
n++
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip NULL separator
|
||||||
|
n++
|
||||||
|
|
||||||
|
// now argv+n is auxv
|
||||||
|
auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize))
|
||||||
|
sysauxv(auxv[:])
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
_AT_NULL = 0 // Terminates the vector
|
||||||
|
_AT_PAGESZ = 6 // Page size in bytes
|
||||||
|
)
|
||||||
|
|
||||||
|
func sysauxv(auxv []uintptr) {
|
||||||
|
for i := 0; auxv[i] != _AT_NULL; i += 2 {
|
||||||
|
tag, val := auxv[i], auxv[i+1]
|
||||||
|
switch tag {
|
||||||
|
case _AT_PAGESZ:
|
||||||
|
physPageSize = val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue