Skip to content

Commit

Permalink
runtime: initialise cpu.HWCap on netbsd/arm64
Browse files Browse the repository at this point in the history
NetBSD does not supply AT_HWCAP, however we still need to initialise
cpu.HWCaps.  For now specify the bare minimum until we add some form of
capabilities detection. See
https://golang.org/issue/30824#issuecomment-494901591

Follows CL 174129 which did the same for openbsd/arm64.

Updates #30824

Change-Id: I43a86b583bc60d259a66772703de06970124bb7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/257998
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
  • Loading branch information
tklauser committed Sep 28, 2020
1 parent af18bce commit 1f4d035
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/runtime/os_netbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ func sysargs(argc int32, argv **byte) {
// now argv+n is auxv
auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize))
sysauxv(auxv[:])
archauxv(auxv[:])
}

const (
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/os_netbsd_386.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ func lwp_mcontext_init(mc *mcontextt, stk unsafe.Pointer, mp *m, gp *g, fn uintp
mc.__gregs[_REG_EDX] = uint32(uintptr(unsafe.Pointer(gp)))
mc.__gregs[_REG_ESI] = uint32(fn)
}

func archauxv(auxv []uintptr) {
}
3 changes: 3 additions & 0 deletions src/runtime/os_netbsd_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ func lwp_mcontext_init(mc *mcontextt, stk unsafe.Pointer, mp *m, gp *g, fn uintp
mc.__gregs[_REG_R9] = uint64(uintptr(unsafe.Pointer(gp)))
mc.__gregs[_REG_R12] = uint64(fn)
}

func archauxv(auxv []uintptr) {
}
3 changes: 3 additions & 0 deletions src/runtime/os_netbsd_arm.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ func cputicks() int64 {
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
return nanotime()
}

func archauxv(auxv []uintptr) {
}
12 changes: 11 additions & 1 deletion src/runtime/os_netbsd_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

package runtime

import "unsafe"
import (
"internal/cpu"
"unsafe"
)

func lwp_mcontext_init(mc *mcontextt, stk unsafe.Pointer, mp *m, gp *g, fn uintptr) {
// Machine dependent mcontext initialisation for LWP.
Expand All @@ -21,3 +24,10 @@ func cputicks() int64 {
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
return nanotime()
}

func archauxv(auxv []uintptr) {
// NetBSD does not supply AT_HWCAP, however we still need to initialise cpu.HWCaps.
// For now specify the bare minimum until we add some form of capabilities
// detection. See issue https://golang.org/issue/30824#issuecomment-494901591
cpu.HWCap = 1<<1 | 1<<0 // ASIMD, FP
}

0 comments on commit 1f4d035

Please sign in to comment.