| 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 "bin/platform.h" | 8 #include "bin/platform.h" |
| 9 | 9 |
| 10 #include <magenta/process.h> | 10 #include <magenta/process.h> |
| 11 #include <magenta/status.h> | 11 #include <magenta/status.h> |
| 12 #include <magenta/syscalls.h> | 12 #include <magenta/syscalls.h> |
| 13 #include <string.h> | 13 #include <string.h> |
| 14 #include <sys/utsname.h> |
| 14 #include <unistd.h> | 15 #include <unistd.h> |
| 15 | 16 |
| 16 #include "bin/dartutils.h" | 17 #include "bin/dartutils.h" |
| 17 #include "bin/fdutils.h" | 18 #include "bin/fdutils.h" |
| 18 #include "bin/file.h" | 19 #include "bin/file.h" |
| 19 | 20 |
| 20 namespace dart { | 21 namespace dart { |
| 21 namespace bin { | 22 namespace bin { |
| 22 | 23 |
| 23 const char* Platform::executable_name_ = NULL; | 24 const char* Platform::executable_name_ = NULL; |
| 24 char* Platform::resolved_executable_name_ = NULL; | 25 char* Platform::resolved_executable_name_ = NULL; |
| 25 int Platform::script_index_ = 1; | 26 int Platform::script_index_ = 1; |
| 26 char** Platform::argv_ = NULL; | 27 char** Platform::argv_ = NULL; |
| 27 | 28 |
| 28 bool Platform::Initialize() { | 29 bool Platform::Initialize() { |
| 29 return true; | 30 return true; |
| 30 } | 31 } |
| 31 | 32 |
| 32 int Platform::NumberOfProcessors() { | 33 int Platform::NumberOfProcessors() { |
| 33 return sysconf(_SC_NPROCESSORS_CONF); | 34 return sysconf(_SC_NPROCESSORS_CONF); |
| 34 } | 35 } |
| 35 | 36 |
| 36 const char* Platform::OperatingSystem() { | 37 const char* Platform::OperatingSystem() { |
| 37 return "fuchsia"; | 38 return "fuchsia"; |
| 38 } | 39 } |
| 39 | 40 |
| 41 const char* Platform::OperatingSystemVersion() { |
| 42 struct utsname info; |
| 43 int ret = uname(&info); |
| 44 if (ret != 0) { |
| 45 return NULL; |
| 46 } |
| 47 const char* kFormat = "%s %s %s"; |
| 48 int len = |
| 49 snprintf(NULL, 0, kFormat, info.sysname, info.release, info.version); |
| 50 if (len <= 0) { |
| 51 return NULL; |
| 52 } |
| 53 char* result = DartUtils::ScopedCString(len + 1); |
| 54 ASSERT(result != NULL); |
| 55 len = snprintf(result, len + 1, kFormat, info.sysname, info.release, |
| 56 info.version); |
| 57 if (len <= 0) { |
| 58 return NULL; |
| 59 } |
| 60 return result; |
| 61 } |
| 62 |
| 40 const char* Platform::LibraryPrefix() { | 63 const char* Platform::LibraryPrefix() { |
| 41 return "lib"; | 64 return "lib"; |
| 42 } | 65 } |
| 43 | 66 |
| 44 const char* Platform::LibraryExtension() { | 67 const char* Platform::LibraryExtension() { |
| 45 return "so"; | 68 return "so"; |
| 46 } | 69 } |
| 47 | 70 |
| 48 const char* Platform::LocaleName() { | 71 const char* Platform::LocaleName() { |
| 49 char* lang = getenv("LANG"); | 72 char* lang = getenv("LANG"); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 147 } |
| 125 | 148 |
| 126 void Platform::Exit(int exit_code) { | 149 void Platform::Exit(int exit_code) { |
| 127 exit(exit_code); | 150 exit(exit_code); |
| 128 } | 151 } |
| 129 | 152 |
| 130 } // namespace bin | 153 } // namespace bin |
| 131 } // namespace dart | 154 } // namespace dart |
| 132 | 155 |
| 133 #endif // defined(HOST_OS_FUCHSIA) | 156 #endif // defined(HOST_OS_FUCHSIA) |
| OLD | NEW |