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

Side by Side Diff: base/sys_info_posix.cc

Issue 151202: Remove sysctl-read workarounds (Closed)
Patch Set: Created 11 years, 5 months 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
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 #include "base/basictypes.h" 6 #include "base/basictypes.h"
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <string.h> 9 #include <string.h>
10 #include <sys/statvfs.h> 10 #include <sys/statvfs.h>
(...skipping 21 matching lines...) Expand all
32 int ncpu; 32 int ncpu;
33 size_t size = sizeof(ncpu); 33 size_t size = sizeof(ncpu);
34 if (sysctl(mib, 2, &ncpu, &size, NULL, 0) == -1) { 34 if (sysctl(mib, 2, &ncpu, &size, NULL, 0) == -1) {
35 NOTREACHED(); 35 NOTREACHED();
36 return 1; 36 return 1;
37 } 37 }
38 return ncpu; 38 return ncpu;
39 #else 39 #else
40 // It seems that sysconf returns the number of "logical" processors on both 40 // It seems that sysconf returns the number of "logical" processors on both
41 // mac and linux. So we get the number of "online logical" processors. 41 // mac and linux. So we get the number of "online logical" processors.
42 static long res = sysconf(_SC_NPROCESSORS_ONLN); 42 long res = sysconf(_SC_NPROCESSORS_ONLN);
43 if (res == -1) { 43 if (res == -1) {
44 NOTREACHED(); 44 NOTREACHED();
45 return 1; 45 return 1;
46 } 46 }
47 47
48 return static_cast<int>(res); 48 return static_cast<int>(res);
49 #endif 49 #endif
50 } 50 }
51 51
52 // static 52 // static
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 NOTIMPLEMENTED(); 144 NOTIMPLEMENTED();
145 return 1; 145 return 1;
146 } 146 }
147 147
148 // static 148 // static
149 size_t SysInfo::VMAllocationGranularity() { 149 size_t SysInfo::VMAllocationGranularity() {
150 return getpagesize(); 150 return getpagesize();
151 } 151 }
152 152
153 } // namespace base 153 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698