]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/os_linux_arm.go
runtime: on arm32, detect whether we have sync instructions
[gostls13.git] / src / runtime / os_linux_arm.go
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 (
8         "internal/cpu"
9         "unsafe"
10 )
11
12 const (
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 func vdsoCall()
18
19 func 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 goarm > 5 && cpu.HWCap&_HWCAP_VFP == 0 {
27                 print("runtime: this CPU has no floating point hardware, so it cannot run\n")
28                 print("this GOARM=", goarm, " binary. Recompile using GOARM=5.\n")
29                 exit(1)
30         }
31         if goarm > 6 && cpu.HWCap&_HWCAP_VFPv3 == 0 {
32                 print("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n")
33                 print("this GOARM=", goarm, " binary. Recompile using GOARM=5 or GOARM=6.\n")
34                 exit(1)
35         }
36 }
37
38 func archauxv(tag, val uintptr) {
39         switch tag {
40         case _AT_HWCAP:
41                 cpu.HWCap = uint(val)
42         case _AT_HWCAP2:
43                 cpu.HWCap2 = uint(val)
44         case _AT_PLATFORM:
45                 cpu.Platform = gostringnocopy((*byte)(unsafe.Pointer(val)))
46         }
47 }
48
49 func osArchInit() {}
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         return nanotime()
56 }