From 0db04cbb67d5420f98cc2090fdcca6bba948527b Mon Sep 17 00:00:00 2001 From: "Mark Palange (Mani)" Date: Tue, 11 May 2010 16:27:50 -0700 Subject: EXT-3780 WIP Adding newline to linux getCPUFeatureDesc output --- indra/llcommon/llprocessor.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/llprocessor.cpp') diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 463b07a7a5..a55765e329 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -240,7 +240,9 @@ public: std::string getCPUFamilyName() const { return getInfo(eFamilyName, "Unknown").asString(); } std::string getCPUBrandName() const { return getInfo(eBrandName, "Unknown").asString(); } - std::string getCPUFeatureDescription() const + // This is virtual to support a different linux format. + // *NOTE:Mani - I didn't want to screw up server use of this data... + virtual std::string getCPUFeatureDescription() const { std::ostringstream out; out << std::endl << std::endl; @@ -671,6 +673,7 @@ private: }; #elif LL_LINUX +const char CPUINFO_FILE[] = "/proc/cpuinfo"; class LLProcessorInfoLinuxImpl : public LLProcessorInfoImpl { @@ -820,6 +823,33 @@ private: # endif // LL_X86 } + + std::string getCPUFeatureDescription() const + { + std::ostringstream s; + + // *NOTE:Mani - This is for linux only. + LLFILE* cpuinfo = LLFile::fopen(CPUINFO_FILE, "rb"); + if(cpuinfo) + { + char line[MAX_STRING]; + memset(line, 0, MAX_STRING); + while(fgets(line, MAX_STRING, cpuinfo)) + { + line[strlen(line)-1] = ' '; + s << line; + s << std::endl; + } + fclose(cpuinfo); + s << std::endl; + } + else + { + s << "Unable to collect processor information" << std::endl; + } + return s.str(); + } + }; @@ -839,11 +869,13 @@ LLProcessorInfo::LLProcessorInfo() : mImpl(NULL) static LLProcessorInfoDarwinImpl the_impl; mImpl = &the_impl; #else - #error "Unimplemented" + static LLProcessorInfoLinuxImpl the_impl; + mImpl = &the_impl; #endif // LL_MSVC } } + LLProcessorInfo::~LLProcessorInfo() {} F64 LLProcessorInfo::getCPUFrequency() const { return mImpl->getCPUFrequency(); } bool LLProcessorInfo::hasSSE() const { return mImpl->hasSSE(); } -- cgit v1.2.3