Skip to content

Commit

Permalink
internal/cpu: add sha512 for arm64
Browse files Browse the repository at this point in the history
The new M1 cpu (Apple) comes with sha512 hardware
acceleration feature.

Change-Id: I823d1e9b09b472bd21571eee75cc5314cd66b1ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/408836
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
mengzhuo committed Aug 9, 2022
1 parent 4884599 commit 228f891
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/internal/cpu/cpu.go
Expand Up @@ -61,6 +61,7 @@ var ARM64 struct {
HasPMULL bool
HasSHA1 bool
HasSHA2 bool
HasSHA512 bool
HasCRC32 bool
HasATOMICS bool
HasCPUID bool
Expand Down
1 change: 1 addition & 0 deletions src/internal/cpu/cpu_arm64.go
Expand Up @@ -12,6 +12,7 @@ func doinit() {
{Name: "pmull", Feature: &ARM64.HasPMULL},
{Name: "sha1", Feature: &ARM64.HasSHA1},
{Name: "sha2", Feature: &ARM64.HasSHA2},
{Name: "sha512", Feature: &ARM64.HasSHA512},
{Name: "crc32", Feature: &ARM64.HasCRC32},
{Name: "atomics", Feature: &ARM64.HasATOMICS},
{Name: "cpuid", Feature: &ARM64.HasCPUID},
Expand Down
1 change: 1 addition & 0 deletions src/internal/cpu/cpu_arm64_darwin.go
Expand Up @@ -9,6 +9,7 @@ package cpu
func osInit() {
ARM64.HasATOMICS = sysctlEnabled([]byte("hw.optional.armv8_1_atomics\x00"))
ARM64.HasCRC32 = sysctlEnabled([]byte("hw.optional.armv8_crc32\x00"))
ARM64.HasSHA512 = sysctlEnabled([]byte("hw.optional.armv8_2_sha512\x00"))

// There are no hw.optional sysctl values for the below features on Mac OS 11.0
// to detect their supported state dynamically. Assume the CPU features that
Expand Down

0 comments on commit 228f891

Please sign in to comment.