summaryrefslogtreecommitdiff
path: root/indra/llcommon/llsys.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llsys.cpp')
-rw-r--r--indra/llcommon/llsys.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 938685bae6..1e0a9e815f 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -82,8 +82,13 @@ using namespace llsd;
# include <sys/sysinfo.h>
# include <stdexcept>
const char MEMINFO_FILE[] = "/proc/meminfo";
+#ifdef __GNU__
# include <gnu/libc-version.h>
#endif
+#elif LL_FREEBSD
+# include <sys/sysctl.h>
+# include <sys/utsname.h>
+#endif
LLCPUInfo gSysCPU;
@@ -350,6 +355,7 @@ LLOSInfo::LLOSInfo() :
boost::regex os_version_parse(OS_VERSION_MATCH_EXPRESSION);
boost::smatch matched;
+#ifdef __GNU__
std::string glibc_version(gnu_get_libc_version());
if ( ll_regex_match(glibc_version, matched, os_version_parse) )
{
@@ -408,6 +414,7 @@ LLOSInfo::LLOSInfo() :
{
LL_WARNS("AppInit") << "glibc version '" << glibc_version << "' cannot be parsed to three numbers; using all zeros" << LL_ENDL;
}
+#endif // __GNU__
#else
@@ -435,6 +442,14 @@ LLOSInfo::LLOSInfo() :
if (simple.length() > 0)
mOSStringSimple = simple;
}
+ else if (ostype == "FreeBSD")
+ {
+ // Only care about major and minor FreeBSD versions, truncate at first '-'
+ std::string simple = mOSStringSimple.substr(0,
+ mOSStringSimple.find_first_of("-", 0));
+ if (simple.length() > 0)
+ mOSStringSimple = simple;
+ }
}
else
{
@@ -771,13 +786,17 @@ static U32Kilobytes LLMemoryAdjustKBResult(U32Kilobytes inKB)
}
#endif
-#if LL_DARWIN
+#if LL_DARWIN || LL_FREEBSD
// static
U32Kilobytes LLMemoryInfo::getHardwareMemSize()
{
// This might work on Linux as well. Someone check...
uint64_t phys = 0;
+#if LL_DARWIN
int mib[2] = { CTL_HW, HW_MEMSIZE };
+#else
+ int mib[2] = { CTL_HW, HW_PHYSMEM };
+#endif
size_t len = sizeof(phys);
sysctl(mib, 2, &phys, &len, NULL, 0);
@@ -791,7 +810,7 @@ U32Kilobytes LLMemoryInfo::getPhysicalMemoryKB() const
#if LL_WINDOWS
return LLMemoryAdjustKBResult(U32Kilobytes(mStatsMap["Total Physical KB"].asInteger()));
-#elif LL_DARWIN
+#elif LL_DARWIN || LL_FREEBSD
return getHardwareMemSize();
#elif LL_LINUX