github.com/elijahmorg/goternal@v1.18.0/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 13 // There are no hw.optional sysctl values for the below features on Mac OS 11.0 14 // to detect their supported state dynamically. Assume the CPU features that 15 // Apple Silicon M1 supports to be available as a minimal set of features 16 // to all Go programs running on darwin/arm64. 17 ARM64.HasAES = true 18 ARM64.HasPMULL = true 19 ARM64.HasSHA1 = true 20 ARM64.HasSHA2 = true 21 } 22 23 //go:noescape 24 func getsysctlbyname(name []byte) (int32, int32) 25 26 func sysctlEnabled(name []byte) bool { 27 ret, value := getsysctlbyname(name) 28 if ret < 0 { 29 return false 30 } 31 return value > 0 32 }