]> Cypherpunks repositories - gostls13.git/commitdiff
internal/cpu: add sha512 for arm64
authorMeng Zhuo <mzh@golangcn.org>
Thu, 26 May 2022 14:36:15 +0000 (22:36 +0800)
committerMeng Zhuo <mzh@golangcn.org>
Tue, 9 Aug 2022 01:22:19 +0000 (01:22 +0000)
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>

src/internal/cpu/cpu.go
src/internal/cpu/cpu_arm64.go
src/internal/cpu/cpu_arm64_darwin.go

index ae23b59617a4febfa023f5c6ea656e5be721d219..c02dadccf6fd8f308020330a4366ee7d17c76aba 100644 (file)
@@ -61,6 +61,7 @@ var ARM64 struct {
        HasPMULL     bool
        HasSHA1      bool
        HasSHA2      bool
+       HasSHA512    bool
        HasCRC32     bool
        HasATOMICS   bool
        HasCPUID     bool
index f64d9e4dd3100a709aa0c682d61932a3d6259297..d02c9b99d06657c39798f1e8612fe53a94c5cd51 100644 (file)
@@ -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},
index 730e14caff09a9ac4e437127ff381cbafa21c337..60beadddbb1d606a4b1ff650160d54dc80703914 100644 (file)
@@ -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