summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2023-07-12 14:43:01 +0800
committerErik Kundiman <erik@megapahit.org>2023-07-19 11:01:00 +0800
commitbcab7e348022eb219ab1beafe7bb0e64f66495f0 (patch)
treed3707d099d0f888130ef30993f7903a0f414d291 /indra/llcommon
parentad2aa6436a4789445e4a1c55b7e3b238f37e702b (diff)
Operating system info implementation for FreeBSD
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llsys.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 91cb65b815..8c4e0988fc 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -83,6 +83,9 @@ using namespace llsd;
# include <stdexcept>
const char MEMINFO_FILE[] = "/proc/meminfo";
# include <gnu/libc-version.h>
+#elif LL_FREEBSD
+# include <sys/sysctl.h>
+# include <sys/utsname.h>
#endif
LLCPUInfo gSysCPU;
@@ -435,6 +438,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
{
@@ -776,10 +787,14 @@ U32Kilobytes LLMemoryInfo::getPhysicalMemoryKB() const
#if LL_WINDOWS
return LLMemoryAdjustKBResult(U32Kilobytes(mStatsMap["Total Physical KB"].asInteger()));
-#elif LL_DARWIN
+#elif LL_DARWIN || LL_FREEBSD
// 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);