# HG changeset patch # User coleenp # Date 1530644881 14400 # Node ID 6a5f1195e15f21610a5d2ccff6d60fb53cf7058d # Parent ef57cfcd22ff0b44517c4022c1d098ba496df59f 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 diff -r ef57cfcd22ff -r 6a5f1195e15f src/hotspot/os/aix/os_aix.cpp --- 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(); } diff -r ef57cfcd22ff -r 6a5f1195e15f src/hotspot/os/bsd/os_bsd.cpp --- 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; diff -r ef57cfcd22ff -r 6a5f1195e15f src/hotspot/os/linux/os_linux.cpp --- 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() { diff -r ef57cfcd22ff -r 6a5f1195e15f src/hotspot/os/posix/os_posix.cpp --- 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; diff -r ef57cfcd22ff -r 6a5f1195e15f src/hotspot/os/solaris/os_solaris.cpp --- 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" {