Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(734)

Unified Diff: base/sys_info_posix.cc

Issue 425010: implement SysInfo::MaxSharedMemorySize for openbsd using... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_posix.cc
===================================================================
--- base/sys_info_posix.cc (revision 32601)
+++ base/sys_info_posix.cc (working copy)
@@ -15,7 +15,9 @@
#endif
#if defined(OS_OPENBSD)
+#include <stdlib.h>
#include <sys/param.h>
+#include <sys/shm.h>
#include <sys/sysctl.h>
#endif
@@ -171,6 +173,35 @@
return limit;
}
+#elif defined(OS_OPENBSD)
+size_t SysInfo::MaxSharedMemorySize() {
+ int mib[3], valid;
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_SYSVSHM;
+ size_t len = sizeof(valid);
+ if (sysctl(mib, 2, &valid, &len, NULL, NULL) < 0) {
+ return -1;
+ }
+ if (!valid) {
+ return -1;
+ }
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_SYSVIPC_INFO;
+ mib[2] = KERN_SYSVIPC_SHM_INFO;
+ len = sizeof(struct shminfo);
+ void *buf = malloc(len);
+ if (buf == NULL) {
+ return -1;
+ }
+ struct shm_sysctl_info *shmsi = (struct shm_sysctl_info *)buf;
djm 2009/12/09 02:25:58 Why do you allocate this by malloc and not automat
pvalchev 2009/12/09 19:08:22 No reason, refactoring that got left behind :) Thx
+ if (sysctl(mib, 3, shmsi, &len, NULL, NULL) < 0) {
+ return -1;
+ }
+
+ return shmsi->shminfo.shmmax;
+}
#endif
} // namespace base
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698