1
2
3
4
5 package cpu
6
7 const CacheLinePadSize = 32
8
9
10
11
12 var HWCap uint
13 var HWCap2 uint
14 var Platform string
15
16
17 const (
18 hwcap_VFPv4 = 1 << 16
19 hwcap_IDIVA = 1 << 17
20 hwcap_LPAE = 1 << 20
21 )
22
23 func doinit() {
24 options = []option{
25 {Name: "vfpv4", Feature: &ARM.HasVFPv4},
26 {Name: "idiva", Feature: &ARM.HasIDIVA},
27 {Name: "v7atomics", Feature: &ARM.HasV7Atomics},
28 }
29
30
31 ARM.HasVFPv4 = isSet(HWCap, hwcap_VFPv4)
32 ARM.HasIDIVA = isSet(HWCap, hwcap_IDIVA)
33
34
35
36 ARM.HasV7Atomics = isSet(HWCap, hwcap_LPAE) && isV7(Platform)
37 }
38
39 func isSet(hwc uint, value uint) bool {
40 return hwc&value != 0
41 }
42
43 func isV7(s string) bool {
44 if s == "aarch64" {
45 return true
46 }
47 return s >= "v7"
48 }
49
View as plain text