aboutsummaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/sys/cpu/cpu_linux.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-01-11 05:39:12 -0800
committerGitHub <noreply@github.com>2019-01-11 05:39:12 -0800
commitb3eb23d671425775673f86bd02b9c89ef781f590 (patch)
tree5f06e4e289f16d9164d692590a3fe6541b5384cf /vendor/golang.org/x/sys/cpu/cpu_linux.go
parent26f2b7debde313af4a5ae39727c66a3f8fd59be4 (diff)
parentbd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87 (diff)
downloadpodman-b3eb23d671425775673f86bd02b9c89ef781f590.tar.gz
podman-b3eb23d671425775673f86bd02b9c89ef781f590.tar.bz2
podman-b3eb23d671425775673f86bd02b9c89ef781f590.zip
Merge pull request #2102 from vrothberg/vendor-update
vendor: update everything
Diffstat (limited to 'vendor/golang.org/x/sys/cpu/cpu_linux.go')
-rw-r--r--vendor/golang.org/x/sys/cpu/cpu_linux.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux.go b/vendor/golang.org/x/sys/cpu/cpu_linux.go
new file mode 100644
index 000000000..a8452e094
--- /dev/null
+++ b/vendor/golang.org/x/sys/cpu/cpu_linux.go
@@ -0,0 +1,61 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//+build !amd64,!amd64p32,!386
+
+package cpu
+
+import (
+ "encoding/binary"
+ "io/ioutil"
+ "runtime"
+)
+
+const (
+ _AT_HWCAP = 16
+ _AT_HWCAP2 = 26
+
+ procAuxv = "/proc/self/auxv"
+
+ uintSize uint = 32 << (^uint(0) >> 63)
+)
+
+// For those platforms don't have a 'cpuid' equivalent we use HWCAP/HWCAP2
+// These are initialized in cpu_$GOARCH.go
+// and should not be changed after they are initialized.
+var HWCap uint
+var HWCap2 uint
+
+func init() {
+ buf, err := ioutil.ReadFile(procAuxv)
+ if err != nil {
+ panic("read proc auxv failed: " + err.Error())
+ }
+
+ pb := int(uintSize / 8)
+
+ for i := 0; i < len(buf)-pb*2; i += pb * 2 {
+ var tag, val uint
+ switch uintSize {
+ case 32:
+ tag = uint(binary.LittleEndian.Uint32(buf[i:]))
+ val = uint(binary.LittleEndian.Uint32(buf[i+pb:]))
+ case 64:
+ if runtime.GOARCH == "ppc64" {
+ tag = uint(binary.BigEndian.Uint64(buf[i:]))
+ val = uint(binary.BigEndian.Uint64(buf[i+pb:]))
+ } else {
+ tag = uint(binary.LittleEndian.Uint64(buf[i:]))
+ val = uint(binary.LittleEndian.Uint64(buf[i+pb:]))
+ }
+ }
+ switch tag {
+ case _AT_HWCAP:
+ HWCap = val
+ case _AT_HWCAP2:
+ HWCap2 = val
+ }
+ }
+ doinit()
+}