aboutsummaryrefslogtreecommitdiff
path: root/internal/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cpu')
-rw-r--r--internal/cpu/cpu.go2
-rw-r--r--internal/cpu/cpu_amd64.go3
2 files changed, 4 insertions, 1 deletions
diff --git a/internal/cpu/cpu.go b/internal/cpu/cpu.go
index dd7680cb..41a0c1f9 100644
--- a/internal/cpu/cpu.go
+++ b/internal/cpu/cpu.go
@@ -1,6 +1,8 @@
package cpu
// X86 contains x86 CPU feature flags detected at runtime.
+//
+//nolint:gochecknoglobals
var X86 struct {
HasAVX2 bool
}
diff --git a/internal/cpu/cpu_amd64.go b/internal/cpu/cpu_amd64.go
index f20c810a..7fe59633 100644
--- a/internal/cpu/cpu_amd64.go
+++ b/internal/cpu/cpu_amd64.go
@@ -14,7 +14,7 @@ func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
// xgetbv with ecx = 0 is implemented in cpu_amd64.s.
func xgetbv() (eax, edx uint32)
-func init() {
+func init() { //nolint:gochecknoinits
maxID, _, _, _ := cpuid(0, 0)
if maxID < 7 {
return
@@ -23,6 +23,7 @@ func init() {
_, _, ecx1, _ := cpuid(1, 0)
osSupportsAVX := false
+
if ecx1&cpuidOSXSAVE != 0 {
eax, _ := xgetbv()
osSupportsAVX = eax&(1<<1) != 0 && eax&(1<<2) != 0