mirror of https://github.com/encounter/SDL.git
Fixed bug 2404 - CPU detection not working with MSVC on x64
Tiemo Jung All CPU detection functions SDL_Has* will return false, even if it is supported by the CPU, if SDL is compiled with MSVC and the target is x64. The reason for this is that 'CPU_haveCPUID' will return 0 and macro 'cpuid' in SDL_cpuinfo.c is the fallback implementation, which sets all params to zero. It is safe to assume that cpuid is supported on a CPU that runs windows x64, so CPU_haveCPUID can just return 1, and the empty macro can be replaced with a small wrap around the __cpuid intrinsic.
This commit is contained in:
parent
fea87cc9cf
commit
9cd5f5ceca
|
@ -98,7 +98,7 @@ CPU_haveCPUID(void)
|
||||||
);
|
);
|
||||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||||
/* Technically, if this is being compiled under __x86_64__ then it has
|
/* Technically, if this is being compiled under __x86_64__ then it has
|
||||||
CPUid by definition. But it's nice to be able to prove it. :) */
|
CPUid by definition. But it's nice to be able to prove it. :) */
|
||||||
__asm__ (
|
__asm__ (
|
||||||
" pushfq # Get original EFLAGS \n"
|
" pushfq # Get original EFLAGS \n"
|
||||||
" popq %%rax \n"
|
" popq %%rax \n"
|
||||||
|
@ -131,6 +131,8 @@ CPUid by definition. But it's nice to be able to prove it. :) */
|
||||||
mov has_CPUID,1 ; We have CPUID support
|
mov has_CPUID,1 ; We have CPUID support
|
||||||
done:
|
done:
|
||||||
}
|
}
|
||||||
|
#elif defined(_MSC_VER) && defined(_M_X64)
|
||||||
|
has_CPUID = 1;
|
||||||
#elif defined(__sun) && defined(__i386)
|
#elif defined(__sun) && defined(__i386)
|
||||||
__asm (
|
__asm (
|
||||||
" pushfl \n"
|
" pushfl \n"
|
||||||
|
@ -191,7 +193,17 @@ done:
|
||||||
__asm mov b, ebx \
|
__asm mov b, ebx \
|
||||||
__asm mov c, ecx \
|
__asm mov c, ecx \
|
||||||
__asm mov d, edx \
|
__asm mov d, edx \
|
||||||
}
|
}
|
||||||
|
#elif defined(_MSC_VER) && defined(_M_X64)
|
||||||
|
#define cpuid(func, a, b, c, d) \
|
||||||
|
{ \
|
||||||
|
int CPUInfo[4]; \
|
||||||
|
__cpuid(CPUInfo, func); \
|
||||||
|
a = CPUInfo[0]; \
|
||||||
|
b = CPUInfo[1]; \
|
||||||
|
c = CPUInfo[2]; \
|
||||||
|
d = CPUInfo[3]; \
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#define cpuid(func, a, b, c, d) \
|
#define cpuid(func, a, b, c, d) \
|
||||||
a = b = c = d = 0
|
a = b = c = d = 0
|
||||||
|
|
Loading…
Reference in New Issue