aqemu: add platform specific code to get memory size (#4422)

* aqemu: add platform specific code to get memory size
This commit is contained in:
TURX
2020-01-21 19:21:08 +08:00
committed by Schrijvers Luc
parent 2cc2710b77
commit 5d8c770810

View File

@@ -1,29 +1,41 @@
From 44d7e9a4ebb1062d5949f5a5d8e6346ad6cec8e9 Mon Sep 17 00:00:00 2001
From: Sergei Reznikov <diver@gelios.net>
Date: Tue, 5 Dec 2017 09:27:36 +0300
Subject: Fix build on Haiku
From: Ruixuan Tu <turx2003@gmail.com>
Date: Wed, 4 Dec 2019 21:00:00 +0800
Subject: GCi 2019 Task - Aqemu - Add platform specific code to get memory size
diff --git a/src/Add_Port_Window.cpp b/src/Add_Port_Window.cpp
index 116122c..9839aa8 100644
index 116122c..46b8e27 100644
--- a/src/Add_Port_Window.cpp
+++ b/src/Add_Port_Window.cpp
@@ -32,6 +32,10 @@ Add_Port_Window::Add_Port_Window( QWidget *parent )
#ifdef Q_OS_UNIX
ui.RB_stdio->setEnabled( true );
@@ -41,7 +41,11 @@ Add_Port_Window::Add_Port_Window( QWidget *parent )
#ifdef Q_OS_WIN32
ui.RB_COM->setEnabled( true );
#endif
-
+
+ #ifdef Q_OS_HAIKU
+ ui.RB_stdio->setEnabled( true );
+ ui.RB_stdio->setEnabled(true);
+ #endif
#ifdef Q_OS_LINUX
ui.RB_pty->setEnabled( true );
+
Connect_Slots();
}
diff --git a/src/System_Info.cpp b/src/System_Info.cpp
index fcbc984..5e368a5 100644
index fcbc984..37bc8d7 100644
--- a/src/System_Info.cpp
+++ b/src/System_Info.cpp
@@ -2098,7 +2098,7 @@ bool System_Info::Delete_From_Used_USB_List( const VM_USB &device )
@@ -31,6 +31,10 @@
#include "Utils.h"
#include "System_Info.h"
+#ifdef Q_OS_HAIKU
+#include <OS.h>
+#endif
+
System_Info::System_Info()
{
}
@@ -2098,7 +2102,7 @@ bool System_Info::Delete_From_Used_USB_List( const VM_USB &device )
return Used_Host_USB.removeOne( device );
}
@@ -32,30 +44,41 @@ index fcbc984..5e368a5 100644
bool System_Info::Update_Host_USB()
{
@@ -2503,7 +2503,7 @@ bool System_Info::Scan_USB_Proc( QList<VM_USB> &list )
@@ -2503,7 +2507,10 @@ bool System_Info::Scan_USB_Proc( QList<VM_USB> &list )
return true;
}
-#include <sys/sysinfo.h>
+//#include <sys/sysinfo.h>
+#ifndef Q_OS_HAIKU
#include <sys/sysinfo.h>
+#endif
+
#include <QDir>
#include <QFileInfoList>
@@ -2595,12 +2595,12 @@ void System_Info::Get_Free_Memory_Size( int &allRAM, int &freeRAM )
@@ -2595,11 +2602,23 @@ void System_Info::Get_Free_Memory_Size( int &allRAM, int &freeRAM )
}
// If proc fs not exists
- struct sysinfo sysInfo;
+/* struct sysinfo sysInfo;
+
+#ifdef Q_OS_HAIKU
+ system_info sysinfo;
+ get_system_info(&sysinfo);
+
+ uint64 tmp;
+ tmp = (sysinfo.max_pages + sysinfo.ignored_pages) * B_PAGE_SIZE;
+ allRAM = (int)(tmp / 1024.0 / 1024.0);
+
+ freeRAM = (int)(sysinfo.free_memory / 1024.0 / 1024.0);
+#else
struct sysinfo sysInfo;
sysinfo( &sysInfo );
allRAM = (int)(unsigned long)(sysInfo.totalram * sysInfo.mem_unit) / 1024.0 / 1024.0;
freeRAM = (int)(unsigned long)((sysInfo.freeram + sysInfo.bufferram) * sysInfo.mem_unit) / 1024.0 / 1024.0;
-}
+*/}
+#endif
}
QStringList System_Info::Get_Host_FDD_List()
{
diff --git a/src/System_Info.h b/src/System_Info.h
index d0e2f35..fe325f7 100644
--- a/src/System_Info.h
@@ -70,78 +93,15 @@ index d0e2f35..fe325f7 100644
static bool Scan_USB_Proc( QList<VM_USB> &list );
static bool Read_SysFS_File( const QString &path, QString &data );
diff --git a/src/main.cpp b/src/main.cpp
index 40a3c61..ace8799 100644
index 46c96b6..c8ad196 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -240,7 +240,7 @@ int main( int argc, char *argv[] )
// Find Data Folder
if( settings.value("AQEMU_Data_Folder", "").toString().isEmpty() )
{
- #ifdef Q_OS_WIN32
+ #if defined Q_OS_WIN32 || defined Q_OS_HAIKU
if( QDir(QDir::currentPath() + "\\os_icons").exists() &&
QDir(QDir::currentPath() + "\\os_templates").exists() )
{
--
2.15.0
From 5ee1bb6c08ba39e6aeb494b14fe1601664ef752f Mon Sep 17 00:00:00 2001
From: Ho Tuan Kiet <tuankiet65@gmail.com>
Date: Sun, 24 Dec 2017 07:22:22 +0000
Subject: Fix total/free memory detection on Haiku
diff --git a/src/System_Info.cpp b/src/System_Info.cpp
index 5e368a5..6108df7 100644
--- a/src/System_Info.cpp
+++ b/src/System_Info.cpp
@@ -2595,12 +2595,23 @@ void System_Info::Get_Free_Memory_Size( int &allRAM, int &freeRAM )
}
// If proc fs not exists
-/* struct sysinfo sysInfo;
- sysinfo( &sysInfo );
-
- allRAM = (int)(unsigned long)(sysInfo.totalram * sysInfo.mem_unit) / 1024.0 / 1024.0;
- freeRAM = (int)(unsigned long)((sysInfo.freeram + sysInfo.bufferram) * sysInfo.mem_unit) / 1024.0 / 1024.0;
-*/}
+ #ifdef Q_OS_HAIKU
+ system_info sysinfo;
+ get_system_info(&sysinfo);
+
+ uint64 tmp;
+ tmp = (sysinfo.max_pages + sysinfo.ignored_pages) * B_PAGE_SIZE;
+ allRAM = (int)(tmp / 1024.0 / 1024.0);
+
+ freeRAM = (int)(sysinfo.free_memory / 1024.0 / 1024.0);
+ #else
+ struct sysinfo sysInfo;
+ sysinfo( &sysInfo );
+
+ allRAM = (int)(unsigned long)(sysInfo.totalram * sysInfo.mem_unit) / 1024.0 / 1024.0;
+ freeRAM = (int)(unsigned long)((sysInfo.freeram + sysInfo.bufferram) * sysInfo.mem_unit) / 1024.0 / 1024.0;
+ #endif
+}
QStringList System_Info::Get_Host_FDD_List()
{
diff --git a/src/System_Info.h b/src/System_Info.h
index fe325f7..64c0e41 100644
--- a/src/System_Info.h
+++ b/src/System_Info.h
@@ -26,6 +26,11 @@
#include "Utils.h"
#include "VM_Devices.h"
+#ifdef Q_OS_HAIKU
+// for memory size detection
+#include <OS.h>
+#endif
+
class System_Info
{
public:
--
2.15.0
@@ -361,7 +361,7 @@ int AQEMU_Main::find_data_folders()
// Find Data Folder
if( settings->value("AQEMU_Data_Folder", "").toString().isEmpty() )
{
- #ifdef Q_OS_WIN32
+ #if defined Q_OS_WIN32 || defined Q_OS_HAIKU
if( QDir(QDir::currentPath() + "\\os_icons").exists() &&
QDir(QDir::currentPath() + "\\os_templates").exists() )
{