blob: 7f75a92202e3117b0eb4c209e61af9f748c2033a (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
--- src/ugenem/src/SendReportDialog.cpp.orig
+++ src/ugenem/src/SendReportDialog.cpp
@@ -44,6 +44,10 @@
#include <Winbase.h> //for IsProcessorFeaturePresent
#endif
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
+#include <unistd.h> // for sysconf(3)
+#endif
+
#define HOST_URL "http://ugene.unipro.ru"
//#define HOST_URL "http://127.0.0.1"
#define DESTINATION_URL_KEEPER_PAGE "/crash_reports_dest.html"
@@ -241,6 +245,8 @@ QString ReportSender::getOSVersion() {
#elif defined(Q_OS_LINUX)
result = "Linux";
+#elif defined(Q_OS_FREEBSD)
+ result = "FreeBSD";
#elif defined(Q_OS_MAC)
result = "Mac ";
switch (QSysInfo::MacintoshVersion){
@@ -304,17 +310,15 @@ int ReportSender::getTotalPhysicalMemory
totalPhysicalMemory = memory_status.ullTotalPhys / (1024 * 1024);
}
-#elif defined(Q_OS_LINUX)
- QProcess p;
- p.start("awk", QStringList() << "/MemTotal/ {print $2}" << "/proc/meminfo");
- p.waitForFinished();
- QString memory = p.readAllStandardOutput();
- p.close();
- bool ok = false;
- qlonglong output_mem = memory.toLongLong(&ok);
- if (ok) {
- totalPhysicalMemory = output_mem / 1024;
- }
+#elif defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
+ long pagesize = sysconf(_SC_PAGESIZE);
+ long numpages = sysconf(_SC_PHYS_PAGES);
+
+ // Assume that page size is always a multiple of 1024, so it can be
+ // divided without losing any precision. On the other hand, number
+ // of pages would hardly overflow `long' when multiplied by a small
+ // number (number of pages / 1024), so we should be safe here.
+ totalPhysicalMemory = (int)(numpages * (pagesize / 1024) / 1024);
#elif defined(Q_OS_MAC)
// TODO
|