github.com/panjjo/go@v0.0.0-20161104043856-d62b31386338/src/runtime/os_linux_arm.go (about)

     1  // Copyright 2009 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 "unsafe"
     8  
     9  const (
    10  	_AT_PLATFORM = 15 //  introduced in at least 2.6.11
    11  
    12  	_HWCAP_VFP   = 1 << 6  // introduced in at least 2.6.11
    13  	_HWCAP_VFPv3 = 1 << 13 // introduced in 2.6.30
    14  )
    15  
    16  var randomNumber uint32
    17  var armArch uint8 = 6 // we default to ARMv6
    18  var hwcap uint32      // set by setup_auxv
    19  
    20  func checkgoarm() {
    21  	if goarm > 5 && hwcap&_HWCAP_VFP == 0 {
    22  		print("runtime: this CPU has no floating point hardware, so it cannot run\n")
    23  		print("this GOARM=", goarm, " binary. Recompile using GOARM=5.\n")
    24  		exit(1)
    25  	}
    26  	if goarm > 6 && hwcap&_HWCAP_VFPv3 == 0 {
    27  		print("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n")
    28  		print("this GOARM=", goarm, " binary. Recompile using GOARM=5.\n")
    29  		exit(1)
    30  	}
    31  }
    32  
    33  func archauxv(tag, val uintptr) {
    34  	switch tag {
    35  	case _AT_RANDOM:
    36  		// sysargs filled in startupRandomData, but that
    37  		// pointer may not be word aligned, so we must treat
    38  		// it as a byte array.
    39  		randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
    40  			uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
    41  
    42  	case _AT_PLATFORM: // v5l, v6l, v7l
    43  		t := *(*uint8)(unsafe.Pointer(val + 1))
    44  		if '5' <= t && t <= '7' {
    45  			armArch = t - '0'
    46  		}
    47  
    48  	case _AT_HWCAP: // CPU capability bit flags
    49  		hwcap = uint32(val)
    50  	}
    51  }
    52  
    53  //go:nosplit
    54  func cputicks() int64 {
    55  	// Currently cputicks() is used in blocking profiler and to seed fastrand().
    56  	// nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
    57  	// randomNumber provides better seeding of fastrand.
    58  	return nanotime() + int64(randomNumber)
    59  }