| 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 |
// macOS 12 moved these to the hw.optional.arm tree, but as of Go 1.24 we |
| 11 |
// still support macOS 11. See [Determine Encryption Capabilities]. |
| 12 |
// |
| 13 |
// [Determine Encryption Capabilities]: https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics#3918855 |
| 14 |
ARM64.HasATOMICS = sysctlEnabled([]byte("hw.optional.armv8_1_atomics\x00")) |
| 15 |
ARM64.HasCRC32 = sysctlEnabled([]byte("hw.optional.armv8_crc32\x00")) |
| 16 |
ARM64.HasSHA512 = sysctlEnabled([]byte("hw.optional.armv8_2_sha512\x00")) |
| 17 |
ARM64.HasSHA3 = sysctlEnabled([]byte("hw.optional.armv8_2_sha3\x00")) |
| 18 |
|
| 19 |
ARM64.HasDIT = sysctlEnabled([]byte("hw.optional.arm.FEAT_DIT\x00")) |
| 20 |
|
| 21 |
// There are no hw.optional sysctl values for the below features on macOS 11 |
| 22 |
// to detect their supported state dynamically (although they are available |
| 23 |
// in the hw.optional.arm tree on macOS 12). Assume the CPU features that |
| 24 |
// Apple Silicon M1 supports to be available on all future iterations. |
| 25 |
ARM64.HasAES = true |
| 26 |
ARM64.HasPMULL = true |
| 27 |
ARM64.HasSHA1 = true |
| 28 |
ARM64.HasSHA2 = true |
| 29 |
} |