Chromium Code Reviews| 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 |