$OpenBSD: patch-base_system_sys_info_openbsd_cc,v 1.2 2019/03/24 12:24:44 robert Exp $

Index: base/system/sys_info_openbsd.cc
--- base/system/sys_info_openbsd.cc.orig
+++ base/system/sys_info_openbsd.cc
@@ -29,6 +29,10 @@ int64_t AmountOfMemory(int pages_name) {
 
 namespace base {
 
+// pledge(2)
+int64_t aofpmem = 0;
+int64_t aofapmem = 0;
+
 // static
 int SysInfo::NumberOfProcessors() {
   int mib[] = {CTL_HW, HW_NCPU};
@@ -43,26 +47,20 @@ int SysInfo::NumberOfProcessors() {
 
 // static
 int64_t SysInfo::AmountOfPhysicalMemoryImpl() {
-  return AmountOfMemory(_SC_PHYS_PAGES);
+  // pledge(2)
+  if (!aofpmem)
+    aofpmem = AmountOfMemory(_SC_PHYS_PAGES);
+  return aofpmem;
 }
 
 // static
 int64_t SysInfo::AmountOfAvailablePhysicalMemoryImpl() {
   // We should add inactive file-backed memory also but there is no such
   // information from OpenBSD unfortunately.
-  return AmountOfMemory(_SC_AVPHYS_PAGES);
-}
-
-// static
-uint64_t SysInfo::MaxSharedMemorySize() {
-  int mib[] = {CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX};
-  size_t limit;
-  size_t size = sizeof(limit);
-  if (sysctl(mib, base::size(mib), &limit, &size, NULL, 0) < 0) {
-    NOTREACHED();
-    return 0;
-  }
-  return static_cast<uint64_t>(limit);
+  // pledge(2)
+  if (!aofapmem)
+    aofapmem = AmountOfMemory(_SC_AVPHYS_PAGES);
+  return aofapmem;
 }
 
 // static
