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 |
3 | // BSD-style license that can be found in the LICENSE file. |
4 | |
5 | #include "platform/globals.h" |
6 | #if defined(HOST_OS_FUCHSIA) |
7 | |
8 | #include <errno.h> |
9 | #include <zircon/syscalls.h> |
10 | #include <zircon/types.h> |
11 | |
12 | #include "bin/utils.h" |
13 | #include "platform/assert.h" |
14 | #include "platform/utils.h" |
15 | |
16 | namespace dart { |
17 | namespace bin { |
18 | |
19 | OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) { |
20 | Reload(); |
21 | } |
22 | |
23 | void OSError::Reload() { |
24 | SetCodeAndMessage(kSystem, errno); |
25 | } |
26 | |
27 | void OSError::SetCodeAndMessage(SubSystem sub_system, int code) { |
28 | set_sub_system(sub_system); |
29 | set_code(code); |
30 | if (sub_system == kSystem) { |
31 | const int kBufferSize = 1024; |
32 | char error_buf[kBufferSize]; |
33 | SetMessage(Utils::StrError(code, error_buf, kBufferSize)); |
34 | } else if (sub_system == kGetAddressInfo) { |
35 | UNIMPLEMENTED(); |
36 | } else { |
37 | UNREACHABLE(); |
38 | } |
39 | } |
40 | |
41 | const char* StringUtils::ConsoleStringToUtf8(const char* str, |
42 | intptr_t len, |
43 | intptr_t* result_len) { |
44 | UNIMPLEMENTED(); |
45 | return NULL; |
46 | } |
47 | |
48 | const char* StringUtils::Utf8ToConsoleString(const char* utf8, |
49 | intptr_t len, |
50 | intptr_t* result_len) { |
51 | UNIMPLEMENTED(); |
52 | return NULL; |
53 | } |
54 | |
55 | char* StringUtils::ConsoleStringToUtf8(char* str, |
56 | intptr_t len, |
57 | intptr_t* result_len) { |
58 | UNIMPLEMENTED(); |
59 | return NULL; |
60 | } |
61 | |
62 | char* StringUtils::Utf8ToConsoleString(char* utf8, |
63 | intptr_t len, |
64 | intptr_t* result_len) { |
65 | UNIMPLEMENTED(); |
66 | return NULL; |
67 | } |
68 | |
69 | bool ShellUtils::GetUtf8Argv(int argc, char** argv) { |
70 | return false; |
71 | } |
72 | |
73 | void TimerUtils::InitOnce() {} |
74 | |
75 | int64_t TimerUtils::GetCurrentMonotonicMillis() { |
76 | return GetCurrentMonotonicMicros() / 1000; |
77 | } |
78 | |
79 | int64_t TimerUtils::GetCurrentMonotonicMicros() { |
80 | zx_time_t ticks = zx_clock_get_monotonic(); |
81 | return ticks / kNanosecondsPerMicrosecond; |
82 | } |
83 | |
84 | void TimerUtils::Sleep(int64_t millis) { |
85 | zx_nanosleep(zx_deadline_after(millis * kMicrosecondsPerMillisecond * |
86 | kNanosecondsPerMicrosecond)); |
87 | } |
88 | |
89 | } // namespace bin |
90 | } // namespace dart |
91 | |
92 | #endif // defined(HOST_OS_FUCHSIA) |
93 | |