This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Accepting IRIX 5.2's old-style getpwuid_r


Here's a patch to accept old-style getpwuid_r, that returns struct
passwd* instead of taking it by reference and returning int.  I'm
checking it in the branch and in mainline.  Hopefully, it's not too
late for 2.95.1.  There's just one more nit remaining for a clean
build on IRIX 5.2 (ctime_r has an additional argument).  I'm working
on it right now.  Hopefully, I'll have patience to fix a couple of
SunOS 4.1.3 problems too (the host in question is too slow)

Index: libjava/ChangeLog
from  Alexandre Oliva  <oliva@dcc.unicamp.br>
	
	* configure.in: Check whether getpwuid_r returns int.
	* acconfig.h (HAVE_GETPWUID_R, GETPWUID_R_RETURNS_INT): Added.
	* java/lang/natSystem.cc (init_properties): Assume getpwuid_r
	returns struct passwd* unless it is found to return int.
	* configure, include/config.h.in: Rebuilt.
	
Index: libjava/configure.in
===================================================================
RCS file: /cvs/java/libgcj/libjava/configure.in,v
retrieving revision 1.11.2.8
diff -u -r1.11.2.8 configure.in
--- libjava/configure.in	1999/08/09 18:53:10	1.11.2.8
+++ libjava/configure.in	1999/08/21 09:29:38
@@ -298,7 +298,16 @@
    # E.g., Solaris.
    AC_CHECK_FUNCS(strerror ioctl select open fsync sleep)
    AC_CHECK_FUNCS(ctime_r ctime, break)
-   AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r getpwuid_r)
+   AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r)
+
+   AC_CHECK_FUNCS(getpwuid_r, [
+     AC_DEFINE(HAVE_GETPWUID_R)
+     # There are two different kinds of getpwuid_r.
+     # We look for the one that returns `int'.
+     # Hopefully this check is robust enough.
+     AC_EGREP_HEADER(int.*getpwuid_r, pwd.h, [
+       AC_DEFINE(GETPWUID_R_RETURNS_INT)])])
+
    AC_CHECK_FUNCS(access stat mkdir rename rmdir unlink realpath)
    AC_CHECK_FUNCS(inet_aton inet_addr, break)
    AC_CHECK_FUNCS(inet_pton uname)
Index: libjava/acconfig.h
===================================================================
RCS file: /cvs/java/libgcj/libjava/acconfig.h,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 acconfig.h
--- libjava/acconfig.h	1999/06/24 20:14:56	1.2.2.1
+++ libjava/acconfig.h	1999/08/21 09:29:38
@@ -67,6 +67,9 @@
 /* Define if gethostname is declared in <unistd.h>.  */
 #undef HAVE_GETHOSTNAME_DECL
 
+/* Define if getpwuid_r returns `int'.  */
+#undef GETPWUID_R_RETURNS_INT
+
 /* Define if gethostbyname_r returns `int'.  */
 #undef GETHOSTBYNAME_R_RETURNS_INT
 
@@ -91,5 +94,6 @@
 #undef HAVE_UNLINK
 #undef HAVE_REALPATH
 #undef HAVE_READDIR_R
+#undef HAVE_GETPWUID_R
 #undef HAVE_GETHOSTBYNAME_R
 #undef HAVE_GETHOSTBYADDR_R
Index: libjava/java/lang/natSystem.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/natSystem.cc,v
retrieving revision 1.7.2.1
diff -u -r1.7.2.1 natSystem.cc
--- libjava/java/lang/natSystem.cc	1999/07/31 23:42:11	1.7.2.1
+++ libjava/java/lang/natSystem.cc	1999/08/21 09:29:39
@@ -293,7 +293,13 @@
 
   while (buf_r != NULL)
     {
-      int r = getpwuid_r (user_id, &pwd_r, buf_r, len_r, &pwd_entry);
+      int r;
+#ifdef GETPWUID_R_RETURNS_INT
+      r = getpwuid_r (user_id, &pwd_r, buf_r, len_r, &pwd_entry);
+#else
+      pwd_entry = getpwuid_r (user_id, &pwd_r, buf_r, len_r);
+      r = (pwd_entry == NULL) ? errno : 0;
+#endif
       if (r == 0)
 	break;
       else if (r != ERANGE)

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{dcc.unicamp.br,guarana.{org,com}} aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]