changeset 50930:6a5f1195e15f

8134538: Duplicate implementations of os::lasterror Summary: Method os::lasterror was moved to os_posix.cpp Reviewed-by: hseigel, kbarrett, coleenp Contributed-by: patricio.chilano.mateo@oracle.com
author coleenp
date Tue, 03 Jul 2018 15:08:01 -0400
parents ef57cfcd22ff
children d93bba067334
files src/hotspot/os/aix/os_aix.cpp src/hotspot/os/bsd/os_bsd.cpp src/hotspot/os/linux/os_linux.cpp src/hotspot/os/posix/os_posix.cpp src/hotspot/os/solaris/os_solaris.cpp
diffstat 5 files changed, 13 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/os/aix/os_aix.cpp	Tue Jul 03 13:41:18 2018 -0400
+++ b/src/hotspot/os/aix/os_aix.cpp	Tue Jul 03 15:08:01 2018 -0400
@@ -1208,22 +1208,6 @@
   ::abort();
 }
 
-// This method is a copy of JDK's sysGetLastErrorString
-// from src/solaris/hpi/src/system_md.c
-
-size_t os::lasterror(char *buf, size_t len) {
-  if (errno == 0) return 0;
-
-  const char *s = os::strerror(errno);
-  size_t n = ::strlen(s);
-  if (n >= len) {
-    n = len - 1;
-  }
-  ::strncpy(buf, s, n);
-  buf[n] = '\0';
-  return n;
-}
-
 intx os::current_thread_id() {
   return (intx)pthread_self();
 }
--- a/src/hotspot/os/bsd/os_bsd.cpp	Tue Jul 03 13:41:18 2018 -0400
+++ b/src/hotspot/os/bsd/os_bsd.cpp	Tue Jul 03 15:08:01 2018 -0400
@@ -1081,22 +1081,6 @@
   ::abort();
 }
 
-// This method is a copy of JDK's sysGetLastErrorString
-// from src/solaris/hpi/src/system_md.c
-
-size_t os::lasterror(char *buf, size_t len) {
-  if (errno == 0)  return 0;
-
-  const char *s = os::strerror(errno);
-  size_t n = ::strlen(s);
-  if (n >= len) {
-    n = len - 1;
-  }
-  ::strncpy(buf, s, n);
-  buf[n] = '\0';
-  return n;
-}
-
 // Information of current thread in variety of formats
 pid_t os::Bsd::gettid() {
   int retval = -1;
--- a/src/hotspot/os/linux/os_linux.cpp	Tue Jul 03 13:41:18 2018 -0400
+++ b/src/hotspot/os/linux/os_linux.cpp	Tue Jul 03 15:08:01 2018 -0400
@@ -1419,23 +1419,6 @@
   ::abort();
 }
 
-
-// This method is a copy of JDK's sysGetLastErrorString
-// from src/solaris/hpi/src/system_md.c
-
-size_t os::lasterror(char *buf, size_t len) {
-  if (errno == 0)  return 0;
-
-  const char *s = os::strerror(errno);
-  size_t n = ::strlen(s);
-  if (n >= len) {
-    n = len - 1;
-  }
-  ::strncpy(buf, s, n);
-  buf[n] = '\0';
-  return n;
-}
-
 // thread_id is kernel thread id (similar to Solaris LWP id)
 intx os::current_thread_id() { return os::Linux::gettid(); }
 int os::current_process_id() {
--- a/src/hotspot/os/posix/os_posix.cpp	Tue Jul 03 13:41:18 2018 -0400
+++ b/src/hotspot/os/posix/os_posix.cpp	Tue Jul 03 15:08:01 2018 -0400
@@ -150,6 +150,19 @@
   return errno;
 }
 
+size_t os::lasterror(char *buf, size_t len) {
+  if (errno == 0)  return 0;
+
+  const char *s = os::strerror(errno);
+  size_t n = ::strlen(s);
+  if (n >= len) {
+    n = len - 1;
+  }
+  ::strncpy(buf, s, n);
+  buf[n] = '\0';
+  return n;
+}
+
 bool os::is_debugger_attached() {
   // not implemented
   return false;
--- a/src/hotspot/os/solaris/os_solaris.cpp	Tue Jul 03 13:41:18 2018 -0400
+++ b/src/hotspot/os/solaris/os_solaris.cpp	Tue Jul 03 15:08:01 2018 -0400
@@ -2010,23 +2010,6 @@
   // no suffix required
 }
 
-// This method is a copy of JDK's sysGetLastErrorString
-// from src/solaris/hpi/src/system_md.c
-
-size_t os::lasterror(char *buf, size_t len) {
-  if (errno == 0)  return 0;
-
-  const char *s = os::strerror(errno);
-  size_t n = ::strlen(s);
-  if (n >= len) {
-    n = len - 1;
-  }
-  ::strncpy(buf, s, n);
-  buf[n] = '\0';
-  return n;
-}
-
-
 // sun.misc.Signal
 
 extern "C" {