Black Lives Matter. Support the Equal Justice Initiative.

Source file src/internal/cpu/cpu_arm64_darwin.go

Documentation: internal/cpu

     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  // +build arm64
     6  // +build darwin
     7  // +build !ios
     8  
     9  package cpu
    10  
    11  func osInit() {
    12  	ARM64.HasATOMICS = sysctlEnabled([]byte("hw.optional.armv8_1_atomics\x00"))
    13  	ARM64.HasCRC32 = sysctlEnabled([]byte("hw.optional.armv8_crc32\x00"))
    14  
    15  	// There are no hw.optional sysctl values for the below features on Mac OS 11.0
    16  	// to detect their supported state dynamically. Assume the CPU features that
    17  	// Apple Silicon M1 supports to be available as a minimal set of features
    18  	// to all Go programs running on darwin/arm64.
    19  	ARM64.HasAES = true
    20  	ARM64.HasPMULL = true
    21  	ARM64.HasSHA1 = true
    22  	ARM64.HasSHA2 = true
    23  }
    24  
    25  //go:noescape
    26  func getsysctlbyname(name []byte) (int32, int32)
    27  
    28  func sysctlEnabled(name []byte) bool {
    29  	ret, value := getsysctlbyname(name)
    30  	if ret < 0 {
    31  		return false
    32  	}
    33  	return value > 0
    34  }
    35  

View as plain text