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

Side by Side Diff: runtime/bin/platform_win.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 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
« no previous file with comments | « runtime/bin/platform_unsupported.cc ('k') | runtime/bin/process.h » ('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 Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(HOST_OS_WINDOWS) 6 #if defined(HOST_OS_WINDOWS)
7 7
8 #include "bin/platform.h" 8 #include "bin/platform.h"
9 9
10 #include <crtdbg.h> 10 #include <crtdbg.h>
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 int PlatformWin::saved_output_cp_ = -1; 174 int PlatformWin::saved_output_cp_ = -1;
175 int PlatformWin::saved_input_cp_ = -1; 175 int PlatformWin::saved_input_cp_ = -1;
176 Mutex* PlatformWin::platform_win_mutex_ = NULL; 176 Mutex* PlatformWin::platform_win_mutex_ = NULL;
177 177
178 bool Platform::Initialize() { 178 bool Platform::Initialize() {
179 PlatformWin::InitOnce(); 179 PlatformWin::InitOnce();
180 PlatformWin::SaveAndConfigureConsole(); 180 PlatformWin::SaveAndConfigureConsole();
181 return true; 181 return true;
182 } 182 }
183 183
184
185 int Platform::NumberOfProcessors() { 184 int Platform::NumberOfProcessors() {
186 SYSTEM_INFO info; 185 SYSTEM_INFO info;
187 GetSystemInfo(&info); 186 GetSystemInfo(&info);
188 return info.dwNumberOfProcessors; 187 return info.dwNumberOfProcessors;
189 } 188 }
190 189
191
192 const char* Platform::OperatingSystem() { 190 const char* Platform::OperatingSystem() {
193 return "windows"; 191 return "windows";
194 } 192 }
195 193
196
197 const char* Platform::LibraryPrefix() { 194 const char* Platform::LibraryPrefix() {
198 return ""; 195 return "";
199 } 196 }
200 197
201
202 const char* Platform::LibraryExtension() { 198 const char* Platform::LibraryExtension() {
203 return "dll"; 199 return "dll";
204 } 200 }
205 201
206
207 const char* Platform::LocaleName() { 202 const char* Platform::LocaleName() {
208 wchar_t locale_name[LOCALE_NAME_MAX_LENGTH]; 203 wchar_t locale_name[LOCALE_NAME_MAX_LENGTH];
209 int result = GetUserDefaultLocaleName(locale_name, LOCALE_NAME_MAX_LENGTH); 204 int result = GetUserDefaultLocaleName(locale_name, LOCALE_NAME_MAX_LENGTH);
210 if (result == 0) { 205 if (result == 0) {
211 return NULL; 206 return NULL;
212 } 207 }
213 return StringUtilsWin::WideToUtf8(locale_name); 208 return StringUtilsWin::WideToUtf8(locale_name);
214 } 209 }
215 210
216
217 bool Platform::LocalHostname(char* buffer, intptr_t buffer_length) { 211 bool Platform::LocalHostname(char* buffer, intptr_t buffer_length) {
218 #if defined(DART_IO_DISABLED) || defined(PLATFORM_DISABLE_SOCKET) 212 #if defined(DART_IO_DISABLED) || defined(PLATFORM_DISABLE_SOCKET)
219 return false; 213 return false;
220 #else 214 #else
221 if (!SocketBase::Initialize()) { 215 if (!SocketBase::Initialize()) {
222 return false; 216 return false;
223 } 217 }
224 return gethostname(buffer, buffer_length) == 0; 218 return gethostname(buffer, buffer_length) == 0;
225 #endif 219 #endif
226 } 220 }
227 221
228
229 char** Platform::Environment(intptr_t* count) { 222 char** Platform::Environment(intptr_t* count) {
230 wchar_t* strings = GetEnvironmentStringsW(); 223 wchar_t* strings = GetEnvironmentStringsW();
231 if (strings == NULL) { 224 if (strings == NULL) {
232 return NULL; 225 return NULL;
233 } 226 }
234 wchar_t* tmp = strings; 227 wchar_t* tmp = strings;
235 intptr_t i = 0; 228 intptr_t i = 0;
236 while (*tmp != '\0') { 229 while (*tmp != '\0') {
237 // Skip environment strings starting with "=". 230 // Skip environment strings starting with "=".
238 // These are synthetic variables corresponding to dynamic environment 231 // These are synthetic variables corresponding to dynamic environment
(...skipping 12 matching lines...) Expand all
251 // Skip the strings that were not counted above. 244 // Skip the strings that were not counted above.
252 if (*tmp != '=') { 245 if (*tmp != '=') {
253 result[current++] = StringUtilsWin::WideToUtf8(tmp); 246 result[current++] = StringUtilsWin::WideToUtf8(tmp);
254 } 247 }
255 tmp += (wcslen(tmp) + 1); 248 tmp += (wcslen(tmp) + 1);
256 } 249 }
257 FreeEnvironmentStringsW(strings); 250 FreeEnvironmentStringsW(strings);
258 return result; 251 return result;
259 } 252 }
260 253
261
262 const char* Platform::GetExecutableName() { 254 const char* Platform::GetExecutableName() {
263 return executable_name_; 255 return executable_name_;
264 } 256 }
265 257
266
267 const char* Platform::ResolveExecutablePath() { 258 const char* Platform::ResolveExecutablePath() {
268 // GetModuleFileNameW cannot directly provide information on the 259 // GetModuleFileNameW cannot directly provide information on the
269 // required buffer size, so start out with a buffer large enough to 260 // required buffer size, so start out with a buffer large enough to
270 // hold any Windows path. 261 // hold any Windows path.
271 const int kTmpBufferSize = 32768; 262 const int kTmpBufferSize = 32768;
272 wchar_t* tmp_buffer = 263 wchar_t* tmp_buffer =
273 reinterpret_cast<wchar_t*>(Dart_ScopeAllocate(kTmpBufferSize)); 264 reinterpret_cast<wchar_t*>(Dart_ScopeAllocate(kTmpBufferSize));
274 // Ensure no last error before calling GetModuleFileNameW. 265 // Ensure no last error before calling GetModuleFileNameW.
275 SetLastError(ERROR_SUCCESS); 266 SetLastError(ERROR_SUCCESS);
276 // Get the required length of the buffer. 267 // Get the required length of the buffer.
277 int path_length = GetModuleFileNameW(NULL, tmp_buffer, kTmpBufferSize); 268 int path_length = GetModuleFileNameW(NULL, tmp_buffer, kTmpBufferSize);
278 if (GetLastError() != ERROR_SUCCESS) { 269 if (GetLastError() != ERROR_SUCCESS) {
279 return NULL; 270 return NULL;
280 } 271 }
281 char* path = StringUtilsWin::WideToUtf8(tmp_buffer); 272 char* path = StringUtilsWin::WideToUtf8(tmp_buffer);
282 // Return the canonical path as the returned path might contain symlinks. 273 // Return the canonical path as the returned path might contain symlinks.
283 const char* canon_path = File::GetCanonicalPath(path); 274 const char* canon_path = File::GetCanonicalPath(path);
284 return canon_path; 275 return canon_path;
285 } 276 }
286 277
287
288 void Platform::Exit(int exit_code) { 278 void Platform::Exit(int exit_code) {
289 // TODO(zra): Remove once VM shuts down cleanly. 279 // TODO(zra): Remove once VM shuts down cleanly.
290 ::dart::private_flag_windows_run_tls_destructors = false; 280 ::dart::private_flag_windows_run_tls_destructors = false;
291 // Restore the console's output code page 281 // Restore the console's output code page
292 PlatformWin::RestoreConsole(); 282 PlatformWin::RestoreConsole();
293 // On Windows we use ExitProcess so that threads can't clobber the exit_code. 283 // On Windows we use ExitProcess so that threads can't clobber the exit_code.
294 // See: https://code.google.com/p/nativeclient/issues/detail?id=2870 284 // See: https://code.google.com/p/nativeclient/issues/detail?id=2870
295 ::ExitProcess(exit_code); 285 ::ExitProcess(exit_code);
296 } 286 }
297 287
298 } // namespace bin 288 } // namespace bin
299 } // namespace dart 289 } // namespace dart
300 290
301 #endif // defined(HOST_OS_WINDOWS) 291 #endif // defined(HOST_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/platform_unsupported.cc ('k') | runtime/bin/process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698