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

Side by Side Diff: runtime/vm/os_win.cc

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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/vm/os_thread_win.cc ('k') | runtime/vm/pages.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 "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "vm/os.h" 8 #include "vm/os.h"
9 9
10 #include <malloc.h> // NOLINT 10 #include <malloc.h> // NOLINT
11 #include <process.h> // NOLINT 11 #include <process.h> // NOLINT
12 #include <psapi.h> // NOLINT 12 #include <psapi.h> // NOLINT
13 #include <time.h> // NOLINT 13 #include <time.h> // NOLINT
14 14
15 #include "platform/utils.h" 15 #include "platform/utils.h"
16 #include "platform/assert.h" 16 #include "platform/assert.h"
17 #include "vm/os_thread.h" 17 #include "vm/os_thread.h"
18 #include "vm/zone.h" 18 #include "vm/zone.h"
19 19
20 namespace dart { 20 namespace dart {
21 21
22 // Defined in vm/os_thread_win.cc 22 // Defined in vm/os_thread_win.cc
23 extern bool private_flag_windows_run_tls_destructors; 23 extern bool private_flag_windows_run_tls_destructors;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Figure out whether we're in standard or daylight. 72 // Figure out whether we're in standard or daylight.
73 bool daylight_savings = (status == TIME_ZONE_ID_DAYLIGHT); 73 bool daylight_savings = (status == TIME_ZONE_ID_DAYLIGHT);
74 if (status == TIME_ZONE_ID_UNKNOWN) { 74 if (status == TIME_ZONE_ID_UNKNOWN) {
75 tm local_time; 75 tm local_time;
76 if (LocalTime(seconds_since_epoch, &local_time)) { 76 if (LocalTime(seconds_since_epoch, &local_time)) {
77 daylight_savings = (local_time.tm_isdst == 1); 77 daylight_savings = (local_time.tm_isdst == 1);
78 } 78 }
79 } 79 }
80 80
81 // Convert the wchar string to a null-terminated utf8 string. 81 // Convert the wchar string to a null-terminated utf8 string.
82 wchar_t* wchar_name = daylight_savings 82 wchar_t* wchar_name = daylight_savings ? zone_information.DaylightName
83 ? zone_information.DaylightName 83 : zone_information.StandardName;
84 : zone_information.StandardName; 84 intptr_t utf8_len =
85 intptr_t utf8_len = WideCharToMultiByte( 85 WideCharToMultiByte(CP_UTF8, 0, wchar_name, -1, NULL, 0, NULL, NULL);
86 CP_UTF8, 0, wchar_name, -1, NULL, 0, NULL, NULL);
87 char* name = Thread::Current()->zone()->Alloc<char>(utf8_len + 1); 86 char* name = Thread::Current()->zone()->Alloc<char>(utf8_len + 1);
88 WideCharToMultiByte( 87 WideCharToMultiByte(CP_UTF8, 0, wchar_name, -1, name, utf8_len, NULL, NULL);
89 CP_UTF8, 0, wchar_name, -1, name, utf8_len, NULL, NULL);
90 name[utf8_len] = '\0'; 88 name[utf8_len] = '\0';
91 return name; 89 return name;
92 } 90 }
93 91
94 92
95 int OS::GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch) { 93 int OS::GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch) {
96 tm decomposed; 94 tm decomposed;
97 // LocalTime will set _timezone. 95 // LocalTime will set _timezone.
98 bool succeeded = LocalTime(seconds_since_epoch, &decomposed); 96 bool succeeded = LocalTime(seconds_since_epoch, &decomposed);
99 if (succeeded) { 97 if (succeeded) {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 368
371 369
372 bool OS::StringToInt64(const char* str, int64_t* value) { 370 bool OS::StringToInt64(const char* str, int64_t* value) {
373 ASSERT(str != NULL && strlen(str) > 0 && value != NULL); 371 ASSERT(str != NULL && strlen(str) > 0 && value != NULL);
374 int32_t base = 10; 372 int32_t base = 10;
375 char* endptr; 373 char* endptr;
376 int i = 0; 374 int i = 0;
377 if (str[0] == '-') { 375 if (str[0] == '-') {
378 i = 1; 376 i = 1;
379 } 377 }
380 if ((str[i] == '0') && 378 if ((str[i] == '0') && (str[i + 1] == 'x' || str[i + 1] == 'X') &&
381 (str[i + 1] == 'x' || str[i + 1] == 'X') &&
382 (str[i + 2] != '\0')) { 379 (str[i + 2] != '\0')) {
383 base = 16; 380 base = 16;
384 } 381 }
385 errno = 0; 382 errno = 0;
386 *value = _strtoi64(str, &endptr, base); 383 *value = _strtoi64(str, &endptr, base);
387 return ((errno == 0) && (endptr != str) && (*endptr == 0)); 384 return ((errno == 0) && (endptr != str) && (*endptr == 0));
388 } 385 }
389 386
390 387
391 void OS::RegisterCodeObservers() { 388 void OS::RegisterCodeObservers() {}
392 }
393 389
394 390
395 void OS::PrintErr(const char* format, ...) { 391 void OS::PrintErr(const char* format, ...) {
396 va_list args; 392 va_list args;
397 va_start(args, format); 393 va_start(args, format);
398 VFPrint(stderr, format, args); 394 VFPrint(stderr, format, args);
399 va_end(args); 395 va_end(args);
400 } 396 }
401 397
402 398
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 // TODO(zra): Remove once VM shuts down cleanly. 434 // TODO(zra): Remove once VM shuts down cleanly.
439 private_flag_windows_run_tls_destructors = false; 435 private_flag_windows_run_tls_destructors = false;
440 // On Windows we use ExitProcess so that threads can't clobber the exit_code. 436 // On Windows we use ExitProcess so that threads can't clobber the exit_code.
441 // See: https://code.google.com/p/nativeclient/issues/detail?id=2870 437 // See: https://code.google.com/p/nativeclient/issues/detail?id=2870
442 ::ExitProcess(code); 438 ::ExitProcess(code);
443 } 439 }
444 440
445 } // namespace dart 441 } // namespace dart
446 442
447 #endif // defined(TARGET_OS_WINDOWS) 443 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/vm/os_thread_win.cc ('k') | runtime/vm/pages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698