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 <errno.h> // NOLINT | 8 #include <errno.h> // NOLINT |
9 #include <time.h> // NOLINT | 9 #include <time.h> // NOLINT |
10 | 10 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 QueryPerformanceCounter(&now); | 184 QueryPerformanceCounter(&now); |
185 int64_t qpc_value = static_cast<int64_t>(now.QuadPart); | 185 int64_t qpc_value = static_cast<int64_t>(now.QuadPart); |
186 // Convert to microseconds. | 186 // Convert to microseconds. |
187 int64_t seconds = qpc_value / qpc_ticks_per_second; | 187 int64_t seconds = qpc_value / qpc_ticks_per_second; |
188 int64_t leftover_ticks = qpc_value - (seconds * qpc_ticks_per_second); | 188 int64_t leftover_ticks = qpc_value - (seconds * qpc_ticks_per_second); |
189 int64_t result = seconds * kMicrosecondsPerSecond; | 189 int64_t result = seconds * kMicrosecondsPerSecond; |
190 result += ((leftover_ticks * kMicrosecondsPerSecond) / qpc_ticks_per_second); | 190 result += ((leftover_ticks * kMicrosecondsPerSecond) / qpc_ticks_per_second); |
191 return result; | 191 return result; |
192 } | 192 } |
193 | 193 |
194 | |
195 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { | |
196 const int kMinimumAlignment = 16; | |
197 ASSERT(Utils::IsPowerOfTwo(alignment)); | |
198 ASSERT(alignment >= kMinimumAlignment); | |
199 void* p = _aligned_malloc(size, alignment); | |
200 if (p == NULL) { | |
201 UNREACHABLE(); | |
202 } | |
203 return p; | |
204 } | |
205 | |
206 void TimerUtils::Sleep(int64_t millis) { | 194 void TimerUtils::Sleep(int64_t millis) { |
207 ::Sleep(millis); | 195 ::Sleep(millis); |
208 } | 196 } |
209 | 197 |
210 } // namespace bin | 198 } // namespace bin |
211 } // namespace dart | 199 } // namespace dart |
212 | 200 |
213 #endif // defined(TARGET_OS_WINDOWS) | 201 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |