10#include "cpufeatures.h"
19#include <config-processor.h>
21#if defined(__GNUC__) || defined(__INTEL_COMPILER)
22# define HAVE_GNU_INLINE_ASM
33typedef void (*kde_sighandler_t)(int);
35#if defined( __i386__ ) || defined( __x86_64__ )
40static void sighandler(
int)
48#define ASM_REG(reg) "%e" reg
49#define ASM_POP(reg) "popl %%e" reg " \n\t"
50#define ASM_PUSH(reg) "pushl %%e" reg " \n\t"
51#define ASM_XOR_REG(reg1, reg2) "xorl %%e" reg1 ", %%e" reg2 " \n\t"
52#define ASM_XOR_VAR(var, reg) "xorl " var ", %%e" reg " \n\t"
53#define ASM_CMP_REG(reg1, reg2) "cmpl %%e" reg1 ", %%e" reg2 " \n\t"
54#define ASM_MOV_REG(reg1, reg2) "movl %%e" reg1 ", %%e" reg2 " \n\t"
55#define ASM_MOV_VAR(var, reg) "movl " var ", %%e" reg " \n\t"
56#elif defined(__x86_64__)
57#define ASM_REG(reg) "%r" reg
58#define ASM_POP(reg) "popq %%r" reg " \n\t"
59#define ASM_PUSH(reg) "pushq %%r" reg " \n\t"
60#define ASM_XOR_REG(reg1, reg2) "xorq %%r" reg1 ", %%r" reg2 " \n\t"
61#define ASM_XOR_VAR(var, reg) "xorq " var ", %%r" reg " \n\t"
62#define ASM_CMP_REG(reg1, reg2) "cmpq %%r" reg1 ", %%r" reg2 " \n\t"
63#define ASM_MOV_REG(reg1, reg2) "movq %%r" reg1 ", %%r" reg2 " \n\t"
64#define ASM_MOV_VAR(var, reg) "movq " var ", %%r" reg " \n\t"
69static sigjmp_buf jmpbuf;
70static sig_atomic_t canjump = 0;
72static void sigill_handler(
int sig)
79 siglongjmp(jmpbuf, 1);
87#if defined( HAVE_GNU_INLINE_ASM )
88#if defined( __i386__ ) || defined( __x86_64__ )
89 bool haveCPUID =
false;
90 unsigned int result = 0;
91 unsigned int result2 = 0;
98 ASM_MOV_REG(
"cx",
"dx")
99 ASM_XOR_VAR(
"$0x00200000",
"cx")
106 ASM_XOR_REG(
"ax",
"ax")
107 ASM_CMP_REG(
"cx",
"dx")
108 "je .Lno_cpuid_support%= \n\t"
109 ASM_MOV_VAR(
"$1",
"ax")
110 ".Lno_cpuid_support%=: \n\t"
111 :
"=a"(haveCPUID) : : ASM_REG(
"cx"), ASM_REG(
"dx"));
116 __asm__ __volatile__(
118 ASM_MOV_VAR(
"$1",
"ax")
121 :
"=d"(result),
"=c"(result2) : : ASM_REG(
"ax"));
126 __asm__ __volatile__(
129 ASM_MOV_VAR(
"$0x80000000",
"ax")
130 ASM_MOV_VAR(
"$0x80000000",
"dx")
132 ASM_CMP_REG(
"dx",
"ax")
133 "jbe .Lno_extended%= \n\t"
134 ASM_MOV_VAR(
"$0x80000001",
"ax")
136 ".Lno_extended%=: \n\t"
139 :
"=d"(result) : : ASM_REG(
"ax"), ASM_REG(
"cx"));
141 if (result & 0x80000000) {
147 if (features & 0x02000000) {
150 kde_sighandler_t oldhandler = std::signal(SIGILL, sighandler);
156 __asm__ __volatile__(
"xorps %xmm0, %xmm0");
160 std::signal(SIGILL, oldhandler);
167#elif defined __PPC__ && HAVE_PPC_ALTIVEC
168 signal(SIGILL, sigill_handler);
169 if (sigsetjmp(jmpbuf, 1)) {
170 signal(SIGILL, SIG_DFL);
173 __asm__ __volatile__(
"mtspr 256, %0\n\t"
174 "vand %%v0, %%v0, %%v0"
177 signal(SIGILL, SIG_DFL);
181#elif defined(_MSC_VER)
182 int array[4], ft = 1;
188 if (array[3] & 0x80000000) {
194 if (features & 0x80000000) {
195 featureflags |= Solid::Processor::Amd3DNow;
197 if (features & 0x00800000) {
198 featureflags |= Solid::Processor::IntelMmx;
200 if (features & 0x02000000) {
201 featureflags |= Solid::Processor::IntelSse;
203 if (features & 0x04000000) {
204 featureflags |= Solid::Processor::IntelSse2;
206 if (features & 0x00000001) {
207 featureflags |= Solid::Processor::IntelSse3;
209 if (features & 0x00000100) {
210 featureflags |= Solid::Processor::IntelSsse3;
212 if (features & 0x00080000) {
213 featureflags |= Solid::Processor::IntelSse41;
215 if (features & 0x00100000) {
216 featureflags |= Solid::Processor::IntelSse42;
219 if (features & 0x2) {
220 featureflags |= Solid::Processor::AltiVec;
std::vector< Feature > features(QStringView coachNumber, QStringView coachClassification)