< prev index next >

src/hotspot/os/bsd/os_bsd.cpp

Print this page

        

@@ -1534,25 +1534,41 @@
   char os[100];
   size_t size = sizeof(os);
   int mib_kern[] = { CTL_KERN, KERN_OSTYPE };
   if (sysctl(mib_kern, 2, os, &size, NULL, 0) < 0) {
 #ifdef __APPLE__
-      strncpy(os, "Darwin", sizeof(os));
+    strncpy(os, "Darwin", sizeof(os));
 #elif __OpenBSD__
-      strncpy(os, "OpenBSD", sizeof(os));
+    strncpy(os, "OpenBSD", sizeof(os));
 #else
-      strncpy(os, "BSD", sizeof(os));
+    strncpy(os, "BSD", sizeof(os));
 #endif
   }
 
   char release[100];
   size = sizeof(release);
   int mib_release[] = { CTL_KERN, KERN_OSRELEASE };
   if (sysctl(mib_release, 2, release, &size, NULL, 0) < 0) {
-      // if error, leave blank
-      strncpy(release, "", sizeof(release));
+    // if error, leave blank
+    strncpy(release, "", sizeof(release));
   }
+
+#ifdef __APPLE__
+  char osproductversion[100];
+  size_t sz = sizeof(osproductversion);
+  int ret = sysctlbyname("kern.osproductversion", osproductversion, &sz, NULL, 0);
+  if (ret == 0) {
+    char build[100];
+    size = sizeof(build);
+    int mib_build[] = { CTL_KERN, KERN_OSVERSION };
+    if (sysctl(mib_build, 2, build, &size, NULL, 0) < 0) {
+      snprintf(buf, buflen, "%s %s, macOS %s", os, release, osproductversion);
+    } else {
+      snprintf(buf, buflen, "%s %s, macOS %s (%s)", os, release, osproductversion, build);
+    }
+  } else
+#endif
   snprintf(buf, buflen, "%s %s", os, release);
 }
 
 void os::print_os_info_brief(outputStream* st) {
   os::Posix::print_uname_info(st);
< prev index next >