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
5package runtime
6
7import (
8	"internal/cpu"
9	"unsafe"
10)
11
12const (
13	_HWCAP_VFP   = 1 << 6  // introduced in at least 2.6.11
14	_HWCAP_VFPv3 = 1 << 13 // introduced in 2.6.30
15)
16
17func vdsoCall()
18
19func checkgoarm() {
20	// On Android, /proc/self/auxv might be unreadable and hwcap won't
21	// reflect the CPU capabilities. Assume that every Android arm device
22	// has the necessary floating point hardware available.
23	if GOOS == "android" {
24		return
25	}
26	if cpu.HWCap&_HWCAP_VFP == 0 && goarmsoftfp == 0 {
27		print("runtime: this CPU has no floating point hardware, so it cannot run\n")
28		print("a binary compiled for hard floating point. Recompile adding ,softfloat\n")
29		print("to GOARM.\n")
30		exit(1)
31	}
32	if goarm > 6 && cpu.HWCap&_HWCAP_VFPv3 == 0 && goarmsoftfp == 0 {
33		print("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n")
34		print("a binary compiled for VFPv3 hard floating point. Recompile adding ,softfloat\n")
35		print("to GOARM or changing GOARM to 6.\n")
36		exit(1)
37	}
38}
39
40func archauxv(tag, val uintptr) {
41	switch tag {
42	case _AT_HWCAP:
43		cpu.HWCap = uint(val)
44	case _AT_HWCAP2:
45		cpu.HWCap2 = uint(val)
46	case _AT_PLATFORM:
47		cpu.Platform = gostringnocopy((*byte)(unsafe.Pointer(val)))
48	}
49}
50
51func osArchInit() {}
52
53//go:nosplit
54func cputicks() int64 {
55	// nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
56	return nanotime()
57}
58