OLD | NEW |
---|---|
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 <errno.h> | 7 #include <errno.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 NOTREACHED(); | 106 NOTREACHED(); |
107 return std::string(); | 107 return std::string(); |
108 } | 108 } |
109 return std::string(info.sysname); | 109 return std::string(info.sysname); |
110 } | 110 } |
111 #endif | 111 #endif |
112 | 112 |
113 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 113 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
114 // static | 114 // static |
115 std::string SysInfo::OperatingSystemVersion() { | 115 std::string SysInfo::OperatingSystemVersion() { |
116 struct utsname info; | 116 static struct utsname info = {}; |
117 if (uname(&info) < 0) { | 117 if (!strlen(info.release) && uname(&info) < 0) { |
piman
2016/05/06 19:53:11
This is not thread safe. Why the change?
Julien Isorce Samsung
2016/05/07 08:18:13
Txh for pointing that, well I made this change bec
| |
118 NOTREACHED(); | 118 NOTREACHED(); |
119 return std::string(); | 119 return std::string(); |
120 } | 120 } |
121 return std::string(info.release); | 121 return std::string(info.release); |
122 } | 122 } |
123 #endif | 123 #endif |
124 | 124 |
125 // static | 125 // static |
126 std::string SysInfo::OperatingSystemArchitecture() { | 126 std::string SysInfo::OperatingSystemArchitecture() { |
127 struct utsname info; | 127 struct utsname info; |
128 if (uname(&info) < 0) { | 128 if (uname(&info) < 0) { |
129 NOTREACHED(); | 129 NOTREACHED(); |
130 return std::string(); | 130 return std::string(); |
131 } | 131 } |
132 std::string arch(info.machine); | 132 std::string arch(info.machine); |
133 if (arch == "i386" || arch == "i486" || arch == "i586" || arch == "i686") { | 133 if (arch == "i386" || arch == "i486" || arch == "i586" || arch == "i686") { |
134 arch = "x86"; | 134 arch = "x86"; |
135 } else if (arch == "amd64") { | 135 } else if (arch == "amd64") { |
136 arch = "x86_64"; | 136 arch = "x86_64"; |
137 } | 137 } |
138 return arch; | 138 return arch; |
139 } | 139 } |
140 | 140 |
141 // static | 141 // static |
142 size_t SysInfo::VMAllocationGranularity() { | 142 size_t SysInfo::VMAllocationGranularity() { |
143 return getpagesize(); | 143 return getpagesize(); |
144 } | 144 } |
145 | 145 |
146 } // namespace base | 146 } // namespace base |
OLD | NEW |