Chromium Code Reviews| 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> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 const char* OS::Name() { | 26 const char* OS::Name() { |
| 27 return "fuchsia"; | 27 return "fuchsia"; |
| 28 } | 28 } |
| 29 | 29 |
| 30 | 30 |
| 31 intptr_t OS::ProcessId() { | 31 intptr_t OS::ProcessId() { |
| 32 return static_cast<intptr_t>(getpid()); | 32 return static_cast<intptr_t>(getpid()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 | 35 |
| 36 static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) { | |
| 37 time_t seconds = static_cast<time_t>(seconds_since_epoch); | |
| 38 if (seconds != seconds_since_epoch) return false; | |
| 39 struct tm* error_code = localtime_r(&seconds, tm_result); | |
| 40 return error_code != NULL; | |
| 41 } | |
| 42 | |
| 43 | |
| 36 const char* OS::GetTimeZoneName(int64_t seconds_since_epoch) { | 44 const char* OS::GetTimeZoneName(int64_t seconds_since_epoch) { |
| 37 UNIMPLEMENTED(); | 45 tm decomposed; |
| 38 return ""; | 46 bool succeeded = LocalTime(seconds_since_epoch, &decomposed); |
| 47 // If unsuccessful, return an empty string like V8 does. | |
| 48 return (succeeded && (decomposed.tm_zone != NULL)) ? decomposed.tm_zone : ""; | |
| 39 } | 49 } |
| 40 | 50 |
| 41 | 51 |
| 42 int OS::GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch) { | 52 int OS::GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch) { |
| 43 UNIMPLEMENTED(); | 53 tm decomposed; |
| 44 return 0; | 54 bool succeeded = LocalTime(seconds_since_epoch, &decomposed); |
| 55 // Even if the offset was 24 hours it would still easily fit into 32 bits. | |
| 56 // If unsuccessful, return zero like V8 does. | |
| 57 return succeeded ? static_cast<int>(decomposed.tm_gmtoff) : 0; | |
| 45 } | 58 } |
| 46 | 59 |
|
zra
2016/10/22 06:40:56
Two newlines between functions.
| |
| 47 | |
| 48 int OS::GetLocalTimeZoneAdjustmentInSeconds() { | 60 int OS::GetLocalTimeZoneAdjustmentInSeconds() { |
| 49 UNIMPLEMENTED(); | 61 // TODO(floitsch): avoid excessive calls to tzset? |
| 50 return 0; | 62 tzset(); |
| 63 // Even if the offset was 24 hours it would still easily fit into 32 bits. | |
| 64 // Note that Unix and Dart disagree on the sign. | |
| 65 return static_cast<int>(-timezone); | |
| 51 } | 66 } |
| 52 | 67 |
|
zra
2016/10/22 06:40:56
ditto.
| |
| 53 | |
| 54 int64_t OS::GetCurrentTimeMillis() { | 68 int64_t OS::GetCurrentTimeMillis() { |
| 55 return GetCurrentTimeMicros() / 1000; | 69 return GetCurrentTimeMicros() / 1000; |
| 56 } | 70 } |
| 57 | 71 |
| 58 | 72 |
| 59 int64_t OS::GetCurrentTimeMicros() { | 73 int64_t OS::GetCurrentTimeMicros() { |
| 60 return mx_current_time() / 1000; | 74 return mx_current_time() / 1000; |
| 61 } | 75 } |
| 62 | 76 |
| 63 | 77 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 } | 305 } |
| 292 | 306 |
| 293 | 307 |
| 294 void OS::Exit(int code) { | 308 void OS::Exit(int code) { |
| 295 UNIMPLEMENTED(); | 309 UNIMPLEMENTED(); |
| 296 } | 310 } |
| 297 | 311 |
| 298 } // namespace dart | 312 } // namespace dart |
| 299 | 313 |
| 300 #endif // defined(TARGET_OS_FUCHSIA) | 314 #endif // defined(TARGET_OS_FUCHSIA) |
| OLD | NEW |