diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcommon/llprocessor.cpp | 115 | ||||
-rw-r--r-- | indra/llcommon/llsys.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/tests/llprocessor_test.cpp | 2 |
3 files changed, 80 insertions, 39 deletions
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 75f1c7e36c..98c9eabcd6 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -180,6 +180,49 @@ namespace "Altivec" }; + std::string intel_CPUFamilyName(int composed_family) + { + switch(composed_family) + { + case 3: return "Intel i386"; + case 4: return "Intel i486"; + case 5: return "Intel Pentium"; + case 6: return "Intel Pentium Pro/2/3, Core"; + case 7: return "Intel Itanium (IA-64)"; + case 0xF: return "Intel Pentium 4"; + case 0x10: return "Intel Itanium 2 (IA-64)"; + } + return "Unknown"; + } + + std::string amd_CPUFamilyName(int composed_family) + { + switch(composed_family) + { + case 4: return "AMD 80486/5x86"; + case 5: return "AMD K5/K6"; + case 6: return "AMD K7"; + case 0xF: return "AMD K8"; + case 0x10: return "AMD K8L"; + } + return "Unknown"; + } + + std::string compute_CPUFamilyName(const char* cpu_vendor, int composed_family) + { + const char* intel_string = "GenuineIntel"; + const char* amd_string = "AuthenticAMD"; + if(!strncmp(cpu_vendor, intel_string, strlen(intel_string))) + { + return intel_CPUFamilyName(composed_family); + } + else if(!strncmp(cpu_vendor, amd_string, strlen(amd_string))) + { + return amd_CPUFamilyName(composed_family); + } + return "Unknown"; + } + std::string compute_CPUFamilyName(const char* cpu_vendor, int family, int ext_family) { const char* intel_string = "GenuineIntel"; @@ -187,35 +230,18 @@ namespace if(!strncmp(cpu_vendor, intel_string, strlen(intel_string))) { U32 composed_family = family + ext_family; - switch(composed_family) - { - case 3: return "Intel i386"; - case 4: return "Intel i486"; - case 5: return "Intel Pentium"; - case 6: return "Intel Pentium Pro/2/3, Core"; - case 7: return "Intel Itanium (IA-64)"; - case 0xF: return "Intel Pentium 4"; - case 0x10: return "Intel Itanium 2 (IA-64)"; - default: return "Unknown"; - } + return intel_CPUFamilyName(composed_family); } else if(!strncmp(cpu_vendor, amd_string, strlen(amd_string))) { U32 composed_family = (family == 0xF) ? family + ext_family : family; - switch(composed_family) - { - case 4: return "AMD 80486/5x86"; - case 5: return "AMD K5/K6"; - case 6: return "AMD K7"; - case 0xF: return "AMD K8"; - case 0x10: return "AMD K8L"; - default: return "Unknown"; - } + return amd_CPUFamilyName(composed_family); } return "Unknown"; } + } // end unnamed namespace // The base class for implementations. @@ -263,7 +289,7 @@ public: out << "// CPU General Information" << std::endl; out << "//////////////////////////" << std::endl; out << "Processor Name: " << getCPUBrandName() << std::endl; - out << "Frequency: " << getCPUFrequency() / (F64)1000000 << " MHz" << std::endl; + out << "Frequency: " << getCPUFrequency() << " MHz" << std::endl; out << "Vendor: " << getInfo(eVendor, "Unknown").asString() << std::endl; out << "Family: " << getCPUFamilyName() << " (" << getInfo(eFamily, 0) << ")" << std::endl; out << "Extended family: " << getInfo(eExtendedFamily, 0) << std::endl; @@ -322,13 +348,16 @@ private: void setInfo(const std::string& name, const LLSD& value) { mProcessorInfo["info"][name]=value; } LLSD getInfo(const std::string& name, const LLSD& defaultVal) const { - LLSD r = mProcessorInfo["info"].get(name); - return r.isDefined() ? r : defaultVal; + if(mProcessorInfo["info"].has(name)) + { + return mProcessorInfo["info"][name]; + } + return defaultVal; } void setConfig(const std::string& name, const LLSD& value) { mProcessorInfo["config"][name]=value; } LLSD getConfig(const std::string& name, const LLSD& defaultVal) const { - LLSD r = mProcessorInfo["config"].get(name); + LLSD r = mProcessorInfo["config"].get(name); return r.isDefined() ? r : defaultVal; } @@ -431,8 +460,8 @@ static F64 calculate_cpu_frequency(U32 measure_msecs) F64 frequency = (F64)dif / (((F64)timedif) / freq); // At last we just return the frequency that is also stored in the call - // member var uqwFrequency - return frequency; + // member var uqwFrequency - converted to MHz + return frequency / (F64)1000000; } // Windows implementation @@ -567,7 +596,7 @@ public: { getCPUIDInfo(); uint64_t frequency = getSysctlInt64("hw.cpufrequency"); - setInfo(eFrequency, (F64)frequency); + setInfo(eFrequency, (F64)frequency / (F64)1000000); } virtual ~LLProcessorInfoDarwinImpl() {} @@ -736,11 +765,17 @@ private: // *NOTE:Mani - eww, macros! srry. #define LLPI_SET_INFO_STRING(llpi_id, cpuinfo_id) \ - if (!cpuinfo[cpuinfo_id].empty()) { setInfo(llpi_id, cpuinfo[cpuinfo_id]);} + if (!cpuinfo[cpuinfo_id].empty()) \ + { setInfo(llpi_id, cpuinfo[cpuinfo_id]);} #define LLPI_SET_INFO_INT(llpi_id, cpuinfo_id) \ - if (!cpuinfo[cpuinfo_id].empty()) { setInfo(llpi_id, LLStringUtil::convertToS32(cpuinfo[cpuinfo_id]));} - + {\ + S32 result; \ + if (!cpuinfo[cpuinfo_id].empty() \ + && LLStringUtil::convertToS32(cpuinfo[cpuinfo_id], result)) \ + { setInfo(llpi_id, result);} \ + } + F64 mhz; if (LLStringUtil::convertToF64(cpuinfo["cpu mhz"], mhz) && 200.0 < mhz && mhz < 10000.0) @@ -753,11 +788,17 @@ private: LLPI_SET_INFO_INT(eStepping, "stepping"); LLPI_SET_INFO_INT(eModel, "model"); - int family = LLStringUtil::convertTos32getSysctlInt("machdep.cpu.family"); - int ext_family = getSysctlInt("machdep.cpu.extfamily"); - LLPI_SET_INFO_INT(eFamily, "cpu family"); - //LLPI_SET_INFO_INT(eExtendedFamily, ext_family); - // setInfo(eFamilyName, compute_CPUFamilyName(cpu_vendor, family, ext_family)); + + + S32 family; + if (!cpuinfo["cpu family"].empty() + && LLStringUtil::convertToS32(cpuinfo["cpu family"], family)) + { + setInfo(eFamily, family); + } + + setInfo(eFamilyName, compute_CPUFamilyName(cpuinfo["vendor_id"].c_str(), family)); + // setInfo(eExtendedModel, getSysctlInt("machdep.cpu.extmodel")); // setInfo(eBrandID, getSysctlInt("machdep.cpu.brand")); // setInfo(eType, 0); // ? where to find this? @@ -774,12 +815,12 @@ private: if( flags.find( " sse " ) != std::string::npos ) { - setExtension(eSSE_Ext); + setExtension(cpu_feature_names[eSSE_Ext]); } if( flags.find( " sse2 " ) != std::string::npos ) { - setExtension(eSSE2_Ext); + setExtension(cpu_feature_names[eSSE2_Ext]); } # endif // LL_X86 diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 86f2736d5a..d41d0c8a3f 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -517,7 +517,7 @@ LLCPUInfo::LLCPUInfo() mHasSSE = proc.hasSSE(); mHasSSE2 = proc.hasSSE2(); mHasAltivec = proc.hasAltivec(); - mCPUMHz = (F64)(proc.getCPUFrequency()/1000000.0); + mCPUMHz = (F64)proc.getCPUFrequency(); mFamily = proc.getCPUFamilyName(); mCPUString = "Unknown"; diff --git a/indra/llcommon/tests/llprocessor_test.cpp b/indra/llcommon/tests/llprocessor_test.cpp index 83b235cae5..a9e312b70b 100644 --- a/indra/llcommon/tests/llprocessor_test.cpp +++ b/indra/llcommon/tests/llprocessor_test.cpp @@ -62,6 +62,6 @@ namespace tut ensure_not_equals("Unknown Brand name", brand, "Unknown"); ensure_not_equals("Unknown Family name", family, "Unknown"); - ensure_not_equals("Undetected Frequency", freq, LLSD(0).asReal()); + ensure("Reasonable CPU Frequency > 100 && < 10000", freq > 100 && freq < 10000); } } |