| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 #if defined(FLETCH_TARGET_OS_LINUX) | 5 #if defined(DARTINO_TARGET_OS_LINUX) |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 #include <time.h> | 10 #include <time.h> |
| 11 | 11 |
| 12 #include "src/shared/assert.h" | 12 #include "src/shared/assert.h" |
| 13 #include "src/shared/platform.h" | 13 #include "src/shared/platform.h" |
| 14 | 14 |
| 15 namespace fletch { | 15 namespace dartino { |
| 16 | 16 |
| 17 void GetPathOfExecutable(char* path, size_t path_length) { | 17 void GetPathOfExecutable(char* path, size_t path_length) { |
| 18 ssize_t length = readlink("/proc/self/exe", path, path_length - 1); | 18 ssize_t length = readlink("/proc/self/exe", path, path_length - 1); |
| 19 if (length == -1) { | 19 if (length == -1) { |
| 20 FATAL1("readlink failed: %s", strerror(errno)); | 20 FATAL1("readlink failed: %s", strerror(errno)); |
| 21 } | 21 } |
| 22 if (static_cast<size_t>(length) == path_length - 1) { | 22 if (static_cast<size_t>(length) == path_length - 1) { |
| 23 FATAL("readlink returned too much data"); | 23 FATAL("readlink returned too much data"); |
| 24 } | 24 } |
| 25 path[length] = '\0'; | 25 path[length] = '\0'; |
| 26 } | 26 } |
| 27 | 27 |
| 28 int Platform::GetLocalTimeZoneOffset() { | 28 int Platform::GetLocalTimeZoneOffset() { |
| 29 // TODO(ajohnsen): avoid excessive calls to tzset? | 29 // TODO(ajohnsen): avoid excessive calls to tzset? |
| 30 tzset(); | 30 tzset(); |
| 31 // Even if the offset was 24 hours it would still easily fit into 32 bits. | 31 // Even if the offset was 24 hours it would still easily fit into 32 bits. |
| 32 // Note that Unix and Dart disagree on the sign. | 32 // Note that Unix and Dart disagree on the sign. |
| 33 return static_cast<int>(-timezone); | 33 return static_cast<int>(-timezone); |
| 34 } | 34 } |
| 35 | 35 |
| 36 } // namespace fletch | 36 } // namespace dartino |
| 37 | 37 |
| 38 #endif // defined(FLETCH_TARGET_OS_LINUX) | 38 #endif // defined(DARTINO_TARGET_OS_LINUX) |
| OLD | NEW |