1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-08 04:20:09 +00:00

Minor clean-ups.

This commit is contained in:
Julian Storer 2010-06-10 12:26:43 +01:00
parent 6bcc8febca
commit 419aac8074
58 changed files with 656 additions and 743 deletions

View file

@ -68,11 +68,6 @@ static const String juce_getCpuInfo (const char* const key)
return String::empty;
}
bool SystemStats::hasMMX() { return juce_getCpuInfo ("flags").contains ("mmx"); }
bool SystemStats::hasSSE() { return juce_getCpuInfo ("flags").contains ("sse"); }
bool SystemStats::hasSSE2() { return juce_getCpuInfo ("flags").contains ("sse2"); }
bool SystemStats::has3DNow() { return juce_getCpuInfo ("flags").contains ("3dnow"); }
const String SystemStats::getCpuVendor()
{
return juce_getCpuInfo ("vendor_id");
@ -98,11 +93,6 @@ int SystemStats::getPageSize()
return sysconf (_SC_PAGESIZE);
}
int SystemStats::getNumCpus()
{
return juce_getCpuInfo ("processor").getIntValue() + 1;
}
//==============================================================================
const String SystemStats::getLogonName()
{
@ -126,6 +116,13 @@ const String SystemStats::getFullUserName()
//==============================================================================
void SystemStats::initialiseStats()
{
const String flags (juce_getCpuInfo ("flags"));
cpuFlags.hasMMX = flags.contains ("mmx");
cpuFlags.hasSSE = flags.contains ("sse");
cpuFlags.hasSSE2 = flags.contains ("sse2");
cpuFlags.has3DNow = flags.contains ("3dnow");
cpuFlags.numCpus = juce_getCpuInfo ("processor").getIntValue() + 1;
}
void PlatformUtilities::fpuReset()

View file

@ -65,16 +65,6 @@ namespace SystemStatsHelpers
return cpu;
}
struct CPUFlags
{
bool hasMMX : 1;
bool hasSSE : 1;
bool hasSSE2 : 1;
bool has3DNow : 1;
};
static CPUFlags cpuFlags;
#endif
}
@ -88,16 +78,15 @@ void SystemStats::initialiseStats()
{
initialised = true;
#if JUCE_MAC
// extremely annoying: adding this line stops the apple menu items from working. Of
// course, not adding it means that carbon windows (e.g. in plugins) won't get
// any events.
//NSApplicationLoad();
[NSApplication sharedApplication];
#endif
#if JUCE_MAC
// extremely annoying: adding this line stops the apple menu items from working. Of
// course, not adding it means that carbon windows (e.g. in plugins) won't get
// any events.
//NSApplicationLoad();
[NSApplication sharedApplication];
#endif
#if JUCE_INTEL
{
#if JUCE_INTEL
unsigned int familyModel, extFeatures;
const unsigned int features = getCPUIDWord (familyModel, extFeatures);
@ -105,8 +94,18 @@ void SystemStats::initialiseStats()
cpuFlags.hasSSE = ((features & (1 << 25)) != 0);
cpuFlags.hasSSE2 = ((features & (1 << 26)) != 0);
cpuFlags.has3DNow = ((extFeatures & (1 << 31)) != 0);
}
#endif
#else
cpuFlags.hasMMX = false;
cpuFlags.hasSSE = false;
cpuFlags.hasSSE2 = false;
cpuFlags.has3DNow = false;
#endif
#if JUCE_IPHONE || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
cpuFlags.numCpus = (int) [[NSProcessInfo processInfo] activeProcessorCount];
#else
cpuFlags.numCpus = (int) MPProcessors();
#endif
mach_timebase_info_data_t timebase;
(void) mach_timebase_info (&timebase);
@ -152,42 +151,6 @@ int SystemStats::getMemorySizeInMegabytes()
return (int) (mem / (1024 * 1024));
}
bool SystemStats::hasMMX()
{
#if JUCE_INTEL
return SystemStatsHelpers::cpuFlags.hasMMX;
#else
return false;
#endif
}
bool SystemStats::hasSSE()
{
#if JUCE_INTEL
return SystemStatsHelpers::cpuFlags.hasSSE;
#else
return false;
#endif
}
bool SystemStats::hasSSE2()
{
#if JUCE_INTEL
return SystemStatsHelpers::cpuFlags.hasSSE2;
#else
return false;
#endif
}
bool SystemStats::has3DNow()
{
#if JUCE_INTEL
return SystemStatsHelpers::cpuFlags.has3DNow;
#else
return false;
#endif
}
const String SystemStats::getCpuVendor()
{
#if JUCE_INTEL
@ -213,15 +176,6 @@ int SystemStats::getCpuSpeedInMegaherz()
return (int) (speedHz / 1000000);
}
int SystemStats::getNumCpus()
{
#if JUCE_IPHONE || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
return (int) [[NSProcessInfo processInfo] activeProcessorCount];
#else
return MPProcessors();
#endif
}
//==============================================================================
const String SystemStats::getLogonName()
{

View file

@ -113,36 +113,6 @@ const String SystemStats::getCpuVendor()
//==============================================================================
struct CPUFlags
{
bool hasMMX : 1;
bool hasSSE : 1;
bool hasSSE2 : 1;
bool has3DNow : 1;
};
static CPUFlags cpuFlags;
bool SystemStats::hasMMX()
{
return cpuFlags.hasMMX;
}
bool SystemStats::hasSSE()
{
return cpuFlags.hasSSE;
}
bool SystemStats::hasSSE2()
{
return cpuFlags.hasSSE2;
}
bool SystemStats::has3DNow()
{
return cpuFlags.has3DNow;
}
void SystemStats::initialiseStats()
{
juce_initialiseThreadEvents();
@ -156,6 +126,12 @@ void SystemStats::initialiseStats()
cpuFlags.has3DNow = IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE) != 0;
#endif
{
SYSTEM_INFO systemInfo;
GetSystemInfo (&systemInfo);
cpuFlags.numCpus = systemInfo.dwNumberOfProcessors;
}
LARGE_INTEGER f;
QueryPerformanceFrequency (&f);
hiResTicksPerSecond = f.QuadPart;
@ -163,12 +139,9 @@ void SystemStats::initialiseStats()
String s (SystemStats::getJUCEVersion());
#if JUCE_DEBUG
const MMRESULT res = timeBeginPeriod (1);
(void) res;
jassert (res == TIMERR_NOERROR);
#else
timeBeginPeriod (1);
#endif
#if JUCE_DEBUG && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS
_CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
@ -244,14 +217,6 @@ int SystemStats::getMemorySizeInMegabytes()
return (int) (mem.ullTotalPhys / (1024 * 1024)) + 1;
}
int SystemStats::getNumCpus()
{
SYSTEM_INFO systemInfo;
GetSystemInfo (&systemInfo);
return systemInfo.dwNumberOfProcessors;
}
//==============================================================================
uint32 juce_millisecondsSinceStartup() throw()
{