diff options
author | Don Kjer <don@lindenlab.com> | 2007-07-26 01:22:23 +0000 |
---|---|---|
committer | Don Kjer <don@lindenlab.com> | 2007-07-26 01:22:23 +0000 |
commit | 9746cf5310871f305a1419163c5adfbed3f1534b (patch) | |
tree | d1f1d278927683fe837173318cc0da1e3c2f8ca4 /indra/llcommon | |
parent | 4284da17878eb9f8ade673d172148d34887aa816 (diff) |
EFFECTIVE MERGE: svn merge -r 65485:66133 svn+ssh://svn/svn/linden/branches/maintenance into release
This includes fixes to the maintenance-r66133 branch, and sync'ing up with release@r66392
ACTUAL MERGE: svn merge -r 66394:66435 svn+ssh://svn/svn/linden/branches/release-r66392 into release
EQUIVALENT TO: svn merge -r 65485:66434 svn+ssh://svn/svn/linden/branches/maintenance-r66133 into release (plus branch sync'ing)
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llprocessor.cpp | 46 | ||||
-rw-r--r-- | indra/llcommon/llprocessor.h | 14 | ||||
-rw-r--r-- | indra/llcommon/llsys.cpp | 111 | ||||
-rw-r--r-- | indra/llcommon/llsys.h | 1 |
4 files changed, 120 insertions, 52 deletions
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index e7cfe564f8..c8c565a05b 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -235,24 +235,24 @@ bool CProcessor::AnalyzeIntelProcessor() /* 0x03 */ "0.13 micron Intel Celeron", /* 0x04 */ "0.13 micron Intel Pentium III", /* 0x05 */ "", - /* 0x06 */ "0.13 micron Intel Pentium III mobile", - /* 0x07 */ "0.13 micron Intel Celeron mobile", + /* 0x06 */ "0.13 micron Intel Pentium III Mobile", + /* 0x07 */ "0.13 micron Intel Celeron Mobile", /* 0x08 */ "0.18 micron Intel Pentium 4", /* 0x09 */ "0.13 micron Intel Pentium 4", - /* 0x0A */ "0.13 micron Intel Pentium 4", + /* 0x0A */ "0.13 micron Intel Celeron", /* 0x0B */ "0.13 micron Intel Pentium 4 Xeon", - /* 0x0C */ "", + /* 0x0C */ "Intel Xeon MP", /* 0x0D */ "", /* 0x0E */ "0.18 micron Intel Pentium 4 Xeon", - /* 0x0F */ "", + /* 0x0F */ "Mobile Intel Celeron", /* 0x10 */ "", - /* 0x11 */ "", + /* 0x11 */ "Mobile Genuine Intel", /* 0x12 */ "Intel Celeron M", - /* 0x13 */ "mobile Intel Celeron", + /* 0x13 */ "Mobile Intel Celeron", /* 0x14 */ "Intel Celeron", - /* 0x15 */ "mobile Intel", + /* 0x15 */ "Mobile Genuine Intel", /* 0x16 */ "Intel Pentium M", - /* 0x17 */ "mobile Intel Celeron", + /* 0x17 */ "Mobile Intel Celeron", }; // Only override the brand if we have it in the lookup table. We should @@ -427,17 +427,21 @@ bool CProcessor::AnalyzeIntelProcessor() case 1: // Model = 8, Brand id = 1: Celeron (on-die L2 cache) processor model strncat(strCPUName, "Intel Celeron (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; - case 2: // Model = 8, Brand id = 2: Pentium III (on-die L2 cache) processor model (my current cpu :-)) + case 2: // Model = 8, Brand id = 2: Pentium III (on-die L2 cache) processor model (my current cpu :-)) strncat(strCPUName, "Intel Pentium III (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; case 3: // Model = 8, Brand id = 3: Pentium III Xeon (on-die L2 cache) processor model - strncat(strCPUName, "Intel Pentium III Xeon (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ + strncat(strCPUName, "Intel Pentium III Xeon (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; default: // ... strncat(strCPUName, "Intel Pentium III core (unknown model, 0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; } break; + case 9: // Model = 9: Intel Pentium M processor, Intel Celeron M processor, model 9 + strcpy(CPUInfo.strModel, "Intel Pentium M Series Processor"); /*Flawfinder: ignore*/ + strncat(strCPUName, "Intel Pentium M Series Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ + break; case 0xA: // Model = 0xA: Pentium III/Xeon/Celeron (1 or 2 MB on-die L2 cache) processor model strcpy(CPUInfo.strModel, "Intel Pentium III/Celeron/Pentium III Xeon - internal L2 cache, 0.18 micron"); /*Flawfinder: ignore*/ // Exact detection: @@ -446,11 +450,11 @@ bool CProcessor::AnalyzeIntelProcessor() case 1: // Model = 0xA, Brand id = 1: Celeron (1 or 2 MB on-die L2 cache (does it exist??)) processor model strncat(strCPUName, "Intel Celeron (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; - case 2: // Model = 0xA, Brand id = 2: Pentium III (1 or 2 MB on-die L2 cache (never seen...)) processor model + case 2: // Model = 0xA, Brand id = 2: Pentium III (1 or 2 MB on-die L2 cache (never seen...)) processor model strncat(strCPUName, "Intel Pentium III (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; case 3: // Model = 0xA, Brand id = 3: Pentium III Xeon (1 or 2 MB on-die L2 cache) processor model - strncat(strCPUName, "Intel Pentium III Xeon (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ + strncat(strCPUName, "Intel Pentium III Xeon (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; default: // Getting bored of this............ strncat(strCPUName, "Intel Pentium III core (unknown model, 0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ @@ -465,24 +469,28 @@ bool CProcessor::AnalyzeIntelProcessor() case 3: // Model = 0xB, Brand id = 3: Celeron (Tualatin core) processor model strncat(strCPUName, "Intel Celeron (Tualatin core, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; - case 4: // Model = 0xB, Brand id = 4: Pentium III (Tualatin core) processor model + case 4: // Model = 0xB, Brand id = 4: Pentium III (Tualatin core) processor model strncat(strCPUName, "Intel Pentium III (Tualatin core, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; case 7: // Model = 0xB, Brand id = 7: Celeron mobile (Tualatin core) processor model - strncat(strCPUName, "Intel Celeron mobile (Tualatin core, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ + strncat(strCPUName, "Intel Celeron mobile (Tualatin core, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; default: // *bored* strncat(strCPUName, "Intel Pentium III Tualatin core (unknown model, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; } break; + case 0xD: // Model = 0xD: Intel Pentium M processor, Intel Celeron M processor, model D + strcpy(CPUInfo.strModel, "Intel Pentium M Series Processor"); /*Flawfinder: ignore*/ + strncat(strCPUName, "Intel Pentium M Series Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ + break; case 0xE: // Model = 0xE: Intel Core Duo processor, Intel Core Solo processor, model E - strcpy(CPUInfo.strModel, "Intel Core Duo/Solo Processor"); /*Flawfinder: ignore*/ - strncat(strCPUName, "Intel Core Duo/Solo Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ + strcpy(CPUInfo.strModel, "Intel Core Series Processor"); /*Flawfinder: ignore*/ + strncat(strCPUName, "Intel Core Series Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; case 0xF: // Model = 0xF: Intel Core 2 Duo processor, model F - strcpy(CPUInfo.strModel, "Intel Core2 Duo Processor"); /*Flawfinder: ignore*/ - strncat(strCPUName, "Intel Core2 Duo Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ + strcpy(CPUInfo.strModel, "Intel Core 2 Series Processor"); /*Flawfinder: ignore*/ + strncat(strCPUName, "Intel Core 2 Series Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ break; default: // *more bored* strcpy(CPUInfo.strModel, "Unknown Intel Pentium Pro/2/3, Core"); /*Flawfinder: ignore*/ diff --git a/indra/llcommon/llprocessor.h b/indra/llcommon/llprocessor.h index 9060e8aa95..7a09f37d0c 100644 --- a/indra/llcommon/llprocessor.h +++ b/indra/llcommon/llprocessor.h @@ -20,6 +20,20 @@ #define PROCESSOR_FREQUENCY_MEASURE_AVAILABLE #endif +#if LL_MSVC && _M_X64 +# define LL_X86_64 1 +# define LL_X86 1 +#elif LL_MSVC && _M_IX86 +# define LL_X86 1 +#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) ) +# define LL_X86_64 1 +# define LL_X86 1 +#elif LL_GNUC && ( defined(__i386__) ) +# define LL_X86 1 +#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) ) +# define LL_PPC 1 +#endif + typedef struct ProcessorExtensions { diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 87d31987ce..b6d927d0f3 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -17,7 +17,7 @@ # include "zlib/zlib.h" #endif -#include "processor.h" +#include "llprocessor.h" #if LL_WINDOWS # define WIN32_LEAN_AND_MEAN @@ -28,6 +28,8 @@ # include <sys/utsname.h> #elif LL_LINUX # include <sys/utsname.h> +# include <unistd.h> +# include <sys/sysinfo.h> const char MEMINFO_FILE[] = "/proc/meminfo"; const char CPUINFO_FILE[] = "/proc/cpuinfo"; #endif @@ -236,7 +238,7 @@ U32 LLOSInfo::getProcessVirtualSizeKB() #if LL_WINDOWS #endif #if LL_LINUX - FILE* status_filep = LLFile::fopen("/proc/self/status", "r"); /* Flawfinder: ignore */ + FILE* status_filep = LLFile::fopen("/proc/self/status", "rb"); S32 numRead = 0; char buff[STATUS_SIZE]; /* Flawfinder: ignore */ @@ -279,7 +281,7 @@ U32 LLOSInfo::getProcessResidentSizeKB() #if LL_WINDOWS #endif #if LL_LINUX - FILE* status_filep = LLFile::fopen("/proc/self/status", "r"); /* Flawfinder: ignore */ + FILE* status_filep = LLFile::fopen("/proc/self/status", "rb"); if (status_filep != NULL) { S32 numRead = 0; @@ -320,6 +322,7 @@ U32 LLOSInfo::getProcessResidentSizeKB() LLCPUInfo::LLCPUInfo() { + std::ostringstream out; CProcessor proc; const ProcessorInfo* info = proc.GetCPUInfo(); // proc.WriteInfoTextFile("procInfo.txt"); @@ -328,6 +331,63 @@ LLCPUInfo::LLCPUInfo() mHasAltivec = info->_Ext.Altivec_Extensions; mCPUMhz = (S32)(proc.GetCPUFrequency(50)/1000000.0); mFamily.assign( info->strFamily ); + mCPUString = "Unknown"; + +#if LL_WINDOWS || LL_DARWIN || LL_SOLARIS + out << proc.strCPUName; + if (200 < mCPUMhz && mCPUMhz < 10000) // *NOTE: cpu speed is often way wrong, do a sanity check + { + out << " (" << mCPUMhz << " MHz)"; + } + mCPUString = out.str(); + +#elif LL_LINUX + std::map< LLString, LLString > cpuinfo; + FILE* cpuinfo_fp = LLFile::fopen(CPUINFO_FILE, "rb"); + if(cpuinfo_fp) + { + char line[MAX_STRING]; + memset(line, 0, MAX_STRING); + while(fgets(line, MAX_STRING, cpuinfo_fp)) + { + // /proc/cpuinfo on Linux looks like: + // name\t*: value\n + char* tabspot = strchr( line, '\t' ); + if (tabspot == NULL) + continue; + char* colspot = strchr( tabspot, ':' ); + if (colspot == NULL) + continue; + char* spacespot = strchr( colspot, ' ' ); + if (spacespot == NULL) + continue; + char* nlspot = strchr( line, '\n' ); + if (nlspot == NULL) + nlspot = line + strlen( line ); // Fallback to terminating NUL + std::string linename( line, tabspot ); + LLString llinename(linename); + LLString::toLower(llinename); + std::string lineval( spacespot + 1, nlspot ); + cpuinfo[ llinename ] = lineval; + } + fclose(cpuinfo_fp); + } +# if LL_X86 + LLString flags = " " + cpuinfo["flags"] + " "; + LLString::toLower(flags); + mHasSSE = ( flags.find( " sse " ) != std::string::npos ); + mHasSSE2 = ( flags.find( " sse2 " ) != std::string::npos ); + + F64 mhz; + if (LLString::convertToF64(cpuinfo["cpu mhz"], mhz) + && 200.0 < mhz && mhz < 10000.0) + { + mCPUMhz = (S32)llrint(mhz); + } + if (!cpuinfo["model name"].empty()) + mCPUString = cpuinfo["model name"]; +# endif // LL_X86 +#endif // LL_LINUX } bool LLCPUInfo::hasAltivec() const @@ -352,25 +412,7 @@ S32 LLCPUInfo::getMhz() const std::string LLCPUInfo::getCPUString() const { -#if LL_WINDOWS || LL_DARWIN || LL_SOLARIS - std::ostringstream out; - - CProcessor proc; - (void) proc.GetCPUInfo(); - out << proc.strCPUName << " "; - - F32 freq = (F32)(proc.GetCPUFrequency(50) / 1000000.0); - - // cpu speed is often way wrong, do a sanity check - if (200.f < freq && freq < 10000.f) - { - out << "(" << (S32)(freq) << " MHz)"; - } - - return out.str(); -#else - return "Can't get terse CPU information"; -#endif + return mCPUString; } void LLCPUInfo::stream(std::ostream& s) const @@ -385,38 +427,41 @@ void LLCPUInfo::stream(std::ostream& s) const } else { - s << "Unable to collect processor info"; + s << "Unable to collect processor information" << std::endl; } #else // *NOTE: This works on linux. What will it do on other systems? - FILE* cpuinfo = LLFile::fopen(CPUINFO_FILE, "r"); /* Flawfinder: ignore */ + FILE* cpuinfo = LLFile::fopen(CPUINFO_FILE, "rb"); if(cpuinfo) { - char line[MAX_STRING]; /* Flawfinder: ignore */ + char line[MAX_STRING]; memset(line, 0, MAX_STRING); while(fgets(line, MAX_STRING, cpuinfo)) { - line[strlen(line)-1] = ' '; /*Flawfinder: ignore*/ + line[strlen(line)-1] = ' '; s << line; } fclose(cpuinfo); + s << std::endl; } else { - s << "Unable to collect memory information"; + s << "Unable to collect processor information" << std::endl; } #endif + // These are interesting as they reflect our internal view of the + // CPU's attributes regardless of platform + s << "->mHasSSE: " << (U32)mHasSSE << std::endl; + s << "->mHasSSE2: " << (U32)mHasSSE2 << std::endl; + s << "->mHasAltivec: " << (U32)mHasAltivec << std::endl; + s << "->mCPUMhz: " << mCPUMhz << std::endl; + s << "->mCPUString: " << mCPUString << std::endl; } LLMemoryInfo::LLMemoryInfo() { } -#if LL_LINUX -#include <unistd.h> -#include <sys/sysinfo.h> -#endif - U32 LLMemoryInfo::getPhysicalMemory() const { #if LL_WINDOWS @@ -481,7 +526,7 @@ void LLMemoryInfo::stream(std::ostream& s) const s << "Total Physical Kb: " << phys << std::endl; #else // *NOTE: This works on linux. What will it do on other systems? - FILE* meminfo = LLFile::fopen(MEMINFO_FILE,"r"); /* Flawfinder: ignore */ + FILE* meminfo = LLFile::fopen(MEMINFO_FILE,"rb"); if(meminfo) { char line[MAX_STRING]; /* Flawfinder: ignore */ diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h index 4b6fbe149b..4c80e2877c 100644 --- a/indra/llcommon/llsys.h +++ b/indra/llcommon/llsys.h @@ -66,6 +66,7 @@ private: bool mHasAltivec; S32 mCPUMhz; std::string mFamily; + std::string mCPUString; }; class LLMemoryInfo |