blob: 3954c51219b2b63cc8d94ce516d2fbd6cf638bc6 [file] [log] [blame]
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +05301// 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.
6package cpuinfo
7
8// HasBMI1 checks whether an x86 CPU supports the BMI1 extension.
9func HasBMI1() bool {
10 return hasBMI1
11}
12
13// HasBMI2 checks whether an x86 CPU supports the BMI2 extension.
14func HasBMI2() bool {
15 return hasBMI2
16}
17
18// DisableBMI2 will disable BMI2, for testing purposes.
19// Call returned function to restore previous state.
20func 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.
29func HasBMI() bool {
30 return HasBMI1() && HasBMI2()
31}
32
33var hasBMI1 bool
34var hasBMI2 bool