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

Side by Side Diff: base/sys_info_ios.mm

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_internal.h ('k') | base/sys_info_linux.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <mach/mach.h> 7 #include <mach/mach.h>
8 #include <sys/sysctl.h> 8 #include <sys/sysctl.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #import <UIKit/UIKit.h> 10 #import <UIKit/UIKit.h>
(...skipping 25 matching lines...) Expand all
36 static std::string* system_version; 36 static std::string* system_version;
37 dispatch_once(&get_system_version_once, ^{ 37 dispatch_once(&get_system_version_once, ^{
38 base::mac::ScopedNSAutoreleasePool pool; 38 base::mac::ScopedNSAutoreleasePool pool;
39 system_version = new std::string( 39 system_version = new std::string(
40 SysNSStringToUTF8([[UIDevice currentDevice] systemVersion])); 40 SysNSStringToUTF8([[UIDevice currentDevice] systemVersion]));
41 }); 41 });
42 return *system_version; 42 return *system_version;
43 } 43 }
44 44
45 // static 45 // static
46 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, 46 void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version,
47 int32* minor_version, 47 int32_t* minor_version,
48 int32* bugfix_version) { 48 int32_t* bugfix_version) {
49 base::mac::ScopedNSAutoreleasePool pool; 49 base::mac::ScopedNSAutoreleasePool pool;
50 std::string system_version = OperatingSystemVersion(); 50 std::string system_version = OperatingSystemVersion();
51 if (!system_version.empty()) { 51 if (!system_version.empty()) {
52 // Try to parse out the version numbers from the string. 52 // Try to parse out the version numbers from the string.
53 int num_read = sscanf(system_version.c_str(), "%d.%d.%d", major_version, 53 int num_read = sscanf(system_version.c_str(), "%d.%d.%d", major_version,
54 minor_version, bugfix_version); 54 minor_version, bugfix_version);
55 if (num_read < 1) 55 if (num_read < 1)
56 *major_version = 0; 56 *major_version = 0;
57 if (num_read < 2) 57 if (num_read < 2)
58 *minor_version = 0; 58 *minor_version = 0;
59 if (num_read < 3) 59 if (num_read < 3)
60 *bugfix_version = 0; 60 *bugfix_version = 0;
61 } 61 }
62 } 62 }
63 63
64 // static 64 // static
65 int64 SysInfo::AmountOfPhysicalMemory() { 65 int64_t SysInfo::AmountOfPhysicalMemory() {
66 struct host_basic_info hostinfo; 66 struct host_basic_info hostinfo;
67 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; 67 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
68 base::mac::ScopedMachSendRight host(mach_host_self()); 68 base::mac::ScopedMachSendRight host(mach_host_self());
69 int result = host_info(host.get(), 69 int result = host_info(host.get(),
70 HOST_BASIC_INFO, 70 HOST_BASIC_INFO,
71 reinterpret_cast<host_info_t>(&hostinfo), 71 reinterpret_cast<host_info_t>(&hostinfo),
72 &count); 72 &count);
73 if (result != KERN_SUCCESS) { 73 if (result != KERN_SUCCESS) {
74 NOTREACHED(); 74 NOTREACHED();
75 return 0; 75 return 0;
76 } 76 }
77 DCHECK_EQ(HOST_BASIC_INFO_COUNT, count); 77 DCHECK_EQ(HOST_BASIC_INFO_COUNT, count);
78 return static_cast<int64>(hostinfo.max_mem); 78 return static_cast<int64_t>(hostinfo.max_mem);
79 } 79 }
80 80
81 // static 81 // static
82 int64 SysInfo::AmountOfAvailablePhysicalMemory() { 82 int64_t SysInfo::AmountOfAvailablePhysicalMemory() {
83 base::mac::ScopedMachSendRight host(mach_host_self()); 83 base::mac::ScopedMachSendRight host(mach_host_self());
84 vm_statistics_data_t vm_info; 84 vm_statistics_data_t vm_info;
85 mach_msg_type_number_t count = HOST_VM_INFO_COUNT; 85 mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
86 if (host_statistics(host.get(), 86 if (host_statistics(host.get(),
87 HOST_VM_INFO, 87 HOST_VM_INFO,
88 reinterpret_cast<host_info_t>(&vm_info), 88 reinterpret_cast<host_info_t>(&vm_info),
89 &count) != KERN_SUCCESS) { 89 &count) != KERN_SUCCESS) {
90 NOTREACHED(); 90 NOTREACHED();
91 return 0; 91 return 0;
92 } 92 }
93 93
94 return static_cast<int64>( 94 return static_cast<int64_t>(vm_info.free_count - vm_info.speculative_count) *
95 vm_info.free_count - vm_info.speculative_count) * PAGE_SIZE; 95 PAGE_SIZE;
96 } 96 }
97 97
98 // static 98 // static
99 std::string SysInfo::CPUModelName() { 99 std::string SysInfo::CPUModelName() {
100 char name[256]; 100 char name[256];
101 size_t len = arraysize(name); 101 size_t len = arraysize(name);
102 if (sysctlbyname("machdep.cpu.brand_string", &name, &len, NULL, 0) == 0) 102 if (sysctlbyname("machdep.cpu.brand_string", &name, &len, NULL, 0) == 0)
103 return name; 103 return name;
104 return std::string(); 104 return std::string();
105 } 105 }
106 106
107 } // namespace base 107 } // namespace base
OLDNEW
« no previous file with comments | « base/sys_info_internal.h ('k') | base/sys_info_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698