github.com/megatontech/mynoteforgo@v0.0.0-20200507084910-5d0c6ea6e890/源码/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 "internal/cpu" 8 9 const ( 10 _HWCAP_VFP = 1 << 6 // introduced in at least 2.6.11 11 _HWCAP_VFPv3 = 1 << 13 // introduced in 2.6.30 12 ) 13 14 var randomNumber uint32 15 16 func checkgoarm() { 17 // On Android, /proc/self/auxv might be unreadable and hwcap won't 18 // reflect the CPU capabilities. Assume that every Android arm device 19 // has the necessary floating point hardware available. 20 if GOOS == "android" { 21 return 22 } 23 if goarm > 5 && cpu.HWCap&_HWCAP_VFP == 0 { 24 print("runtime: this CPU has no floating point hardware, so it cannot run\n") 25 print("this GOARM=", goarm, " binary. Recompile using GOARM=5.\n") 26 exit(1) 27 } 28 if goarm > 6 && cpu.HWCap&_HWCAP_VFPv3 == 0 { 29 print("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n") 30 print("this GOARM=", goarm, " binary. Recompile using GOARM=5 or GOARM=6.\n") 31 exit(1) 32 } 33 } 34 35 func archauxv(tag, val uintptr) { 36 switch tag { 37 case _AT_RANDOM: 38 // sysargs filled in startupRandomData, but that 39 // pointer may not be word aligned, so we must treat 40 // it as a byte array. 41 randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 | 42 uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24 43 44 case _AT_HWCAP: 45 cpu.HWCap = uint(val) 46 case _AT_HWCAP2: 47 cpu.HWCap2 = uint(val) 48 } 49 } 50 51 //go:nosplit 52 func cputicks() int64 { 53 // Currently cputicks() is used in blocking profiler and to seed fastrand(). 54 // nanotime() is a poor approximation of CPU ticks that is enough for the profiler. 55 // randomNumber provides better seeding of fastrand. 56 return nanotime() + int64(randomNumber) 57 }