Index: runtime/bin/platform_macos.cc |
diff --git a/runtime/bin/platform_macos.cc b/runtime/bin/platform_macos.cc |
index b02bca7554f31e8de0237fd29de4f9a8f97a0815..e563788ceb3e22cab73e623d54dbbd4c08b72ac2 100644 |
--- a/runtime/bin/platform_macos.cc |
+++ b/runtime/bin/platform_macos.cc |
@@ -13,11 +13,12 @@ |
#include <crt_externs.h> // NOLINT |
#endif // !HOST_OS_IOS |
#include <mach-o/dyld.h> |
-#include <signal.h> // NOLINT |
-#include <string.h> // NOLINT |
-#include <sys/sysctl.h> // NOLINT |
-#include <sys/types.h> // NOLINT |
-#include <unistd.h> // NOLINT |
+#include <signal.h> // NOLINT |
+#include <string.h> // NOLINT |
+#include <sys/sysctl.h> // NOLINT |
+#include <sys/types.h> // NOLINT |
+#include <sys/utsname.h> // NOLINT |
+#include <unistd.h> // NOLINT |
#include "bin/fdutils.h" |
#include "bin/file.h" |
@@ -90,6 +91,28 @@ const char* Platform::OperatingSystem() { |
#endif |
} |
+const char* Platform::OperatingSystemVersion() { |
+ struct utsname info; |
+ int ret = uname(&info); |
+ if (ret != 0) { |
+ return NULL; |
+ } |
+ const char* kFormat = "%s %s %s"; |
+ int len = |
+ snprintf(NULL, 0, kFormat, info.sysname, info.release, info.version); |
+ if (len <= 0) { |
+ return NULL; |
+ } |
+ char* result = DartUtils::ScopedCString(len + 1); |
+ ASSERT(result != NULL); |
+ len = snprintf(result, len + 1, kFormat, info.sysname, info.release, |
+ info.version); |
+ if (len <= 0) { |
+ return NULL; |
+ } |
+ return result; |
+} |
+ |
const char* Platform::LibraryPrefix() { |
return "lib"; |
} |