From bcab7e348022eb219ab1beafe7bb0e64f66495f0 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Wed, 12 Jul 2023 14:43:01 +0800 Subject: Operating system info implementation for FreeBSD --- indra/llcommon/llsys.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/llsys.cpp') 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 const char MEMINFO_FILE[] = "/proc/meminfo"; # include +#elif LL_FREEBSD +# include +# include #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); -- cgit v1.2.3 From eadd80cf95cc25565a3bdcea179503d21ba5ae11 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Thu, 17 Aug 2023 20:57:43 +0800 Subject: GLibc related code is used only on a GNU system --- indra/llcommon/llsys.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llcommon/llsys.cpp') diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 8c4e0988fc..457ced7fae 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -82,7 +82,9 @@ using namespace llsd; # include # include const char MEMINFO_FILE[] = "/proc/meminfo"; +#ifdef __GNU__ # include +#endif #elif LL_FREEBSD # include # include @@ -353,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) ) { @@ -411,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 -- cgit v1.2.3