summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorJosh Bell <josh@lindenlab.com>2007-04-11 17:54:18 +0000
committerJosh Bell <josh@lindenlab.com>2007-04-11 17:54:18 +0000
commit0277259455c4354f81ea8a24c8ab93f27567bc6f (patch)
treef1411dab563dcf697f794e9e8a592a6d3e5c4d2d /indra/llcommon
parent568397bbcc4fca307ebc010ec7f815422b9ba80a (diff)
svn merge -r 59968:60342 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance --> release
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llmemory.h8
-rw-r--r--indra/llcommon/llpreprocessor.h7
-rw-r--r--indra/llcommon/llprocessor.cpp216
-rw-r--r--indra/llcommon/llsys.cpp43
-rw-r--r--indra/llcommon/llsys.h1
5 files changed, 111 insertions, 164 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 2a58db659e..1253d34a7d 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -174,6 +174,14 @@ public:
}
return *this;
}
+
+ // Just exchange the pointers, which will not change the reference counts.
+ static void swap(LLPointer<Type>& a, LLPointer<Type>& b)
+ {
+ Type* temp = a.mPointer;
+ a.mPointer = b.mPointer;
+ b.mPointer = temp;
+ }
protected:
void ref()
diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h
index aaecbf3ddc..0882472242 100644
--- a/indra/llcommon/llpreprocessor.h
+++ b/indra/llcommon/llpreprocessor.h
@@ -22,6 +22,13 @@
#define LL_BIG_ENDIAN 1
#endif
+// Per-compiler switches
+#ifdef __GNUC__
+#define LL_FORCE_INLINE inline __attribute__((always_inline))
+#else
+#define LL_FORCE_INLINE __forceinline
+#endif
+
// Per-OS feature switches.
#if LL_DARWIN
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index a941941fa8..0e469e6341 100644
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -84,6 +84,7 @@ static void _Delay(unsigned int ms)
CProcessor::CProcessor()
{
uqwFrequency = 0;
+ strCPUName[0] = 0;
memset(&CPUInfo, 0, sizeof(CPUInfo));
}
@@ -226,77 +227,44 @@ bool CProcessor::AnalyzeIntelProcessor()
CPUInfo.uiType = (eaxreg >> 12) & 0x3;
CPUInfo.uiBrandID = ebxreg & 0xF;
- // Now we can translate the type number to a more understandable string format
- switch (CPUInfo.uiType)
+ static const char* INTEL_BRAND[] =
{
- case 0: // Type = 0: Original OEM processor
- strcpy(CPUInfo.strType, "Original OEM"); /* Flawfinder: ignore */
- strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */
- strcat(strCPUName, " "); /* Flawfinder: ignore */
- break;
- case 1: // Type = 1: Overdrive processor
- strcpy(CPUInfo.strType, "Overdrive"); /* Flawfinder: ignore */
- strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */
- strcat(strCPUName, " "); /* Flawfinder: ignore */
- break;
- case 2: // Type = 2: Dual-capable processor
- strcpy(CPUInfo.strType, "Dual-capable"); /* Flawfinder: ignore */
- strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */
- strcat(strCPUName, " "); /* Flawfinder: ignore */
- break;
- case 3: // Type = 3: Reserved for future use
- strcpy(CPUInfo.strType, "Reserved"); /* Flawfinder: ignore */
- break;
- default: // This should be never called, cause we just mask 2 bits --> [0..3]
- strcpy(CPUInfo.strType, "Unknown"); /* Flawfinder: ignore */
- break;
- }
-
- // Then we translate the brand id:
- switch (CPUInfo.uiBrandID)
+ /* 0x00 */ "",
+ /* 0x01 */ "0.18 micron Intel Celeron",
+ /* 0x02 */ "0.18 micron Intel Pentium III",
+ /* 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",
+ /* 0x08 */ "0.18 micron Intel Pentium 4",
+ /* 0x09 */ "0.13 micron Intel Pentium 4",
+ /* 0x0A */ "0.13 micron Intel Pentium 4",
+ /* 0x0B */ "0.13 micron Intel Pentium 4 Xeon",
+ /* 0x0C */ "",
+ /* 0x0D */ "",
+ /* 0x0E */ "0.18 micron Intel Pentium 4 Xeon",
+ /* 0x0F */ "",
+ /* 0x10 */ "",
+ /* 0x11 */ "",
+ /* 0x12 */ "Intel Celeron M",
+ /* 0x13 */ "mobile Intel Celeron",
+ /* 0x14 */ "Intel Celeron",
+ /* 0x15 */ "mobile Intel",
+ /* 0x16 */ "Intel Pentium M",
+ /* 0x17 */ "mobile Intel Celeron",
+ };
+
+ // Only override the brand if we have it in the lookup table. We should
+ // already have a string here from GetCPUInfo(). JC
+ if (CPUInfo.uiBrandID < sizeof(INTEL_BRAND))
{
- case 0: // Brand id = 0: Brand id not supported on this processor
- strcpy(CPUInfo.strBrandID, "Not supported"); /* Flawfinder: ignore */
- break;
- case 1: // Brand id = 1: Intel Celeron (0.18 micron) processor
- strcpy(CPUInfo.strBrandID, "0.18 micron Intel Celeron"); /* Flawfinder: ignore */
- break;
- case 2: // Brand id = 2: Intel Pentium III (0.18 micron) processor
- strcpy(CPUInfo.strBrandID, "0.18 micron Intel Pentium III"); /* Flawfinder: ignore */
- break;
- case 3: // Brand id = 3: Model dependent
- if (CPUInfo.uiModel == 6) // If the cpu model is Celeron (well, I'm NOT SURE!!!)
- strcpy(CPUInfo.strBrandID, "0.13 micron Intel Celeron"); /* Flawfinder: ignore */
- else
- strcpy(CPUInfo.strBrandID, "0.18 micron Intel Pentium III Xeon"); /* Flawfinder: ignore */
- break;
- case 4: // Brand id = 4: Intel Pentium III Tualatin (0.13 micron) processor
- strcpy(CPUInfo.strBrandID, "0.13 micron Intel Pentium III"); /* Flawfinder: ignore */
- break;
- case 6: // Brand id = 6: Intel Pentium III mobile (0.13 micron) processor
- strcpy(CPUInfo.strBrandID, "0.13 micron Intel Pentium III mobile"); /* Flawfinder: ignore */
- break;
- case 7: // Brand id = 7: Intel Celeron mobile (0.13 micron) processor
- strcpy(CPUInfo.strBrandID, "0.13 micron Intel Celeron mobile"); /* Flawfinder: ignore */
- break;
- case 8: // Brand id = 8: Intel Pentium 4 Willamette (0.18 micron) processor
- strcpy(CPUInfo.strBrandID, "0.18 micron Intel Pentium 4"); /* Flawfinder: ignore */
- break;
- case 9: // Brand id = 9: Intel Pentium 4 Northwood (0.13 micron) processor
- strcpy(CPUInfo.strBrandID, "0.13 micron Intel Pentium 4"); /* Flawfinder: ignore */
- break;
- case 0xA: // Brand id = 0xA: Intel Pentium 4 Northwood (0.13 micron processor)
- strcpy(CPUInfo.strBrandID, "0.13 micron Intel Pentium 4"); /* Flawfinder: ignore */
- break; // No idea, where the difference to id=9 is
- case 0xB: // Brand id = 0xB: Intel Pentium 4 Northwood Xeon (0.13 micron processor)
- strcpy(CPUInfo.strBrandID, "0.13 micron Intel Pentium 4 Xeon"); /* Flawfinder: ignore */
- break;
- case 0xE: // Brand id = 0xE: Intel Pentium 4 Willamette Xeon (0.18 micron processor)
- strcpy(CPUInfo.strBrandID, "0.18 micron Intel Pentium 4 Xeon"); /* Flawfinder: ignore */
- break;
- default: // Should be never called, but sure is sure
- strcpy(CPUInfo.strBrandID, "Unknown"); /* Flawfinder: ignore */
- break;
+ strcpy(CPUInfo.strBrandID, INTEL_BRAND[CPUInfo.uiBrandID]);
+
+ if (CPUInfo.uiBrandID == 3 && CPUInfo.uiModel == 6)
+ {
+ strcpy(CPUInfo.strBrandID, "0.18 micron Intel Pentium III Xeon");
+ }
}
// Then we translate the cpu family
@@ -648,33 +616,6 @@ bool CProcessor::AnalyzeAMDProcessor()
CPUInfo.uiFamily = (eaxreg >> 8) & 0xF;
CPUInfo.uiType = (eaxreg >> 12) & 0x3;
- // After that, we translate the processor type (see CProcessor::AnalyzeIntelProcessor()
- // for further comments on this)
- switch (CPUInfo.uiType)
- {
- case 0:
- strcpy(CPUInfo.strType, "Original OEM"); /* Flawfinder: ignore */
- strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */
- strcat(strCPUName, " "); /*Flawfinder: ignore*/
- break;
- case 1:
- strcpy(CPUInfo.strType, "Overdrive"); /* Flawfinder: ignore */
- strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */
- strcat(strCPUName, " "); /*Flawfinder: ignore*/
- break;
- case 2:
- strcpy(CPUInfo.strType, "Dual-capable"); /* Flawfinder: ignore */
- strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */
- strcat(strCPUName, " "); /*Flawfinder: ignore*/
- break;
- case 3:
- strcpy(CPUInfo.strType, "Reserved"); /* Flawfinder: ignore */
- break;
- default:
- strcpy(CPUInfo.strType, "Unknown"); /* Flawfinder: ignore */
- break;
- }
-
// Now we check if the processor supports the brand id string extended CPUID level
if (CPUInfo.MaxSupportedExtendedLevel >= 0x80000004)
{
@@ -709,7 +650,7 @@ bool CProcessor::AnalyzeAMDProcessor()
else
{
// Or just tell there is no brand id string support
- strcpy(CPUInfo.strBrandID, "Not supported"); /* Flawfinder: ignore */
+ strcpy(CPUInfo.strBrandID, ""); /* Flawfinder: ignore */
}
// After that we translate the processor family
@@ -1103,26 +1044,6 @@ bool CProcessor::AnalyzeUnknownProcessor()
snprintf(CPUInfo.strFamily, sizeof(CPUInfo.strFamily), "Family number %d", CPUInfo.uiFamily); /* Flawfinder: ignore */
snprintf(CPUInfo.strModel, sizeof(CPUInfo.strModel), "Model number %d", CPUInfo.uiModel); /* Flawfinder: ignore */
- // Nevertheless we can determine the processor type
- switch (CPUInfo.uiType)
- {
- case 0:
- strcpy(CPUInfo.strType, "Original OEM"); /*Flawfinder: ignore*/
- break;
- case 1:
- strcpy(CPUInfo.strType, "Overdrive"); /*Flawfinder: ignore*/
- break;
- case 2:
- strcpy(CPUInfo.strType, "Dual-capable"); /*Flawfinder: ignore*/
- break;
- case 3:
- strcpy(CPUInfo.strType, "Reserved"); /*Flawfinder: ignore*/
- break;
- default:
- strcpy(CPUInfo.strType, "Unknown"); /*Flawfinder: ignore*/
- break;
- }
-
// And thats it
return true;
#else
@@ -1634,6 +1555,8 @@ const ProcessorInfo *CProcessor::GetCPUInfo()
*((unsigned long *) CPUInfo.strVendor) = ebxreg;
*((unsigned long *) (CPUInfo.strVendor+4)) = edxreg;
*((unsigned long *) (CPUInfo.strVendor+8)) = ecxreg;
+ // Null terminate for string comparisons below.
+ CPUInfo.strVendor[12] = 0;
// We can also read the max. supported standard CPUID level
CPUInfo.MaxSupportedLevel = eaxreg & 0xFFFF;
@@ -1649,22 +1572,52 @@ const ProcessorInfo *CProcessor::GetCPUInfo()
CPUInfo.MaxSupportedExtendedLevel = eaxreg;
// Then we switch to the specific processor vendors
- switch (ebxreg)
+ // See http://www.sandpile.org/ia32/cpuid.htm
+ if (!strcmp(CPUInfo.strVendor, "GenuineIntel"))
{
- case 0x756E6547: // GenuineIntel
- AnalyzeIntelProcessor();
- break;
- case 0x68747541: // AuthenticAMD
- AnalyzeAMDProcessor();
- break;
- case 0x69727943: // CyrixInstead
- // I really do not know anyone owning such a piece of crab
- // So we analyze it as an unknown processor *ggggg*
- default:
- AnalyzeUnknownProcessor();
- break;
+ AnalyzeIntelProcessor();
+ }
+ else if (!strcmp(CPUInfo.strVendor, "AuthenticAMD"))
+ {
+ AnalyzeAMDProcessor();
+ }
+ else if (!strcmp(CPUInfo.strVendor, "UMC UMC UMC"))
+ {
+ AnalyzeUnknownProcessor();
+ }
+ else if (!strcmp(CPUInfo.strVendor, "CyrixInstead"))
+ {
+ AnalyzeUnknownProcessor();
+ }
+ else if (!strcmp(CPUInfo.strVendor, "NexGenDriven"))
+ {
+ AnalyzeUnknownProcessor();
+ }
+ else if (!strcmp(CPUInfo.strVendor, "CentaurHauls"))
+ {
+ AnalyzeUnknownProcessor();
+ }
+ else if (!strcmp(CPUInfo.strVendor, "RiseRiseRise"))
+ {
+ AnalyzeUnknownProcessor();
+ }
+ else if (!strcmp(CPUInfo.strVendor, "SiS SiS SiS"))
+ {
+ AnalyzeUnknownProcessor();
+ }
+ else if (!strcmp(CPUInfo.strVendor, "GenuineTMx86"))
+ {
+ // Transmeta
+ AnalyzeUnknownProcessor();
+ }
+ else if (!strcmp(CPUInfo.strVendor, "Geode by NSC"))
+ {
+ AnalyzeUnknownProcessor();
+ }
+ else
+ {
+ AnalyzeUnknownProcessor();
}
-
#endif
// After all we return the class CPUInfo member var
return (&CPUInfo);
@@ -1748,6 +1701,7 @@ void CProcessor::TranslateProcessorConfiguration()
CProcessor::CProcessor()
{
uqwFrequency = 0;
+ strCPUName[0] = 0;
memset(&CPUInfo, 0, sizeof(CPUInfo));
}
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 54276f9f2f..6f0bda4b71 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -12,6 +12,7 @@
#include <iostream>
#include <zlib/zlib.h>
+
#include "processor.h"
#if LL_WINDOWS
@@ -289,50 +290,28 @@ LLCPUInfo::LLCPUInfo()
mFamily.assign( info->strFamily );
}
+
std::string LLCPUInfo::getCPUString() const
{
- std::string cpu_string;
-
#if LL_WINDOWS || LL_DARWIN
- // gather machine information.
- char proc_buf[CPUINFO_BUFFER_SIZE]; /* Flawfinder: ignore */
- CProcessor proc;
- if(proc.CPUInfoToText(proc_buf, CPUINFO_BUFFER_SIZE))
- {
- cpu_string.append(proc_buf);
- }
-#else
- cpu_string.append("Can't get CPU information");
-#endif
-
- return cpu_string;
-}
-
-std::string LLCPUInfo::getCPUStringTerse() const
-{
- std::string cpu_string;
+ std::ostringstream out;
-#if LL_WINDOWS || LL_DARWIN
CProcessor proc;
- const ProcessorInfo *info = proc.GetCPUInfo();
-
- cpu_string.append(info->strBrandID);
+ (void) proc.GetCPUInfo();
+ out << proc.strCPUName << " ";
- F64 freq = (F64)(S64)proc.GetCPUFrequency(50) / 1000000.f;
+ F32 freq = (F32)(proc.GetCPUFrequency(50) / 1000000.0);
// cpu speed is often way wrong, do a sanity check
- if (freq < 10000.f && freq > 200.f )
+ if (200.f < freq && freq < 10000.f)
{
- char tmp[MAX_STRING]; /* Flawfinder: ignore */
- snprintf(tmp, sizeof(tmp), " (%.0f Mhz)", freq); /* Flawfinder: ignore */
-
- cpu_string.append(tmp);
+ out << "(" << (S32)(freq) << " MHz)";
}
+
+ return out.str();
#else
- cpu_string.append("Can't get terse CPU information");
+ return "Can't get terse CPU information";
#endif
-
- return cpu_string;
}
void LLCPUInfo::stream(std::ostream& s) const
diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h
index 05c975a5fa..7808a97b80 100644
--- a/indra/llcommon/llsys.h
+++ b/indra/llcommon/llsys.h
@@ -51,7 +51,6 @@ public:
void stream(std::ostream& s) const;
std::string getCPUString() const;
- std::string getCPUStringTerse() const;
BOOL hasSSE() const { return mHasSSE; }
BOOL hasSSE2() const { return mHasSSE2; }