Skip to content

Commit 96f3fa4

Browse files
committed
internal/cpu: add ARM64.HasSHA3
For golang#69536 Change-Id: If237226ba03e282443b4fc90484968c903198cb1
1 parent ae9387d commit 96f3fa4

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/internal/cpu/cpu.go

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ var ARM64 struct {
7070
HasSHA1 bool
7171
HasSHA2 bool
7272
HasSHA512 bool
73+
HasSHA3 bool
7374
HasCRC32 bool
7475
HasATOMICS bool
7576
HasCPUID bool

src/internal/cpu/cpu_arm64_darwin.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,21 @@ package cpu
99
import _ "unsafe" // for linkname
1010

1111
func osInit() {
12+
// macOS 12 moved these to the hw.optional.arm tree, but as of Go 1.24 we
13+
// still support macOS 11. See [Determine Encryption Capabilities].
14+
//
15+
// [Determine Encryption Capabilities]: https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics#3918855
1216
ARM64.HasATOMICS = sysctlEnabled([]byte("hw.optional.armv8_1_atomics\x00"))
1317
ARM64.HasCRC32 = sysctlEnabled([]byte("hw.optional.armv8_crc32\x00"))
1418
ARM64.HasSHA512 = sysctlEnabled([]byte("hw.optional.armv8_2_sha512\x00"))
19+
ARM64.HasSHA3 = sysctlEnabled([]byte("hw.optional.armv8_2_sha3\x00"))
20+
1521
ARM64.HasDIT = sysctlEnabled([]byte("hw.optional.arm.FEAT_DIT\x00"))
1622

17-
// There are no hw.optional sysctl values for the below features on Mac OS 11.0
18-
// to detect their supported state dynamically. Assume the CPU features that
19-
// Apple Silicon M1 supports to be available as a minimal set of features
20-
// to all Go programs running on darwin/arm64.
23+
// There are no hw.optional sysctl values for the below features on macOS 11
24+
// to detect their supported state dynamically (although they are available
25+
// in the hw.optional.arm tree on macOS 12). Assume the CPU features that
26+
// Apple Silicon M1 supports to be available on all future iterations.
2127
ARM64.HasAES = true
2228
ARM64.HasPMULL = true
2329
ARM64.HasSHA1 = true

0 commit comments

Comments
 (0)