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> | |
14 | 13 |
15 #include "platform/assert.h" | 14 #include "platform/assert.h" |
16 #include "vm/zone.h" | 15 #include "vm/zone.h" |
17 | 16 |
18 namespace dart { | 17 namespace dart { |
19 | 18 |
20 #ifndef PRODUCT | 19 #ifndef PRODUCT |
21 | 20 |
22 DEFINE_FLAG(bool, | 21 DEFINE_FLAG(bool, |
23 generate_perf_events_symbols, | 22 generate_perf_events_symbols, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 return static_cast<int>(-timezone); | 70 return static_cast<int>(-timezone); |
72 } | 71 } |
73 | 72 |
74 | 73 |
75 int64_t OS::GetCurrentTimeMillis() { | 74 int64_t OS::GetCurrentTimeMillis() { |
76 return GetCurrentTimeMicros() / 1000; | 75 return GetCurrentTimeMicros() / 1000; |
77 } | 76 } |
78 | 77 |
79 | 78 |
80 int64_t OS::GetCurrentTimeMicros() { | 79 int64_t OS::GetCurrentTimeMicros() { |
81 struct timeval tv; | 80 return mx_time_get(MX_CLOCK_UTC) / kNanosecondsPerMicrosecond; |
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; | |
87 } | 81 } |
88 | 82 |
89 | 83 |
90 int64_t OS::GetCurrentMonotonicTicks() { | 84 int64_t OS::GetCurrentMonotonicTicks() { |
91 return mx_time_get(MX_CLOCK_MONOTONIC); | 85 return mx_time_get(MX_CLOCK_MONOTONIC); |
92 } | 86 } |
93 | 87 |
94 | 88 |
95 int64_t OS::GetCurrentMonotonicFrequency() { | 89 int64_t OS::GetCurrentMonotonicFrequency() { |
96 return kNanosecondsPerSecond; | 90 return kNanosecondsPerSecond; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 306 } |
313 | 307 |
314 | 308 |
315 void OS::Exit(int code) { | 309 void OS::Exit(int code) { |
316 UNIMPLEMENTED(); | 310 UNIMPLEMENTED(); |
317 } | 311 } |
318 | 312 |
319 } // namespace dart | 313 } // namespace dart |
320 | 314 |
321 #endif // defined(TARGET_OS_FUCHSIA) | 315 #endif // defined(TARGET_OS_FUCHSIA) |
OLD | NEW |