diff options
| author | Fangming.Fang <fangming.fang@arm.com> | 2017-11-08 02:17:51 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2017-11-14 19:07:15 +0000 |
| commit | 66bfbd9ad7a93ea85175bf1db663ca5f440666e3 (patch) | |
| tree | 7ada947a495b21f1520f1534a287ef9dcc398b0e /src/runtime | |
| parent | b3ee6f0c2e8be8701ec15f3fb91397e086f106ae (diff) | |
| download | go-66bfbd9ad7a93ea85175bf1db663ca5f440666e3.tar.xz | |
internal/cpu: detect cpu features in internal/cpu package
change hash/crc32 package to use cpu package instead of using
runtime internal variables to check crc32 instruction
Change-Id: I8f88d2351bde8ed4e256f9adf822a08b9a00f532
Reviewed-on: https://go-review.googlesource.com/76490
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/os_darwin_arm64.go | 2 | ||||
| -rw-r--r-- | src/runtime/os_linux_arm64.go | 20 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/runtime/os_darwin_arm64.go b/src/runtime/os_darwin_arm64.go index 01285afa19..8de132d8e2 100644 --- a/src/runtime/os_darwin_arm64.go +++ b/src/runtime/os_darwin_arm64.go @@ -4,8 +4,6 @@ package runtime -var supportCRC32 = false - //go:nosplit func cputicks() int64 { // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand(). diff --git a/src/runtime/os_linux_arm64.go b/src/runtime/os_linux_arm64.go index 986a34135e..96827e7c9f 100644 --- a/src/runtime/os_linux_arm64.go +++ b/src/runtime/os_linux_arm64.go @@ -2,14 +2,22 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build arm64 + package runtime -const ( - _ARM64_FEATURE_HAS_CRC32 = 0x80 -) +// For go:linkname +import _ "unsafe" var randomNumber uint32 -var supportCRC32 bool + +// arm64 doesn't have a 'cpuid' instruction equivalent and relies on +// HWCAP/HWCAP2 bits for hardware capabilities. + +//go:linkname cpu_hwcap internal/cpu.arm64_hwcap +//go:linkname cpu_hwcap2 internal/cpu.arm64_hwcap2 +var cpu_hwcap uint +var cpu_hwcap2 uint func archauxv(tag, val uintptr) { switch tag { @@ -20,7 +28,9 @@ func archauxv(tag, val uintptr) { randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 | uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24 case _AT_HWCAP: - supportCRC32 = val&_ARM64_FEATURE_HAS_CRC32 != 0 + cpu_hwcap = uint(val) + case _AT_HWCAP2: + cpu_hwcap2 = uint(val) } } |
