18 static inline void cpuid (
int output[4],
int functionnumber) {
19 #if defined (_MSC_VER) || defined (__INTEL_COMPILER) // Microsoft or Intel compiler, intrin.h included
21 __cpuidex(output, functionnumber, 0);
23 #elif defined(__GNUC__) || defined(__clang__) // use inline assembly, Gnu/AT&T syntax
26 __asm(
"cpuid" :
"=a"(a),
"=b"(b),
"=c"(c),
"=d"(d) :
"a"(functionnumber),
"c"(0) : );
32 #else // unknown platform. try inline assembly with masm/intel syntax
35 mov eax, functionnumber
49 static inline int64_t xgetbv (
int ctr) {
50 #if (defined (_MSC_FULL_VER) && _MSC_FULL_VER >= 160040000) || (defined (__INTEL_COMPILER) && __INTEL_COMPILER >= 1200) // Microsoft or Intel compiler supporting _xgetbv intrinsic
54 #elif defined(__GNUC__) // use inline assembly, Gnu/AT&T syntax
57 __asm(
"xgetbv" :
"=a"(a),
"=d"(d) :
"c"(ctr) : );
60 #else // #elif defined (_WIN32) // other compiler. try inline assembly with masm/intel/MS syntax
97 int abcd[4] = {0,0,0,0};
99 if (abcd[0] == 0)
return iset;
101 if ((abcd[3] & (1 << 0)) == 0)
return iset;
102 if ((abcd[3] & (1 << 23)) == 0)
return iset;
103 if ((abcd[3] & (1 << 15)) == 0)
return iset;
104 if ((abcd[3] & (1 << 24)) == 0)
return iset;
105 if ((abcd[3] & (1 << 25)) == 0)
return iset;
107 if ((abcd[3] & (1 << 26)) == 0)
return iset;
109 if ((abcd[2] & (1 << 0)) == 0)
return iset;
111 if ((abcd[2] & (1 << 9)) == 0)
return iset;
113 if ((abcd[2] & (1 << 19)) == 0)
return iset;
115 if ((abcd[2] & (1 << 23)) == 0)
return iset;
116 if ((abcd[2] & (1 << 20)) == 0)
return iset;
118 if ((abcd[2] & (1 << 27)) == 0)
return iset;
119 if ((xgetbv(0) & 6) != 6)
return iset;
120 if ((abcd[2] & (1 << 28)) == 0)
return iset;
123 if ((abcd[1] & (1 << 5)) == 0)
return iset;
126 if ((abcd[0] & 0x60) != 0x60)
return iset;
136 return ((abcd[2] & (1 << 12)) != 0);
143 cpuid(abcd, 0x80000001);
144 return ((abcd[2] & (1 << 16)) != 0);
151 cpuid(abcd, 0x80000001);
152 return ((abcd[2] & (1 << 11)) != 0);