github.com/megatontech/mynoteforgo@v0.0.0-20200507084910-5d0c6ea6e890/源码/runtime/os_freebsd_arm.go (about)

     1  // Copyright 2012 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  package runtime
     6  
     7  import "internal/cpu"
     8  
     9  const (
    10  	_HWCAP_VFP   = 1 << 6
    11  	_HWCAP_VFPv3 = 1 << 13
    12  )
    13  
    14  // AT_HWCAP is not available on FreeBSD-11.1-RELEASE or earlier.
    15  // Default to mandatory VFP hardware support for arm being available.
    16  // If AT_HWCAP is available goarmHWCap will be updated in archauxv.
    17  // TODO(moehrmann) remove once all go supported FreeBSD versions support _AT_HWCAP.
    18  var goarmHWCap uint = (_HWCAP_VFP | _HWCAP_VFPv3)
    19  
    20  func checkgoarm() {
    21  	// Update cpu.HWCap to match goarmHWCap in case they were not updated in archauxv.
    22  	cpu.HWCap = goarmHWCap
    23  
    24  	if goarm > 5 && cpu.HWCap&_HWCAP_VFP == 0 {
    25  		print("runtime: this CPU has no floating point hardware, so it cannot run\n")
    26  		print("this GOARM=", goarm, " binary. Recompile using GOARM=5.\n")
    27  		exit(1)
    28  	}
    29  	if goarm > 6 && cpu.HWCap&_HWCAP_VFPv3 == 0 {
    30  		print("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n")
    31  		print("this GOARM=", goarm, " binary. Recompile using GOARM=5 or GOARM=6.\n")
    32  		exit(1)
    33  	}
    34  
    35  	// osinit not called yet, so ncpu not set: must use getncpu directly.
    36  	if getncpu() > 1 && goarm < 7 {
    37  		print("runtime: this system has multiple CPUs and must use\n")
    38  		print("atomic synchronization instructions. Recompile using GOARM=7.\n")
    39  		exit(1)
    40  	}
    41  }
    42  
    43  func archauxv(tag, val uintptr) {
    44  	switch tag {
    45  	case _AT_HWCAP:
    46  		cpu.HWCap = uint(val)
    47  		goarmHWCap = cpu.HWCap
    48  	case _AT_HWCAP2:
    49  		cpu.HWCap2 = uint(val)
    50  	}
    51  }
    52  
    53  //go:nosplit
    54  func cputicks() int64 {
    55  	// Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
    56  	// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
    57  	// TODO: need more entropy to better seed fastrand.
    58  	return nanotime()
    59  }