summaryrefslogtreecommitdiff
path: root/www/webkitgtk4/patches/patch-Source_bmalloc_bmalloc_AvailableMemory_cpp
diff options
context:
space:
mode:
Diffstat (limited to 'www/webkitgtk4/patches/patch-Source_bmalloc_bmalloc_AvailableMemory_cpp')
-rw-r--r--www/webkitgtk4/patches/patch-Source_bmalloc_bmalloc_AvailableMemory_cpp90
1 files changed, 0 insertions, 90 deletions
diff --git a/www/webkitgtk4/patches/patch-Source_bmalloc_bmalloc_AvailableMemory_cpp b/www/webkitgtk4/patches/patch-Source_bmalloc_bmalloc_AvailableMemory_cpp
deleted file mode 100644
index 107220b..0000000
--- a/www/webkitgtk4/patches/patch-Source_bmalloc_bmalloc_AvailableMemory_cpp
+++ /dev/null
@@ -1,90 +0,0 @@
1Index: Source/bmalloc/bmalloc/AvailableMemory.cpp
2--- Source/bmalloc/bmalloc/AvailableMemory.cpp.orig
3+++ Source/bmalloc/bmalloc/AvailableMemory.cpp
4@@ -44,13 +44,15 @@
5 #import <mach/mach_error.h>
6 #import <math.h>
7 #elif BOS(UNIX)
8-#if BOS(FREEBSD) || BOS(LINUX)
9+#if BOS(OPENBSD)
10+#include <kvm.h>
11+#elif BOS(FREEBSD) || BOS(LINUX)
12 #include <sys/sysinfo.h>
13 #endif
14 #if BOS(LINUX)
15 #include <algorithm>
16 #include <fcntl.h>
17-#elif BOS(FREEBSD)
18+#elif BOS(FREEBSD) || BOS(OPENBSD)
19 #include "VMAllocate.h"
20 #include <sys/sysctl.h>
21 #include <sys/types.h>
22@@ -166,6 +168,24 @@ static size_t computeAvailableMemory()
23 if (!sysinfo(&info))
24 return info.totalram * info.mem_unit;
25 return availableMemoryGuess;
26+#elif BOS(OPENBSD)
27+ struct uvmexp uvmexp;
28+ size_t length;
29+ static int uvmexp_mib [] = { CTL_VM, VM_UVMEXP };
30+ long pages;
31+ long pageSize = sysconf(_SC_PAGE_SIZE);
32+ if (pageSize == -1)
33+ return availableMemoryGuess;
34+ length = sizeof (uvmexp);
35+ if (sysctl(uvmexp_mib, std::size(uvmexp_mib), &uvmexp, &length, NULL, 0) == 0)
36+ return uvmexp.npages * pageSize;
37+ else {
38+ bzero(&uvmexp, sizeof(length));
39+ pages = sysconf(_SC_PHYS_PAGES);
40+ if (pages == -1)
41+ return availableMemoryGuess;
42+ return pages * pageSize;
43+ }
44 #elif BOS(UNIX)
45 long pages = sysconf(_SC_PHYS_PAGES);
46 long pageSize = sysconf(_SC_PAGE_SIZE);
47@@ -180,14 +200,19 @@ static size_t computeAvailableMemory()
48 size_t availableMemory()
49 {
50 static size_t availableMemory;
51+#if BOS(OPENBSD)
52+ // We always calculate the available memory because we take care...
53+ availableMemory = computeAvailableMemory();
54+#else
55 static std::once_flag onceFlag;
56 std::call_once(onceFlag, [] {
57 availableMemory = computeAvailableMemory();
58 });
59+#endif
60 return availableMemory;
61 }
62
63-#if BPLATFORM(IOS_FAMILY) || BOS(LINUX) || BOS(FREEBSD)
64+#if BPLATFORM(IOS_FAMILY) || BOS(LINUX) || BOS(FREEBSD) || BOS(OPENBSD)
65 MemoryStatus memoryStatus()
66 {
67 #if BPLATFORM(IOS_FAMILY)
68@@ -213,6 +238,22 @@ MemoryStatus memoryStatus()
69 size_t memoryFootprint = 0;
70 if (!sysctl(mib, 4, &info, &infolen, nullptr, 0))
71 memoryFootprint = static_cast<size_t>(info.ki_rssize) * vmPageSize();
72+#elif BOS(OPENBSD)
73+ size_t memoryFootprint = 0, length;
74+ struct kinfo_proc *info;
75+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid(), sizeof(struct kinfo_proc), 0 };
76+
77+ if (sysctl(mib, std::size(mib), NULL, &length, NULL, 0) == 0) {
78+ info = (struct kinfo_proc *)malloc(length);
79+ mib[5] = (length / sizeof(struct kinfo_proc));
80+ if (sysctl(mib, std::size(mib), info, &length, NULL, 0) == 0) {
81+ memoryFootprint = static_cast<size_t>(
82+ info->p_vm_tsize +
83+ info->p_vm_dsize +
84+ info->p_vm_ssize) * vmPageSize();
85+ }
86+ free(info);
87+ }
88 #endif
89
90 double percentInUse = static_cast<double>(memoryFootprint) / static_cast<double>(availableMemory());