8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
Summary: Use final POSIX 1003.1c versions of getgrgid_r(), getgrnam_r(), getpwnam_r(), and getpwuid_r().
Reviewed-by: alanb, dcubed, simonis, dholmes
Contributed-by: alan.burlison@oracle.com
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp Fri Jul 15 12:40:47 2016 +0000
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Fri Jul 15 09:36:28 2016 -0700
@@ -79,7 +79,6 @@
# include <link.h>
# include <poll.h>
# include <pthread.h>
-# include <pwd.h>
# include <schedctl.h>
# include <setjmp.h>
# include <signal.h>
--- a/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp Fri Jul 15 12:40:47 2016 +0000
+++ b/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp Fri Jul 15 09:36:28 2016 -0700
@@ -34,16 +34,18 @@
#include "utilities/exceptions.hpp"
// put OS-includes here
-# include <sys/types.h>
-# include <sys/mman.h>
-# include <errno.h>
-# include <stdio.h>
-# include <unistd.h>
-# include <sys/stat.h>
-# include <signal.h>
-# include <pwd.h>
-# include <procfs.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <signal.h>
+#include <procfs.h>
+/* For POSIX-compliant getpwuid_r on Solaris */
+#define _POSIX_PTHREAD_SEMANTICS
+#include <pwd.h>
static char* backing_store_file_name = NULL; // name of the backing store
// file, if successfully created.
@@ -453,12 +455,8 @@
char* pwbuf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
-#ifdef _GNU_SOURCE
struct passwd* p = NULL;
int result = getpwuid_r(uid, &pwent, pwbuf, (size_t)bufsize, &p);
-#else // _GNU_SOURCE
- struct passwd* p = getpwuid_r(uid, &pwent, pwbuf, (int)bufsize);
-#endif // _GNU_SOURCE
if (p == NULL || p->pw_name == NULL || *(p->pw_name) == '\0') {
if (PrintMiscellaneous && Verbose) {
--- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Fri Jul 15 12:40:47 2016 +0000
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Fri Jul 15 09:36:28 2016 -0700
@@ -74,7 +74,6 @@
# include <sys/systeminfo.h>
# include <sys/socket.h>
# include <sys/lwp.h>
-# include <pwd.h>
# include <poll.h>
# include <sys/lwp.h>
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Fri Jul 15 12:40:47 2016 +0000
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Fri Jul 15 09:36:28 2016 -0700
@@ -74,7 +74,6 @@
# include <sys/socket.h>
# include <sys/trap.h>
# include <sys/lwp.h>
-# include <pwd.h>
# include <poll.h>
# include <sys/lwp.h>
# include <procfs.h> // see comment in <sys/procfs.h>