github.com/primecitizens/pcz/std@v0.2.1/core/cpu/cpu_arm64_openbsd.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  //
     4  // Copyright 2022 The Go Authors. All rights reserved.
     5  // Use of this source code is governed by a BSD-style
     6  // license that can be found in the LICENSE file.
     7  
     8  //go:build arm64 && openbsd
     9  
    10  package cpu
    11  
    12  const (
    13  	// From OpenBSD's sys/sysctl.h.
    14  	_CTL_MACHDEP = 7
    15  
    16  	// From OpenBSD's machine/cpu.h.
    17  	_CPU_ID_AA64ISAR0 = 2
    18  	_CPU_ID_AA64ISAR1 = 3
    19  )
    20  
    21  //go:noescape
    22  func sysctlUint64(mib []uint32) (uint64, bool)
    23  
    24  func osInit() *ARM64Features {
    25  	// Get ID_AA64ISAR0 from sysctl.
    26  	isar0, ok := sysctlUint64([]uint32{_CTL_MACHDEP, _CPU_ID_AA64ISAR0})
    27  	if !ok {
    28  		return &ARM64
    29  	}
    30  
    31  	parseARM64SystemRegisters(isar0)
    32  	return &ARM64
    33  }