summaryrefslogtreecommitdiff
path: root/www/iridium/files/patch-base_process_process__metrics__freebsd.cc
diff options
context:
space:
mode:
Diffstat (limited to 'www/iridium/files/patch-base_process_process__metrics__freebsd.cc')
-rw-r--r--www/iridium/files/patch-base_process_process__metrics__freebsd.cc65
1 files changed, 57 insertions, 8 deletions
diff --git a/www/iridium/files/patch-base_process_process__metrics__freebsd.cc b/www/iridium/files/patch-base_process_process__metrics__freebsd.cc
index 89aa3be55bf4..e2ea325713e9 100644
--- a/www/iridium/files/patch-base_process_process__metrics__freebsd.cc
+++ b/www/iridium/files/patch-base_process_process__metrics__freebsd.cc
@@ -1,19 +1,28 @@
---- base/process/process_metrics_freebsd.cc.orig 2017-04-19 19:06:28 UTC
-+++ base/process/process_metrics_freebsd.cc
-@@ -13,6 +13,9 @@
- #include "base/memory/ptr_util.h"
- #include "base/sys_info.h"
+--- base/process/process_metrics_freebsd.cc.orig 2018-08-01 00:08:25.000000000 +0200
++++ base/process/process_metrics_freebsd.cc 2018-08-04 21:48:06.554728000 +0200
+@@ -14,11 +14,14 @@
+ #include "base/process/process_metrics_iocounters.h"
+ #include "base/stl_util.h"
+#include <unistd.h> /* getpagesize() */
+#include <fcntl.h> /* O_RDONLY */
++#include <kvm.h>
+
namespace base {
ProcessMetrics::ProcessMetrics(ProcessHandle process)
-@@ -122,4 +125,23 @@ size_t GetSystemCommitCharge() {
- return mem_total - (mem_free*pagesize) - (mem_inactive*pagesize);
- }
+- : process_(process),
+- last_cpu_(0) {}
++ : process_(process) {}
+
+ // static
+ std::unique_ptr<ProcessMetrics> ProcessMetrics::CreateProcessMetrics(
+@@ -67,6 +70,65 @@
+ pagesize = getpagesize();
+ return mem_total - (mem_free*pagesize) - (mem_inactive*pagesize);
++}
++
+int GetNumberOfThreads(ProcessHandle process) {
+ // Taken from FreeBSD top (usr.bin/top/machine.c)
+
@@ -33,4 +42,44 @@
+ return nproc;
+}
+
++bool GetSystemMemoryInfo(SystemMemoryInfoKB *meminfo) {
++ unsigned int mem_total, mem_free, swap_total, swap_used;
++ size_t length;
++ int pagesizeKB;
++
++ pagesizeKB = getpagesize() / 1024;
++
++ length = sizeof(mem_total);
++ if (sysctlbyname("vm.stats.vm.v_page_count", &mem_total,
++ &length, NULL, 0) != 0 || length != sizeof(mem_total))
++ return false;
++
++ length = sizeof(mem_free);
++ if (sysctlbyname("vm.stats.vm.v_free_count", &mem_free, &length, NULL, 0)
++ != 0 || length != sizeof(mem_free))
++ return false;
++
++ length = sizeof(swap_total);
++ if (sysctlbyname("vm.swap_size", &swap_total, &length, NULL, 0)
++ != 0 || length != sizeof(swap_total))
++ return false;
++
++ length = sizeof(swap_used);
++ if (sysctlbyname("vm.swap_anon_use", &swap_used, &length, NULL, 0)
++ != 0 || length != sizeof(swap_used))
++ return false;
++
++ meminfo->total = mem_total * pagesizeKB;
++ meminfo->free = mem_free * pagesizeKB;
++ meminfo->swap_total = swap_total * pagesizeKB;
++ meminfo->swap_free = (swap_total - swap_used) * pagesizeKB;
++
++ return true;
++}
++
++uint64_t ProcessMetrics::GetVmSwapBytes() const {
++ NOTIMPLEMENTED();
++ return 0;
+ }
+
} // namespace base