1 // Package cpuinfo gives runtime info about the current CPU.
2 //
3 // This is a very limited module meant for use internally
4 // in this project. For more versatile solution check
5 // https://github.com/klauspost/cpuid.
6 package cpuinfo
7 8 // HasBMI1 checks whether an x86 CPU supports the BMI1 extension.
9 func HasBMI1() bool {
10 return hasBMI1
11 }
12 13 // HasBMI2 checks whether an x86 CPU supports the BMI2 extension.
14 func HasBMI2() bool {
15 return hasBMI2
16 }
17 18 // DisableBMI2 will disable BMI2, for testing purposes.
19 // Call returned function to restore previous state.
20 func DisableBMI2() func() {
21 old := hasBMI2
22 hasBMI2 = false
23 return func() {
24 hasBMI2 = old
25 }
26 }
27 28 // HasBMI checks whether an x86 CPU supports both BMI1 and BMI2 extensions.
29 func HasBMI() bool {
30 return HasBMI1() && HasBMI2()
31 }
32 33 var hasBMI1 bool
34 var hasBMI2 bool
35