diff options
Diffstat (limited to 'cpu/hwcap_linux.go')
-rw-r--r-- | cpu/hwcap_linux.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cpu/hwcap_linux.go b/cpu/hwcap_linux.go index f3baa37..1d9d91f 100644 --- a/cpu/hwcap_linux.go +++ b/cpu/hwcap_linux.go @@ -24,6 +24,21 @@ var hwCap uint var hwCap2 uint func readHWCAP() error { + // For Go 1.21+, get auxv from the Go runtime. + if a := getAuxv(); len(a) > 0 { + for len(a) >= 2 { + tag, val := a[0], uint(a[1]) + a = a[2:] + switch tag { + case _AT_HWCAP: + hwCap = val + case _AT_HWCAP2: + hwCap2 = val + } + } + return nil + } + buf, err := ioutil.ReadFile(procAuxv) if err != nil { // e.g. on android /proc/self/auxv is not accessible, so silently |