36#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
37 __cpuid(info.data(), type);
38#elif defined(__i386) && defined(__PIC__)
45 __asm__ __volatile__ (
46 "xchgl %%ebx, %1 \n\t"
48 "xchgl %%ebx, %1 \n\t"
49 :
"=a" (info[0]),
"=r" (info[1]),
"=c" (info[2]),
"=d" (info[3])
55#elif defined(__x86_64__) || defined(__i386)
56 __asm__ __volatile__ (
58 :
"=a" (info[0]),
"=b" (info[1]),
"=c" (info[2]),
"=d" (info[3])
64 }
else if (type == 1) {
65# if defined(__SSE4_1__)
68# if defined(__SSSE3__)
83 uint max_info_type = cpu_info[0];
84 if (max_info_type < type)
return false;
86 cpu_info =
CPUID(type);
87 return HasBit(cpu_info[index], bit);
Functions related to bit mathematics.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
std::array< int, 4 > CPUIDArray
Container for CPUID information.
bool HasCPUIDFlag(uint type, uint index, uint bit)
Check whether the current CPU has the given flag.
static CPUIDArray CPUID(int type)
Get the CPUID information from the CPU.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.