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