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

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

Issue 1519073003: Also copy the fallback code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 | « no previous file | no next file » | 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(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include <errno.h> // NOLINT 8 #include <errno.h> // NOLINT
9 #include <time.h> // NOLINT 9 #include <time.h> // NOLINT
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 unicode_argc = argc; 161 unicode_argc = argc;
162 } 162 }
163 for (int i = 0; i < unicode_argc; i++) { 163 for (int i = 0; i < unicode_argc; i++) {
164 wchar_t* arg = unicode_argv[i]; 164 wchar_t* arg = unicode_argv[i];
165 argv[i] = StringUtilsWin::WideToUtf8(arg); 165 argv[i] = StringUtilsWin::WideToUtf8(arg);
166 } 166 }
167 LocalFree(unicode_argv); 167 LocalFree(unicode_argv);
168 return true; 168 return true;
169 } 169 }
170 170
171 static int64_t GetCurrentTimeMicros() {
172 static const int64_t kTimeEpoc = 116444736000000000LL;
173 static const int64_t kTimeScaler = 10; // 100 ns to us.
174
175 // Although win32 uses 64-bit integers for representing timestamps,
176 // these are packed into a FILETIME structure. The FILETIME
177 // structure is just a struct representing a 64-bit integer. The
178 // TimeStamp union allows access to both a FILETIME and an integer
179 // representation of the timestamp. The Windows timestamp is in
180 // 100-nanosecond intervals since January 1, 1601.
181 union TimeStamp {
182 FILETIME ft_;
183 int64_t t_;
184 };
185 TimeStamp time;
186 GetSystemTimeAsFileTime(&time.ft_);
187 return (time.t_ - kTimeEpoc) / kTimeScaler;
188 }
189
171 int64_t TimerUtils::GetCurrentMonotonicMillis() { 190 int64_t TimerUtils::GetCurrentMonotonicMillis() {
172 return GetCurrentMonotonicMicros() / 1000; 191 return GetCurrentMonotonicMicros() / 1000;
173 } 192 }
174 193
175 static int64_t qpc_ticks_per_second = 0; 194 static int64_t qpc_ticks_per_second = 0;
176 195
177 int64_t TimerUtils::GetCurrentMonotonicMicros() { 196 int64_t TimerUtils::GetCurrentMonotonicMicros() {
178 if (qpc_ticks_per_second == 0) { 197 if (qpc_ticks_per_second == 0) {
179 // QueryPerformanceCounter not supported, fallback. 198 // QueryPerformanceCounter not supported, fallback.
180 return GetCurrentTimeMicros(); 199 return GetCurrentTimeMicros();
(...skipping 11 matching lines...) Expand all
192 } 211 }
193 212
194 void TimerUtils::Sleep(int64_t millis) { 213 void TimerUtils::Sleep(int64_t millis) {
195 ::Sleep(millis); 214 ::Sleep(millis);
196 } 215 }
197 216
198 } // namespace bin 217 } // namespace bin
199 } // namespace dart 218 } // namespace dart
200 219
201 #endif // defined(TARGET_OS_WINDOWS) 220 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698