summaryrefslogtreecommitdiff
path: root/vendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo.go
blob: 3954c51219b2b63cc8d94ce516d2fbd6cf638bc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Package cpuinfo gives runtime info about the current CPU.
//
// This is a very limited module meant for use internally
// in this project. For more versatile solution check
// https://github.com/klauspost/cpuid.
package cpuinfo

// HasBMI1 checks whether an x86 CPU supports the BMI1 extension.
func HasBMI1() bool {
	return hasBMI1
}

// HasBMI2 checks whether an x86 CPU supports the BMI2 extension.
func HasBMI2() bool {
	return hasBMI2
}

// DisableBMI2 will disable BMI2, for testing purposes.
// Call returned function to restore previous state.
func DisableBMI2() func() {
	old := hasBMI2
	hasBMI2 = false
	return func() {
		hasBMI2 = old
	}
}

// HasBMI checks whether an x86 CPU supports both BMI1 and BMI2 extensions.
func HasBMI() bool {
	return HasBMI1() && HasBMI2()
}

var hasBMI1 bool
var hasBMI2 bool