OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_LINUX) | 6 #if defined(HOST_OS_LINUX) |
7 | 7 |
8 #include "bin/platform.h" | 8 #include "bin/platform.h" |
9 | 9 |
10 #include <signal.h> // NOLINT | 10 #include <signal.h> // NOLINT |
11 #include <string.h> // NOLINT | 11 #include <string.h> // NOLINT |
12 #include <unistd.h> // NOLINT | 12 #include <sys/utsname.h> // NOLINT |
| 13 #include <unistd.h> // NOLINT |
13 | 14 |
14 #include "bin/fdutils.h" | 15 #include "bin/fdutils.h" |
15 #include "bin/file.h" | 16 #include "bin/file.h" |
16 | 17 |
17 namespace dart { | 18 namespace dart { |
18 namespace bin { | 19 namespace bin { |
19 | 20 |
20 const char* Platform::executable_name_ = NULL; | 21 const char* Platform::executable_name_ = NULL; |
21 char* Platform::resolved_executable_name_ = NULL; | 22 char* Platform::resolved_executable_name_ = NULL; |
22 int Platform::script_index_ = 1; | 23 int Platform::script_index_ = 1; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 66 } |
66 | 67 |
67 int Platform::NumberOfProcessors() { | 68 int Platform::NumberOfProcessors() { |
68 return sysconf(_SC_NPROCESSORS_ONLN); | 69 return sysconf(_SC_NPROCESSORS_ONLN); |
69 } | 70 } |
70 | 71 |
71 const char* Platform::OperatingSystem() { | 72 const char* Platform::OperatingSystem() { |
72 return "linux"; | 73 return "linux"; |
73 } | 74 } |
74 | 75 |
| 76 const char* Platform::OperatingSystemVersion() { |
| 77 struct utsname info; |
| 78 int ret = uname(&info); |
| 79 if (ret != 0) { |
| 80 return NULL; |
| 81 } |
| 82 const char* kFormat = "%s %s %s"; |
| 83 int len = |
| 84 snprintf(NULL, 0, kFormat, info.sysname, info.release, info.version); |
| 85 if (len <= 0) { |
| 86 return NULL; |
| 87 } |
| 88 char* result = DartUtils::ScopedCString(len + 1); |
| 89 ASSERT(result != NULL); |
| 90 len = snprintf(result, len + 1, kFormat, info.sysname, info.release, |
| 91 info.version); |
| 92 if (len <= 0) { |
| 93 return NULL; |
| 94 } |
| 95 return result; |
| 96 } |
| 97 |
75 const char* Platform::LibraryPrefix() { | 98 const char* Platform::LibraryPrefix() { |
76 return "lib"; | 99 return "lib"; |
77 } | 100 } |
78 | 101 |
79 const char* Platform::LibraryExtension() { | 102 const char* Platform::LibraryExtension() { |
80 return "so"; | 103 return "so"; |
81 } | 104 } |
82 | 105 |
83 const char* Platform::LocaleName() { | 106 const char* Platform::LocaleName() { |
84 char* lang = getenv("LANG"); | 107 char* lang = getenv("LANG"); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 141 } |
119 | 142 |
120 void Platform::Exit(int exit_code) { | 143 void Platform::Exit(int exit_code) { |
121 exit(exit_code); | 144 exit(exit_code); |
122 } | 145 } |
123 | 146 |
124 } // namespace bin | 147 } // namespace bin |
125 } // namespace dart | 148 } // namespace dart |
126 | 149 |
127 #endif // defined(HOST_OS_LINUX) | 150 #endif // defined(HOST_OS_LINUX) |
OLD | NEW |