github.com/JimmyHuang454/JLS-go@v0.0.0-20230831150107-90d536585ba0/cpu/cpu_arm64_darwin.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build arm64 && darwin && !ios 6 7 package cpu 8 9 func osInit() { 10 ARM64.HasATOMICS = sysctlEnabled([]byte("hw.optional.armv8_1_atomics\x00")) 11 ARM64.HasCRC32 = sysctlEnabled([]byte("hw.optional.armv8_crc32\x00")) 12 ARM64.HasSHA512 = sysctlEnabled([]byte("hw.optional.armv8_2_sha512\x00")) 13 14 // There are no hw.optional sysctl values for the below features on Mac OS 11.0 15 // to detect their supported state dynamically. Assume the CPU features that 16 // Apple Silicon M1 supports to be available as a minimal set of features 17 // to all Go programs running on darwin/arm64. 18 ARM64.HasAES = true 19 ARM64.HasPMULL = true 20 ARM64.HasSHA1 = true 21 ARM64.HasSHA2 = true 22 } 23 24 //go:noescape 25 func getsysctlbyname(name []byte) (int32, int32) 26 27 func sysctlEnabled(name []byte) bool { 28 ret, value := getsysctlbyname(name) 29 if ret < 0 { 30 return false 31 } 32 return value > 0 33 }