1 // Copyright 2019 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.
15 procAuxv = "/proc/self/auxv"
17 uintSize = int(32 << (^uint(0) >> 63))
20 // For those platforms don't have a 'cpuid' equivalent we use HWCAP/HWCAP2
21 // These are initialized in cpu_$GOARCH.go
22 // and should not be changed after they are initialized.
26 func readHWCAP() error {
27 buf, err := ioutil.ReadFile(procAuxv)
29 // e.g. on android /proc/self/auxv is not accessible, so silently
30 // ignore the error and leave Initialized = false. On some
31 // architectures (e.g. arm64) doinit() implements a fallback
32 // readout and will set Initialized = true again.
36 for len(buf) >= 2*(uintSize/8) {
40 tag = uint(bo.Uint32(buf[0:]))
41 val = uint(bo.Uint32(buf[4:]))
44 tag = uint(bo.Uint64(buf[0:]))
45 val = uint(bo.Uint64(buf[8:]))