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