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

Side by Side Diff: base/sys_info_openbsd.cc

Issue 1498003003: Remove kint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: INT64_MAX Created 5 years 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
« no previous file with comments | « base/sys_info_mac.cc ('k') | base/sys_info_posix.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <sys/param.h> 7 #include <sys/param.h>
8 #include <sys/shm.h> 8 #include <sys/shm.h>
9 #include <sys/sysctl.h> 9 #include <sys/sysctl.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 12
13 namespace { 13 namespace {
14 14
15 int64 AmountOfMemory(int pages_name) { 15 int64_t AmountOfMemory(int pages_name) {
16 long pages = sysconf(pages_name); 16 long pages = sysconf(pages_name);
17 long page_size = sysconf(_SC_PAGESIZE); 17 long page_size = sysconf(_SC_PAGESIZE);
18 if (pages == -1 || page_size == -1) { 18 if (pages == -1 || page_size == -1) {
19 NOTREACHED(); 19 NOTREACHED();
20 return 0; 20 return 0;
21 } 21 }
22 return static_cast<int64>(pages) * page_size; 22 return static_cast<int64_t>(pages) * page_size;
23 } 23 }
24 24
25 } // namespace 25 } // namespace
26 26
27 namespace base { 27 namespace base {
28 28
29 // static 29 // static
30 int SysInfo::NumberOfProcessors() { 30 int SysInfo::NumberOfProcessors() {
31 int mib[] = { CTL_HW, HW_NCPU }; 31 int mib[] = { CTL_HW, HW_NCPU };
32 int ncpu; 32 int ncpu;
33 size_t size = sizeof(ncpu); 33 size_t size = sizeof(ncpu);
34 if (sysctl(mib, arraysize(mib), &ncpu, &size, NULL, 0) < 0) { 34 if (sysctl(mib, arraysize(mib), &ncpu, &size, NULL, 0) < 0) {
35 NOTREACHED(); 35 NOTREACHED();
36 return 1; 36 return 1;
37 } 37 }
38 return ncpu; 38 return ncpu;
39 } 39 }
40 40
41 // static 41 // static
42 int64 SysInfo::AmountOfPhysicalMemory() { 42 int64_t SysInfo::AmountOfPhysicalMemory() {
43 return AmountOfMemory(_SC_PHYS_PAGES); 43 return AmountOfMemory(_SC_PHYS_PAGES);
44 } 44 }
45 45
46 // static 46 // static
47 int64 SysInfo::AmountOfAvailablePhysicalMemory() { 47 int64_t SysInfo::AmountOfAvailablePhysicalMemory() {
48 return AmountOfMemory(_SC_AVPHYS_PAGES); 48 return AmountOfMemory(_SC_AVPHYS_PAGES);
49 } 49 }
50 50
51 // static 51 // static
52 uint64 SysInfo::MaxSharedMemorySize() { 52 uint64_t SysInfo::MaxSharedMemorySize() {
53 int mib[] = { CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX }; 53 int mib[] = { CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX };
54 size_t limit; 54 size_t limit;
55 size_t size = sizeof(limit); 55 size_t size = sizeof(limit);
56 if (sysctl(mib, arraysize(mib), &limit, &size, NULL, 0) < 0) { 56 if (sysctl(mib, arraysize(mib), &limit, &size, NULL, 0) < 0) {
57 NOTREACHED(); 57 NOTREACHED();
58 return 0; 58 return 0;
59 } 59 }
60 return static_cast<uint64>(limit); 60 return static_cast<uint64_t>(limit);
61 } 61 }
62 62
63 // static 63 // static
64 std::string SysInfo::CPUModelName() { 64 std::string SysInfo::CPUModelName() {
65 int mib[] = { CTL_HW, HW_MODEL }; 65 int mib[] = { CTL_HW, HW_MODEL };
66 char name[256]; 66 char name[256];
67 size_t len = arraysize(name); 67 size_t len = arraysize(name);
68 if (sysctl(mib, arraysize(mib), name, &len, NULL, 0) < 0) { 68 if (sysctl(mib, arraysize(mib), name, &len, NULL, 0) < 0) {
69 NOTREACHED(); 69 NOTREACHED();
70 return std::string(); 70 return std::string();
71 } 71 }
72 return name; 72 return name;
73 } 73 }
74 74
75 } // namespace base 75 } // namespace base
OLDNEW
« no previous file with comments | « base/sys_info_mac.cc ('k') | base/sys_info_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698