Changes required to support FreeBSD

This commit is contained in:
Graeme Geldenhuys
2021-12-12 00:35:46 +00:00
parent 80beccb2c4
commit 7179e75e70
16 changed files with 94 additions and 20 deletions

View File

@ -320,7 +320,7 @@ Description: Make it so that the QIcon loader honors /usr/share/pixmaps
icon theme specification.
Bug: https://bugreports.qt.nokia.com/browse/QTBUG-12874
*********************************************************************/
#ifdef Q_OS_LINUX
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
/* Freedesktop standard says to look in /usr/share/pixmaps last */
if (entries.isEmpty())
{

View File

@ -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
}