summaryrefslogtreecommitdiff
path: root/indra/llcommon/llprocessor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llprocessor.cpp')
-rw-r--r--indra/llcommon/llprocessor.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index 9d53b9be35..559deda96f 100644
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -638,6 +638,13 @@ public:
{
getCPUIDInfo();
uint64_t frequency = getSysctlInt64("hw.cpufrequency");
+ if (!frequency) {
+ auto tbfrequency = getSysctlInt64("hw.tbfrequency");
+ struct clockinfo clockrate;
+ auto clockrate_len = sizeof(clockrate);
+ if (!sysctlbyname("kern.clockrate", &clockrate, &clockrate_len, NULL, 0))
+ frequency = tbfrequency * clockrate.hz;
+ }
setInfo(eFrequency, (F64)frequency / (F64)1000000);
}
@@ -742,12 +749,14 @@ private:
: "0" (level))
#endif
+#if __i386__ || __x86_64__
unsigned int eax, ebx, ecx, edx;
__cpuid(0x1, eax, ebx, ecx, edx);
if(feature_infos[0] != (S32)edx)
{
LL_WARNS() << "machdep.cpu.feature_bits doesn't match expected cpuid result!" << LL_ENDL;
}
+#endif // __i386__ || __x86_64__
#endif // LL_RELEASE_FOR_DOWNLOAD
@@ -792,6 +801,100 @@ private:
}
};
+#elif LL_FREEBSD
+
+#include <sys/sysctl.h>
+class LLProcessorInfoFreeBSDImpl : public LLProcessorInfoImpl
+{
+public:
+ LLProcessorInfoFreeBSDImpl()
+ {
+ size_t len = 0;
+ using std::string;
+
+ char cpu_brand_string[0x40];
+ len = sizeof cpu_brand_string;
+ memset(cpu_brand_string, '\0', len);
+ sysctlbyname("hw.model", (void *)cpu_brand_string, &len,
+ NULL, 0);
+ cpu_brand_string[0x3f] = '\0';
+ setInfo(eBrandName, cpu_brand_string);
+
+ uint64_t cpu_frequency = 0;
+ len = sizeof cpu_frequency;
+ sysctlbyname("hw.clockrate", (void *)&cpu_frequency, &len,
+ NULL, 0);
+ setInfo(eFrequency, (F64)cpu_frequency);
+
+ auto dmesgboot = LLFile::fopen("/var/run/dmesg.boot", "rb");
+ std::ostringstream s;
+ if (dmesgboot) {
+ char line[MAX_STRING];
+ memset(line, 0, MAX_STRING);
+ while (fgets(line, MAX_STRING, dmesgboot)) {
+ line[strlen(line) - 1] = ' ';
+ s << line;
+ s << std::endl;
+ }
+ fclose(dmesgboot);
+ s << std::endl;
+ }
+
+ auto dmesgboot_str = s.str();
+ int decimal;
+
+ auto idx1 = dmesgboot_str.find_first_of("\"") + 1;
+ auto idx2 = (idx1 != string::npos)
+ ? dmesgboot_str.find_first_of("\"", idx1)
+ : string::npos;
+ auto vendor = dmesgboot_str.substr(idx1, idx2 - idx1);
+ if (vendor.length() > 0) setInfo(eVendor, vendor.c_str());
+
+ idx1 = dmesgboot_str.find_first_of("=", idx2);
+ idx1 = dmesgboot_str.find_first_of("=", idx1 + 1) + 3;
+ idx2 = dmesgboot_str.find_first_of(" ", idx1);
+ auto family = dmesgboot_str.substr(idx1, idx2 - idx1);
+ std::istringstream(family) >> std::hex >> decimal;
+ setInfo(eFamily, decimal);
+ setInfo(eFamilyName, compute_CPUFamilyName(vendor.c_str(),
+ decimal, 0));
+
+ idx1 = dmesgboot_str.find_first_of("=", idx2) + 3;
+ idx2 = dmesgboot_str.find_first_of(" ", idx1);
+ auto model = dmesgboot_str.substr(idx1, idx2 - idx1);
+ std::istringstream(model) >> std::hex >> decimal;
+ setInfo(eModel, decimal);
+
+ idx1 = dmesgboot_str.find_first_of("=", idx2) + 1;
+ idx2 = dmesgboot_str.find_first_of("\n", idx1);
+ auto stepping = dmesgboot_str.substr(idx1, idx2 - idx1);
+ setInfo(eStepping, std::stoi(stepping));
+
+ if (dmesgboot_str.find(",SSE,") != string::npos)
+ setExtension(cpu_feature_names[eSSE_Ext]);
+
+ if (dmesgboot_str.find(",SSE2,") != string::npos)
+ setExtension(cpu_feature_names[eSSE2_Ext]);
+
+ if (dmesgboot_str.find("<SSE3,") != string::npos)
+ setExtension(cpu_feature_names[eSSE3_Features]);
+
+ if (dmesgboot_str.find(",SSSE3,") != string::npos)
+ setExtension(cpu_feature_names[eSSE3S_Features]);
+
+ if (dmesgboot_str.find(",SSE4.1,") != string::npos)
+ setExtension(cpu_feature_names[eSSE4_1_Features]);
+
+ if (dmesgboot_str.find(",SSE4.2,") != string::npos)
+ setExtension(cpu_feature_names[eSSE4_2_Features]);
+
+ if (dmesgboot_str.find(",SSE4A,") != string::npos)
+ setExtension(cpu_feature_names[eSSE4a_Features]);
+ }
+
+ virtual ~LLProcessorInfoFreeBSDImpl() {}
+};
+
#elif LL_LINUX
const char CPUINFO_FILE[] = "/proc/cpuinfo";
@@ -972,6 +1075,9 @@ LLProcessorInfo::LLProcessorInfo() : mImpl(NULL)
#elif LL_DARWIN
static LLProcessorInfoDarwinImpl the_impl;
mImpl = &the_impl;
+#elif LL_FREEBSD
+ static LLProcessorInfoFreeBSDImpl the_impl;
+ mImpl = &the_impl;
#else
static LLProcessorInfoLinuxImpl the_impl;
mImpl = &the_impl;