summaryrefslogtreecommitdiffstats
path: root/games/multimc/files/patch-libraries_systeminfo_src_sys__unix.cpp
blob: 74e972ddafa29a3df5feb00308c550cb57748dd7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
--- libraries/systeminfo/src/sys_unix.cpp.orig	2021-09-08 22:27:46 UTC
+++ libraries/systeminfo/src/sys_unix.cpp
@@ -47,6 +47,7 @@ Sys::KernelInfo Sys::getKernelInfo()
 uint64_t Sys::getSystemRam()
 {
     std::string token;
+	#ifdef Q_OS_LINUX
     std::ifstream file("/proc/meminfo");
     while(file >> token)
     {
@@ -65,6 +66,19 @@ uint64_t Sys::getSystemRam()
         // ignore rest of the line
         file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
     }
+	#elif defined Q_OS_FREEBSD
+	char buff[512];
+	FILE *fp = popen("sysctl hw.physmem", "r");
+	if (fp != NULL)
+	{
+		while(fgets(buff, 512, fp) != NULL)
+		{
+			std::string str(buff);
+			uint64_t mem = std::stoull(str.substr(12, std::string::npos));
+			return mem * 1024ull;
+		}
+	}
+	#endif
     return 0; // nothing found
 }