OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_FUCHSIA) | 6 #if defined(TARGET_OS_FUCHSIA) |
7 | 7 |
8 #include "vm/os.h" | 8 #include "vm/os.h" |
9 | 9 |
10 #include <errno.h> | 10 #include <errno.h> |
11 #include <magenta/syscalls.h> | 11 #include <magenta/syscalls.h> |
12 #include <magenta/types.h> | 12 #include <magenta/types.h> |
| 13 #include <sys/time.h> |
13 | 14 |
14 #include "platform/assert.h" | 15 #include "platform/assert.h" |
15 #include "vm/zone.h" | 16 #include "vm/zone.h" |
16 | 17 |
17 namespace dart { | 18 namespace dart { |
18 | 19 |
19 #ifndef PRODUCT | 20 #ifndef PRODUCT |
20 | 21 |
21 DEFINE_FLAG(bool, | 22 DEFINE_FLAG(bool, |
22 generate_perf_events_symbols, | 23 generate_perf_events_symbols, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 return static_cast<int>(-timezone); | 71 return static_cast<int>(-timezone); |
71 } | 72 } |
72 | 73 |
73 | 74 |
74 int64_t OS::GetCurrentTimeMillis() { | 75 int64_t OS::GetCurrentTimeMillis() { |
75 return GetCurrentTimeMicros() / 1000; | 76 return GetCurrentTimeMicros() / 1000; |
76 } | 77 } |
77 | 78 |
78 | 79 |
79 int64_t OS::GetCurrentTimeMicros() { | 80 int64_t OS::GetCurrentTimeMicros() { |
80 return mx_time_get(MX_CLOCK_MONOTONIC) / 1000; | 81 struct timeval tv; |
| 82 if (gettimeofday(&tv, NULL) < 0) { |
| 83 UNREACHABLE(); |
| 84 return 0; |
| 85 } |
| 86 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; |
81 } | 87 } |
82 | 88 |
83 | 89 |
84 int64_t OS::GetCurrentMonotonicTicks() { | 90 int64_t OS::GetCurrentMonotonicTicks() { |
85 return mx_time_get(MX_CLOCK_MONOTONIC); | 91 return mx_time_get(MX_CLOCK_MONOTONIC); |
86 } | 92 } |
87 | 93 |
88 | 94 |
89 int64_t OS::GetCurrentMonotonicFrequency() { | 95 int64_t OS::GetCurrentMonotonicFrequency() { |
90 return kNanosecondsPerSecond; | 96 return kNanosecondsPerSecond; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 } | 312 } |
307 | 313 |
308 | 314 |
309 void OS::Exit(int code) { | 315 void OS::Exit(int code) { |
310 UNIMPLEMENTED(); | 316 UNIMPLEMENTED(); |
311 } | 317 } |
312 | 318 |
313 } // namespace dart | 319 } // namespace dart |
314 | 320 |
315 #endif // defined(TARGET_OS_FUCHSIA) | 321 #endif // defined(TARGET_OS_FUCHSIA) |
OLD | NEW |