Skip to content

Commit d469809

Browse files
committed
internal/cpu: remove platform specific prefix from cpu hwcap variables
Go runtime currently only populates hwcap for ppc64 and arm64. While the interpretation of hwcap is platform specific the hwcap information is generally available on linux. Changing the runtime variable name to cpu_hwcap for cpu.hwcap makes it consistent with the general naming of runtime variables that are linked to other packages. Change-Id: I1e1f932a73ed624a219b9298faafbb6355e47ada Reviewed-on: https://go-review.googlesource.com/94757 Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Martin Möhrmann <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 5d9c782 commit d469809

File tree

4 files changed

+44
-43
lines changed

4 files changed

+44
-43
lines changed

src/internal/cpu/cpu_arm64.go

+26-26
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const CacheLineSize = 64
99
// arm64 doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2.
1010
// These are linknamed in runtime/os_linux_arm64.go and are initialized by
1111
// archauxv().
12-
var arm64_hwcap uint
13-
var arm64_hwcap2 uint
12+
var hwcap uint
13+
var hwcap2 uint
1414

1515
// HWCAP/HWCAP2 bits. These are exposed by Linux.
1616
const (
@@ -42,30 +42,30 @@ const (
4242

4343
func doinit() {
4444
// HWCAP feature bits
45-
ARM64.HasFP = isSet(arm64_hwcap, hwcap_FP)
46-
ARM64.HasASIMD = isSet(arm64_hwcap, hwcap_ASIMD)
47-
ARM64.HasEVTSTRM = isSet(arm64_hwcap, hwcap_EVTSTRM)
48-
ARM64.HasAES = isSet(arm64_hwcap, hwcap_AES)
49-
ARM64.HasPMULL = isSet(arm64_hwcap, hwcap_PMULL)
50-
ARM64.HasSHA1 = isSet(arm64_hwcap, hwcap_SHA1)
51-
ARM64.HasSHA2 = isSet(arm64_hwcap, hwcap_SHA2)
52-
ARM64.HasCRC32 = isSet(arm64_hwcap, hwcap_CRC32)
53-
ARM64.HasATOMICS = isSet(arm64_hwcap, hwcap_ATOMICS)
54-
ARM64.HasFPHP = isSet(arm64_hwcap, hwcap_FPHP)
55-
ARM64.HasASIMDHP = isSet(arm64_hwcap, hwcap_ASIMDHP)
56-
ARM64.HasCPUID = isSet(arm64_hwcap, hwcap_CPUID)
57-
ARM64.HasASIMDRDM = isSet(arm64_hwcap, hwcap_ASIMDRDM)
58-
ARM64.HasJSCVT = isSet(arm64_hwcap, hwcap_JSCVT)
59-
ARM64.HasFCMA = isSet(arm64_hwcap, hwcap_FCMA)
60-
ARM64.HasLRCPC = isSet(arm64_hwcap, hwcap_LRCPC)
61-
ARM64.HasDCPOP = isSet(arm64_hwcap, hwcap_DCPOP)
62-
ARM64.HasSHA3 = isSet(arm64_hwcap, hwcap_SHA3)
63-
ARM64.HasSM3 = isSet(arm64_hwcap, hwcap_SM3)
64-
ARM64.HasSM4 = isSet(arm64_hwcap, hwcap_SM4)
65-
ARM64.HasASIMDDP = isSet(arm64_hwcap, hwcap_ASIMDDP)
66-
ARM64.HasSHA512 = isSet(arm64_hwcap, hwcap_SHA512)
67-
ARM64.HasSVE = isSet(arm64_hwcap, hwcap_SVE)
68-
ARM64.HasASIMDFHM = isSet(arm64_hwcap, hwcap_ASIMDFHM)
45+
ARM64.HasFP = isSet(hwcap, hwcap_FP)
46+
ARM64.HasASIMD = isSet(hwcap, hwcap_ASIMD)
47+
ARM64.HasEVTSTRM = isSet(hwcap, hwcap_EVTSTRM)
48+
ARM64.HasAES = isSet(hwcap, hwcap_AES)
49+
ARM64.HasPMULL = isSet(hwcap, hwcap_PMULL)
50+
ARM64.HasSHA1 = isSet(hwcap, hwcap_SHA1)
51+
ARM64.HasSHA2 = isSet(hwcap, hwcap_SHA2)
52+
ARM64.HasCRC32 = isSet(hwcap, hwcap_CRC32)
53+
ARM64.HasATOMICS = isSet(hwcap, hwcap_ATOMICS)
54+
ARM64.HasFPHP = isSet(hwcap, hwcap_FPHP)
55+
ARM64.HasASIMDHP = isSet(hwcap, hwcap_ASIMDHP)
56+
ARM64.HasCPUID = isSet(hwcap, hwcap_CPUID)
57+
ARM64.HasASIMDRDM = isSet(hwcap, hwcap_ASIMDRDM)
58+
ARM64.HasJSCVT = isSet(hwcap, hwcap_JSCVT)
59+
ARM64.HasFCMA = isSet(hwcap, hwcap_FCMA)
60+
ARM64.HasLRCPC = isSet(hwcap, hwcap_LRCPC)
61+
ARM64.HasDCPOP = isSet(hwcap, hwcap_DCPOP)
62+
ARM64.HasSHA3 = isSet(hwcap, hwcap_SHA3)
63+
ARM64.HasSM3 = isSet(hwcap, hwcap_SM3)
64+
ARM64.HasSM4 = isSet(hwcap, hwcap_SM4)
65+
ARM64.HasASIMDDP = isSet(hwcap, hwcap_ASIMDDP)
66+
ARM64.HasSHA512 = isSet(hwcap, hwcap_SHA512)
67+
ARM64.HasSVE = isSet(hwcap, hwcap_SVE)
68+
ARM64.HasASIMDFHM = isSet(hwcap, hwcap_ASIMDFHM)
6969
}
7070

7171
func isSet(hwc uint, value uint) bool {

src/internal/cpu/cpu_ppc64x.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const CacheLineSize = 128
1111
// ppc64x doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2.
1212
// These are linknamed in runtime/os_linux_ppc64x.go and are initialized by
1313
// archauxv().
14-
var ppc64x_hwcap uint
15-
var ppc64x_hwcap2 uint
14+
var hwcap uint
15+
var hwcap2 uint
1616

1717
// HWCAP/HWCAP2 bits. These are exposed by the kernel.
1818
const (
@@ -34,19 +34,19 @@ const (
3434

3535
func init() {
3636
// HWCAP feature bits
37-
PPC64.HasVMX = isSet(ppc64x_hwcap, _PPC_FEATURE_HAS_ALTIVEC)
38-
PPC64.HasDFP = isSet(ppc64x_hwcap, _PPC_FEATURE_HAS_DFP)
39-
PPC64.HasVSX = isSet(ppc64x_hwcap, _PPC_FEATURE_HAS_VSX)
37+
PPC64.HasVMX = isSet(hwcap, _PPC_FEATURE_HAS_ALTIVEC)
38+
PPC64.HasDFP = isSet(hwcap, _PPC_FEATURE_HAS_DFP)
39+
PPC64.HasVSX = isSet(hwcap, _PPC_FEATURE_HAS_VSX)
4040

4141
// HWCAP2 feature bits
42-
PPC64.IsPOWER8 = isSet(ppc64x_hwcap2, _PPC_FEATURE2_ARCH_2_07)
43-
PPC64.HasHTM = isSet(ppc64x_hwcap2, _PPC_FEATURE2_HAS_HTM)
44-
PPC64.HasISEL = isSet(ppc64x_hwcap2, _PPC_FEATURE2_HAS_ISEL)
45-
PPC64.HasVCRYPTO = isSet(ppc64x_hwcap2, _PPC_FEATURE2_HAS_VEC_CRYPTO)
46-
PPC64.HasHTMNOSC = isSet(ppc64x_hwcap2, _PPC_FEATURE2_HTM_NOSC)
47-
PPC64.IsPOWER9 = isSet(ppc64x_hwcap2, _PPC_FEATURE2_ARCH_3_00)
48-
PPC64.HasDARN = isSet(ppc64x_hwcap2, _PPC_FEATURE2_DARN)
49-
PPC64.HasSCV = isSet(ppc64x_hwcap2, _PPC_FEATURE2_SCV)
42+
PPC64.IsPOWER8 = isSet(hwcap2, _PPC_FEATURE2_ARCH_2_07)
43+
PPC64.HasHTM = isSet(hwcap2, _PPC_FEATURE2_HAS_HTM)
44+
PPC64.HasISEL = isSet(hwcap2, _PPC_FEATURE2_HAS_ISEL)
45+
PPC64.HasVCRYPTO = isSet(hwcap2, _PPC_FEATURE2_HAS_VEC_CRYPTO)
46+
PPC64.HasHTMNOSC = isSet(hwcap2, _PPC_FEATURE2_HTM_NOSC)
47+
PPC64.IsPOWER9 = isSet(hwcap2, _PPC_FEATURE2_ARCH_3_00)
48+
PPC64.HasDARN = isSet(hwcap2, _PPC_FEATURE2_DARN)
49+
PPC64.HasSCV = isSet(hwcap2, _PPC_FEATURE2_SCV)
5050
}
5151

5252
func isSet(hwc uint, value uint) bool {

src/runtime/os_linux_arm64.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ var randomNumber uint32
1414
// arm64 doesn't have a 'cpuid' instruction equivalent and relies on
1515
// HWCAP/HWCAP2 bits for hardware capabilities.
1616

17-
//go:linkname cpu_hwcap internal/cpu.arm64_hwcap
17+
//go:linkname cpu_hwcap internal/cpu.hwcap
1818
var cpu_hwcap uint
1919

20-
//go:linkname cpu_hwcap2 internal/cpu.arm64_hwcap2
20+
//go:linkname cpu_hwcap2 internal/cpu.hwcap2
2121
var cpu_hwcap2 uint
2222

2323
func archauxv(tag, val uintptr) {

src/runtime/os_linux_ppc64x.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import _ "unsafe"
1313
// ppc64x doesn't have a 'cpuid' instruction equivalent and relies on
1414
// HWCAP/HWCAP2 bits for hardware capabilities.
1515

16-
//go:linkname cpu_hwcap internal/cpu.ppc64x_hwcap
17-
//go:linkname cpu_hwcap2 internal/cpu.ppc64x_hwcap2
16+
//go:linkname cpu_hwcap internal/cpu.hwcap
1817
var cpu_hwcap uint
18+
19+
//go:linkname cpu_hwcap2 internal/cpu.hwcap2
1920
var cpu_hwcap2 uint
2021

2122
func archauxv(tag, val uintptr) {

0 commit comments

Comments
 (0)