summaryrefslogtreecommitdiff
path: root/www/chromium-uc/patches/patch-base_system_sys_info_openbsd_cc
diff options
context:
space:
mode:
Diffstat (limited to 'www/chromium-uc/patches/patch-base_system_sys_info_openbsd_cc')
-rw-r--r--www/chromium-uc/patches/patch-base_system_sys_info_openbsd_cc103
1 files changed, 103 insertions, 0 deletions
diff --git a/www/chromium-uc/patches/patch-base_system_sys_info_openbsd_cc b/www/chromium-uc/patches/patch-base_system_sys_info_openbsd_cc
new file mode 100644
index 0000000..d8987cf
--- /dev/null
+++ b/www/chromium-uc/patches/patch-base_system_sys_info_openbsd_cc
@@ -0,0 +1,103 @@
1$OpenBSD: patch-base_system_sys_info_openbsd_cc,v 1.7 2021/09/01 16:54:38 robert Exp $
2
3Index: base/system/sys_info_openbsd.cc
4--- base/system/sys_info_openbsd.cc.orig
5+++ base/system/sys_info_openbsd.cc
6@@ -12,6 +12,7 @@
7
8 #include "base/cxx17_backports.h"
9 #include "base/notreached.h"
10+#include "base/strings/string_util.h"
11
12 namespace {
13
14@@ -29,9 +30,14 @@ int64_t AmountOfMemory(int pages_name) {
15
16 namespace base {
17
18+// pledge(2)
19+int64_t aofpmem = 0;
20+int64_t aofapmem = 0;
21+int64_t shmmax = 0;
22+
23 // static
24 int SysInfo::NumberOfProcessors() {
25- int mib[] = {CTL_HW, HW_NCPU};
26+ int mib[] = {CTL_HW, HW_NCPUONLINE};
27 int ncpu;
28 size_t size = sizeof(ncpu);
29 if (sysctl(mib, base::size(mib), &ncpu, &size, NULL, 0) < 0) {
30@@ -43,38 +49,61 @@ int SysInfo::NumberOfProcessors() {
31
32 // static
33 int64_t SysInfo::AmountOfPhysicalMemoryImpl() {
34- return AmountOfMemory(_SC_PHYS_PAGES);
35+ // pledge(2)
36+ if (!aofpmem)
37+ aofpmem = AmountOfMemory(_SC_PHYS_PAGES);
38+ return aofpmem;
39 }
40
41 // static
42 int64_t SysInfo::AmountOfAvailablePhysicalMemoryImpl() {
43 // We should add inactive file-backed memory also but there is no such
44 // information from OpenBSD unfortunately.
45- return AmountOfMemory(_SC_AVPHYS_PAGES);
46+ // pledge(2)
47+ if (!aofapmem)
48+ aofapmem = AmountOfMemory(_SC_AVPHYS_PAGES);
49+ return aofapmem;
50 }
51
52 // static
53+std::string SysInfo::CPUModelName() {
54+ int mib[] = {CTL_HW, HW_MODEL};
55+ char name[256];
56+ size_t len = base::size(name);
57+ if (sysctl(mib, base::size(mib), name, &len, NULL, 0) < 0) {
58+ NOTREACHED();
59+ return std::string();
60+ }
61+ return name;
62+}
63+
64+// static
65 uint64_t SysInfo::MaxSharedMemorySize() {
66 int mib[] = {CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX};
67 size_t limit;
68 size_t size = sizeof(limit);
69+ // pledge(2)
70+ if (shmmax)
71+ goto out;
72 if (sysctl(mib, base::size(mib), &limit, &size, NULL, 0) < 0) {
73 NOTREACHED();
74 return 0;
75 }
76- return static_cast<uint64_t>(limit);
77+ shmmax = static_cast<uint64_t>(limit);
78+out:
79+ return shmmax;
80 }
81
82 // static
83-std::string SysInfo::CPUModelName() {
84- int mib[] = {CTL_HW, HW_MODEL};
85- char name[256];
86- size_t len = base::size(name);
87- if (sysctl(mib, base::size(mib), name, &len, NULL, 0) < 0) {
88- NOTREACHED();
89- return std::string();
90- }
91- return name;
92+SysInfo::HardwareInfo SysInfo::GetHardwareInfoSync() {
93+ HardwareInfo info;
94+ // Set the manufacturer to "OpenBSD" and the model to
95+ // an empty string.
96+ info.manufacturer = "OpenBSD";
97+ info.model = HardwareModelName();
98+ DCHECK(IsStringUTF8(info.manufacturer));
99+ DCHECK(IsStringUTF8(info.model));
100+ return info;
101 }
102
103 } // namespace base