mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Replaced some win32 cpuid code.
This commit is contained in:
parent
12d31f5203
commit
47aad5a8e7
2 changed files with 48 additions and 52 deletions
|
|
@ -114,6 +114,7 @@ static String getAllSystemInfo()
|
|||
<< "CPU has MMX: " << (SystemStats::hasMMX() ? "yes" : "no") << newLine
|
||||
<< "CPU has SSE: " << (SystemStats::hasSSE() ? "yes" : "no") << newLine
|
||||
<< "CPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") << newLine
|
||||
<< "CPU has SSE3: " << (SystemStats::hasSSE3() ? "yes" : "no") << newLine
|
||||
<< "CPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") << newLine
|
||||
<< newLine
|
||||
<< "Current working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << newLine
|
||||
|
|
|
|||
|
|
@ -45,10 +45,46 @@ void Logger::outputDebugString (const String& text)
|
|||
#pragma intrinsic (__cpuid)
|
||||
#pragma intrinsic (__rdtsc)
|
||||
|
||||
static void callCPUID (int result[4], int infoType)
|
||||
{
|
||||
__cpuid (result, infoType);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void callCPUID (int result[4], int infoType)
|
||||
{
|
||||
#if ! JUCE_MINGW
|
||||
__try
|
||||
#endif
|
||||
{
|
||||
#if JUCE_GCC
|
||||
__asm__ __volatile__ ("cpuid" : "=a" (result[0]), "=b" (result[1]), "=c" (result[2]),"=d" (result[3]) : "a" (infoType));
|
||||
#else
|
||||
__asm
|
||||
{
|
||||
mov esi, result
|
||||
mov eax, infoType
|
||||
xor ecx, ecx
|
||||
cpuid
|
||||
mov dword ptr [esi + 0], eax
|
||||
mov dword ptr [esi + 4], ebx
|
||||
mov dword ptr [esi + 8], ecx
|
||||
mov dword ptr [esi + 12], edx
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if ! JUCE_MINGW
|
||||
__except (EXCEPTION_EXECUTE_HANDLER) {}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
String SystemStats::getCpuVendor()
|
||||
{
|
||||
int info [4];
|
||||
__cpuid (info, 0);
|
||||
int info[4] = { 0 };
|
||||
callCPUID (info, 0);
|
||||
|
||||
char v [12];
|
||||
memcpy (v, info + 1, 4);
|
||||
|
|
@ -58,59 +94,18 @@ String SystemStats::getCpuVendor()
|
|||
return String (v, 12);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//==============================================================================
|
||||
// CPU info functions using old fashioned inline asm...
|
||||
|
||||
static void juce_getCpuVendor (char* const v)
|
||||
{
|
||||
int vendor[4] = { 0 };
|
||||
|
||||
#if ! JUCE_MINGW
|
||||
__try
|
||||
#endif
|
||||
{
|
||||
#if JUCE_GCC
|
||||
unsigned int dummy = 0;
|
||||
__asm__ ("cpuid" : "=a" (dummy), "=b" (vendor[0]), "=c" (vendor[2]),"=d" (vendor[1]) : "a" (0));
|
||||
#else
|
||||
__asm
|
||||
{
|
||||
mov eax, 0
|
||||
cpuid
|
||||
mov [vendor], ebx
|
||||
mov [vendor + 4], edx
|
||||
mov [vendor + 8], ecx
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if ! JUCE_MINGW
|
||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
memcpy (v, vendor, 16);
|
||||
}
|
||||
|
||||
String SystemStats::getCpuVendor()
|
||||
{
|
||||
char v [16];
|
||||
juce_getCpuVendor (v);
|
||||
return String (v, 16);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//==============================================================================
|
||||
void CPUInformation::initialise() noexcept
|
||||
{
|
||||
hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0;
|
||||
hasSSE = IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0;
|
||||
hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0;
|
||||
hasSSE3 = IsProcessorFeaturePresent (13 /*PF_SSE3_INSTRUCTIONS_AVAILABLE*/) != 0;
|
||||
has3DNow = IsProcessorFeaturePresent (7 /*PF_AMD3D_INSTRUCTIONS_AVAILABLE*/) != 0;
|
||||
int info[4] = { 0 };
|
||||
callCPUID (info, 1);
|
||||
|
||||
// NB: IsProcessorFeaturePresent doesn't work on XP
|
||||
hasMMX = (info[3] & (1 << 23)) != 0;
|
||||
hasSSE = (info[3] & (1 << 25)) != 0;
|
||||
hasSSE2 = (info[3] & (1 << 26)) != 0;
|
||||
hasSSE3 = (info[2] & (1 << 0)) != 0;
|
||||
has3DNow = (info[1] & (1 << 31)) != 0;
|
||||
|
||||
SYSTEM_INFO systemInfo;
|
||||
GetNativeSystemInfo (&systemInfo);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue