Chromium Code Reviews| OLD | NEW |
|---|---|
| 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(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
| 7 | 7 |
| 8 #include "bin/platform.h" | 8 #include "bin/platform.h" |
| 9 | 9 |
| 10 #include "bin/file.h" | 10 #include "bin/file.h" |
| 11 #include "bin/log.h" | 11 #include "bin/log.h" |
| 12 #if !defined(DART_IO_DISABLED) && !defined(PLATFORM_DISABLE_SOCKET) | 12 #if !defined(DART_IO_DISABLED) && !defined(PLATFORM_DISABLE_SOCKET) |
| 13 #include "bin/socket.h" | 13 #include "bin/socket.h" |
| 14 #endif | 14 #endif |
| 15 #include "bin/utils.h" | 15 #include "bin/utils.h" |
| 16 #include "bin/utils_win.h" | 16 #include "bin/utils_win.h" |
| 17 | 17 |
| 18 namespace dart { | 18 namespace dart { |
| 19 | 19 |
| 20 // Defined in vm/os_thread_win.cc | 20 // Defined in vm/os_thread_win.cc |
| 21 extern bool private_flag_windows_run_tls_destructors; | 21 extern bool private_flag_windows_run_tls_destructors; |
| 22 | 22 |
| 23 namespace bin { | 23 namespace bin { |
| 24 | 24 |
| 25 const char* Platform::executable_name_ = NULL; | 25 const char* Platform::executable_name_ = NULL; |
| 26 char* Platform::resolved_executable_name_ = NULL; | 26 char* Platform::resolved_executable_name_ = NULL; |
| 27 int Platform::script_index_ = 1; | 27 int Platform::script_index_ = 1; |
| 28 char** Platform::argv_ = NULL; | 28 char** Platform::argv_ = NULL; |
| 29 | 29 |
| 30 static int old_output_cp = -1; | |
| 31 | |
| 30 bool Platform::Initialize() { | 32 bool Platform::Initialize() { |
| 33 ASSERT(old_output_cp == -1); | |
| 34 old_output_cp = GetConsoleOutputCP(); | |
| 35 SetConsoleOutputCP(CP_UTF8); | |
| 31 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); | 36 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); |
| 32 return true; | 37 return true; |
| 33 } | 38 } |
| 34 | 39 |
| 35 | 40 |
| 36 int Platform::NumberOfProcessors() { | 41 int Platform::NumberOfProcessors() { |
| 37 SYSTEM_INFO info; | 42 SYSTEM_INFO info; |
| 38 GetSystemInfo(&info); | 43 GetSystemInfo(&info); |
| 39 return info.dwNumberOfProcessors; | 44 return info.dwNumberOfProcessors; |
| 40 } | 45 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 char* path = StringUtilsWin::WideToUtf8(tmp_buffer); | 122 char* path = StringUtilsWin::WideToUtf8(tmp_buffer); |
| 118 // Return the canonical path as the returned path might contain symlinks. | 123 // Return the canonical path as the returned path might contain symlinks. |
| 119 const char* canon_path = File::GetCanonicalPath(path); | 124 const char* canon_path = File::GetCanonicalPath(path); |
| 120 return canon_path; | 125 return canon_path; |
| 121 } | 126 } |
| 122 | 127 |
| 123 | 128 |
| 124 void Platform::Exit(int exit_code) { | 129 void Platform::Exit(int exit_code) { |
| 125 // TODO(zra): Remove once VM shuts down cleanly. | 130 // TODO(zra): Remove once VM shuts down cleanly. |
| 126 ::dart::private_flag_windows_run_tls_destructors = false; | 131 ::dart::private_flag_windows_run_tls_destructors = false; |
| 132 // Restore the console's output code page | |
| 133 if (old_output_cp != -1) { | |
| 134 SetConsoleOutputCP(old_output_cp); | |
|
Florian Schneider
2017/02/21 20:34:50
Can there be multiple threads calling Platform::Ex
zra
2017/02/21 21:26:46
Yes. This can happen if multiple isolates call Pla
| |
| 135 old_output_cp = -1; | |
| 136 } | |
| 127 // On Windows we use ExitProcess so that threads can't clobber the exit_code. | 137 // On Windows we use ExitProcess so that threads can't clobber the exit_code. |
| 128 // See: https://code.google.com/p/nativeclient/issues/detail?id=2870 | 138 // See: https://code.google.com/p/nativeclient/issues/detail?id=2870 |
| 129 ::ExitProcess(exit_code); | 139 ::ExitProcess(exit_code); |
| 130 } | 140 } |
| 131 | 141 |
| 132 } // namespace bin | 142 } // namespace bin |
| 133 } // namespace dart | 143 } // namespace dart |
| 134 | 144 |
| 135 #endif // defined(TARGET_OS_WINDOWS) | 145 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |