func osinit() {
ncpu = getncpu()
- physPageSize = getPageSize()
+ if physPageSize == 0 {
+ physPageSize = getPageSize()
+ }
}
var urandom_dev = []byte("/dev/urandom\x00")
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
+ _AT_HWCAP = 16 // CPU feature flags
+)
+
+func sysauxv(auxv []uintptr) {
+ for i := 0; auxv[i] != _AT_NULL; i += 2 {
+ tag, val := auxv[i], auxv[i+1]
+ switch tag {
+ // _AT_NCPUS from auxv shouldn't be used due to golang.org/issue/15206
+ case _AT_PAGESZ:
+ physPageSize = val
+ }
+
+ archauxv(tag, val)
+ }
+}
package runtime
-var hardDiv bool // TODO: set if a hardware divider is available
+const (
+ _HWCAP_VFP = 1 << 6
+ _HWCAP_VFPv3 = 1 << 13
+ _HWCAP_IDIVA = 1 << 17
+)
+
+var hwcap uint32 // set by archauxv
+var hardDiv bool // set if a hardware divider is available
func checkgoarm() {
- // TODO(minux): FP checks like in os_linux_arm.go.
+ if goarm > 5 && hwcap&_HWCAP_VFP == 0 {
+ print("runtime: this CPU has no floating point hardware, so it cannot run\n")
+ print("this GOARM=", goarm, " binary. Recompile using GOARM=5.\n")
+ exit(1)
+ }
+ if goarm > 6 && hwcap&_HWCAP_VFPv3 == 0 {
+ print("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n")
+ print("this GOARM=", goarm, " binary. Recompile using GOARM=5.\n")
+ exit(1)
+ }
// osinit not called yet, so ncpu not set: must use getncpu directly.
if getncpu() > 1 && goarm < 7 {
}
}
+func archauxv(tag, val uintptr) {
+ switch tag {
+ case _AT_HWCAP: // CPU capability bit flags
+ hwcap = uint32(val)
+ hardDiv = (hwcap & _HWCAP_IDIVA) != 0
+ }
+}
+
//go:nosplit
func cputicks() int64 {
// Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
--- /dev/null
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build freebsd
+// +build !arm
+
+package runtime
+
+func archauxv(tag, val uintptr) {
+}
// +build !linux
// +build !darwin
+// +build !freebsd
package runtime