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