26#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
31#elif defined(__x86_64__) || defined(__i386)
34#if defined(__i386) && defined(__PIC__)
41 __asm__ __volatile__ (
42 "xchgl %%ebx, %1 \n\t"
44 "xchgl %%ebx, %1 \n\t"
45 :
"=a" (info[0]),
"=r" (info[1]),
"=c" (info[2]),
"=d" (info[3])
52 __asm__ __volatile__ (
54 :
"=a" (info[0]),
"=b" (info[1]),
"=c" (info[2]),
"=d" (info[3])
62 info[0] = info[1] = info[2] = info[3] = 0;
65 }
else if (type == 1) {
66#if defined(__SSE4_1__)
80 info[0] = info[1] = info[2] = info[3] = 0;
86 int cpu_info[4] = {-1};
88 uint max_info_type = cpu_info[0];
89 if (max_info_type < type)
return false;
92 return HasBit(cpu_info[index], bit);
Functions related to bit mathematics.
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
bool HasCPUIDFlag(uint type, uint index, uint bit)
Check whether the current CPU has the given flag.
void ottd_cpuid(int info[4], int)
Definitions for CPU detection:
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.