aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/os_linux_arm.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-04-14 12:12:45 -0400
committerAustin Clements <austin@google.com>2016-04-16 21:42:27 +0000
commitc955bb2040e601c474e547b8badbe44677c9fbdf (patch)
treee5ef0398f9f19324560a1b23aa4ac03f4f12e284 /src/runtime/os_linux_arm.go
parent26ecb42fb4c5ee1d8b64f12e5bb8df6549523d23 (diff)
downloadgo-c955bb2040e601c474e547b8badbe44677c9fbdf.tar.xz
runtime: common auxv parser
Currently several different Linux architectures have separate copies of the auxv parser. Bring these all together into a single copy of the parser that calls out to a per-arch handler for each tag/value pair. This is in preparation for handling common auxv tags in one place. For #9993. Change-Id: Iceebc3afad6b4133b70fca7003561ae370445c10 Reviewed-on: https://go-review.googlesource.com/22061 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Diffstat (limited to 'src/runtime/os_linux_arm.go')
-rw-r--r--src/runtime/os_linux_arm.go46
1 files changed, 16 insertions, 30 deletions
diff --git a/src/runtime/os_linux_arm.go b/src/runtime/os_linux_arm.go
index 8fdfb585ba..a61be916b6 100644
--- a/src/runtime/os_linux_arm.go
+++ b/src/runtime/os_linux_arm.go
@@ -4,13 +4,9 @@
package runtime
-import (
- "runtime/internal/sys"
- "unsafe"
-)
+import "unsafe"
const (
- _AT_NULL = 0
_AT_PLATFORM = 15 // introduced in at least 2.6.11
_AT_HWCAP = 16 // introduced in at least 2.6.11
_AT_RANDOM = 25 // introduced in 2.6.29
@@ -36,33 +32,23 @@ func checkgoarm() {
}
}
-func sysargs(argc int32, argv **byte) {
- // skip over argv, envv to get to auxv
- n := argc + 1
- for argv_index(argv, n) != nil {
- n++
- }
- n++
- auxv := (*[1 << 28]uint32)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize))
-
- for i := 0; auxv[i] != _AT_NULL; i += 2 {
- switch auxv[i] {
- case _AT_RANDOM: // kernel provides a pointer to 16-bytes worth of random data
- startupRandomData = (*[16]byte)(unsafe.Pointer(uintptr(auxv[i+1])))[:]
- // the pointer provided may not be word aligned, so we must treat it
- // as a byte array.
- randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
- uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
+func archauxv(tag, val uintptr) {
+ switch tag {
+ case _AT_RANDOM: // kernel provides a pointer to 16-bytes worth of random data
+ startupRandomData = (*[16]byte)(unsafe.Pointer(val))[:]
+ // the pointer provided may not be word aligned, so we must treat it
+ // as a byte array.
+ randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
+ uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
- case _AT_PLATFORM: // v5l, v6l, v7l
- t := *(*uint8)(unsafe.Pointer(uintptr(auxv[i+1] + 1)))
- if '5' <= t && t <= '7' {
- armArch = t - '0'
- }
-
- case _AT_HWCAP: // CPU capability bit flags
- hwcap = auxv[i+1]
+ case _AT_PLATFORM: // v5l, v6l, v7l
+ t := *(*uint8)(unsafe.Pointer(val + 1))
+ if '5' <= t && t <= '7' {
+ armArch = t - '0'
}
+
+ case _AT_HWCAP: // CPU capability bit flags
+ hwcap = uint32(val)
}
}