diff options
author | Martin Möhrmann <moehrmann@google.com> | 2018-05-27 08:49:36 +0200 |
---|---|---|
committer | Martin Möhrmann <moehrmann@google.com> | 2018-08-24 14:27:07 +0000 |
commit | 2e8c31b3d2afce1c1c7b0c6af9cc4a9f296af299 (patch) | |
tree | 68b737013b6cf6ec3b10915aff665b45c724b49b /src/runtime/os_linux_arm.go | |
parent | 4363c98f62e9e315ed20b12d2ce47021fd2bf7bc (diff) | |
download | go-2e8c31b3d2afce1c1c7b0c6af9cc4a9f296af299.tar.gz go-2e8c31b3d2afce1c1c7b0c6af9cc4a9f296af299.zip |
runtime: move arm hardware division support detection to internal/cpu
Assumes mandatory VFP and VFPv3 support to be present by default
but not IDIVA if AT_HWCAP is not available.
Adds GODEBUGCPU options to disable the use of code paths in the runtime
that use hardware support for division.
Change-Id: Ida02311bd9b9701de3fc120697e69445bf6c0853
Reviewed-on: https://go-review.googlesource.com/114826
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/os_linux_arm.go')
-rw-r--r-- | src/runtime/os_linux_arm.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/runtime/os_linux_arm.go b/src/runtime/os_linux_arm.go index 14f1cfeaef..8f082ba6a0 100644 --- a/src/runtime/os_linux_arm.go +++ b/src/runtime/os_linux_arm.go @@ -4,20 +4,20 @@ package runtime -import "unsafe" +import ( + "internal/cpu" + "unsafe" +) const ( _AT_PLATFORM = 15 // introduced in at least 2.6.11 _HWCAP_VFP = 1 << 6 // introduced in at least 2.6.11 _HWCAP_VFPv3 = 1 << 13 // introduced in 2.6.30 - _HWCAP_IDIVA = 1 << 17 ) var randomNumber uint32 var armArch uint8 = 6 // we default to ARMv6 -var hwcap uint32 // set by archauxv -var hardDiv bool // set if a hardware divider is available func checkgoarm() { // On Android, /proc/self/auxv might be unreadable and hwcap won't @@ -26,12 +26,12 @@ func checkgoarm() { if GOOS == "android" { return } - if goarm > 5 && hwcap&_HWCAP_VFP == 0 { + if goarm > 5 && cpu.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 { + if goarm > 6 && cpu.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 or GOARM=6.\n") exit(1) @@ -53,9 +53,10 @@ func archauxv(tag, val uintptr) { armArch = t - '0' } - case _AT_HWCAP: // CPU capability bit flags - hwcap = uint32(val) - hardDiv = (hwcap & _HWCAP_IDIVA) != 0 + case _AT_HWCAP: + cpu.HWCap = uint(val) + case _AT_HWCAP2: + cpu.HWCap2 = uint(val) } } |