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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/sys_info.h" 5 #include "base/sys_info.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/statvfs.h> 9 #include <sys/statvfs.h>
10 #include <sys/utsname.h> 10 #include <sys/utsname.h>
11 #include <unistd.h> 11 #include <unistd.h>
12 12
13 #if !defined(OS_MACOSX) 13 #if !defined(OS_MACOSX)
14 #include <gdk/gdk.h> 14 #include <gdk/gdk.h>
15 #endif 15 #endif
16 16
17 #if defined(OS_OPENBSD) 17 #if defined(OS_OPENBSD)
18 #include <stdlib.h>
18 #include <sys/param.h> 19 #include <sys/param.h>
20 #include <sys/shm.h>
19 #include <sys/sysctl.h> 21 #include <sys/sysctl.h>
20 #endif 22 #endif
21 23
22 #include "base/basictypes.h" 24 #include "base/basictypes.h"
23 #include "base/file_util.h" 25 #include "base/file_util.h"
24 #include "base/logging.h" 26 #include "base/logging.h"
25 #include "base/utf_string_conversions.h" 27 #include "base/utf_string_conversions.h"
26 28
27 namespace base { 29 namespace base {
28 30
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 166
165 if (!limit_valid) { 167 if (!limit_valid) {
166 std::string contents; 168 std::string contents;
167 file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents); 169 file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents);
168 limit = strtoul(contents.c_str(), NULL, 0); 170 limit = strtoul(contents.c_str(), NULL, 0);
169 limit_valid = true; 171 limit_valid = true;
170 } 172 }
171 173
172 return limit; 174 return limit;
173 } 175 }
176 #elif defined(OS_OPENBSD)
177 size_t SysInfo::MaxSharedMemorySize() {
178 int mib[3], valid;
179
180 mib[0] = CTL_KERN;
181 mib[1] = KERN_SYSVSHM;
182 size_t len = sizeof(valid);
183 if (sysctl(mib, 2, &valid, &len, NULL, NULL) < 0) {
184 return -1;
185 }
186 if (!valid) {
187 return -1;
188 }
189
190 mib[0] = CTL_KERN;
191 mib[1] = KERN_SYSVIPC_INFO;
192 mib[2] = KERN_SYSVIPC_SHM_INFO;
193 len = sizeof(struct shminfo);
194 void *buf = malloc(len);
195 if (buf == NULL) {
196 return -1;
197 }
198 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
199 if (sysctl(mib, 3, shmsi, &len, NULL, NULL) < 0) {
200 return -1;
201 }
202
203 return shmsi->shminfo.shmmax;
204 }
174 #endif 205 #endif
175 206
176 } // namespace base 207 } // namespace base
OLDNEW
« 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