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]

Re: in_addr_t is not defined on SunOS4...


On Aug 21, 1999, Alexandre Oliva <oliva@dcc.unicamp.br> wrote:

> On Aug 21, 1999, Alexandre Oliva <oliva@dcc.unicamp.br> wrote:
>> On Aug 21, 1999, Alexandre Oliva <oliva@dcc.unicamp.br> wrote:

>> After some research, I found out it was only typedef in sys/types.h on
>> DU4.0d; I couldn't find it in any other platform I've got, so I'll
>> assume it's safe to AC_CHECK_TYPE it.

> The default type I had chosen in the posted patch, `struct in_addr',
> would not work, since the code assumed an integral type, so I'm
> installing this additional change, that makes in a `jint' that, as a
> 32bit value, should work perfectly well for an IPv4 address.

And after some more research, now with help from the compiler, I found
out Solaris7 does typedef in_addr_t in netinet/in.h, and the `jint'
#define screwed everything up :-(

This patch also fixes another problem on SunOS: struct ip_mreq is not
defined anywhere, so I guess IP Multicast is not available.  The
work-around was to disable this feature when this struct was not
defined.

I'm checking in the following patch (this one, tested on all platforms
I've got :-), in the trunk and the branch:

Index: libjava/ChangeLog
from  Alexandre Oliva  <oliva@dcc.unicamp.br>
	* configure.in: Check for in_addr_t in netinet/in.h too.  Check
	for ip_mreq too.
	* acconfig.h: Define HAVE_IN_ADDR_T instead of in_addr_t.
	(HAVE_STRUCT_IP_MREQ): Added.
	* configure, include/config.h.in: Rebuilt.
	* java/net/natInetAddress.cc (aton): Typedef in_addr_t to jint
	if needed.
	* java/net/natPlainDatagramSocketImpl.cc (McastReq, mcastGrp):
	Disable if ip_mreq is not available.
	
Index: libjava/configure.in
===================================================================
RCS file: /cvs/java/libgcj/libjava/configure.in,v
retrieving revision 1.11.2.10
diff -u -r1.11.2.10 configure.in
--- libjava/configure.in	1999/08/21 13:35:03	1.11.2.10
+++ libjava/configure.in	1999/08/21 14:08:42
@@ -518,7 +518,25 @@
 AC_CHECK_HEADERS(dirent.h)
 
 AC_CHECK_TYPE([ssize_t], [int])
-AC_CHECK_TYPE([in_addr_t], [jint])
+
+AC_MSG_CHECKING([for in_addr_t])
+AC_TRY_COMPILE([#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif], [in_addr_t foo;],
+  [AC_DEFINE([HAVE_IN_ADDR_T])
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)])
+
+AC_MSG_CHECKING([whether struct ip_mreq is in netinet/in.h])
+AC_TRY_COMPILE([#include <netinet/in.h>], [struct ip_mreq mreq;],
+  [AC_DEFINE(HAVE_STRUCT_IP_MREQ)
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)])
 
 AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
 AC_TRY_COMPILE([#include <netinet/in.h>], [struct sockaddr_in6 addr6;],
Index: libjava/acconfig.h
===================================================================
RCS file: /cvs/java/libgcj/libjava/acconfig.h,v
retrieving revision 1.2.2.3
diff -u -r1.2.2.3 acconfig.h
--- libjava/acconfig.h	1999/08/21 13:35:00	1.2.2.3
+++ libjava/acconfig.h	1999/08/21 14:08:42
@@ -58,11 +58,15 @@
 /* Define to `int' if `ssize_t' is not defined.  */
 #undef ssize_t
 
-/* Define to `jint' if `in_addr_t' is not defined.  */
-#undef in_addr_t
+/* Define to 1 if `in_addr_t' is defined in sys/types.h or
+   netinet/in.h.  */
+#undef HAVE_IN_ADDR_T
 
 /* Define if inet6 structures are defined in netinet/in.h.  */
 #undef HAVE_INET6
+
+/* Define if struct ip_mreq is defined in netinet/in.h.  */
+#undef HAVE_STRUCT_IP_MREQ
 
 /* Define it socklen_t typedef is in sys/socket.h.  */
 #undef HAVE_SOCKLEN_T
Index: libjava/java/net/natInetAddress.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/net/natInetAddress.cc,v
retrieving revision 1.6.2.1
diff -u -r1.6.2.1 natInetAddress.cc
--- libjava/java/net/natInetAddress.cc	1999/08/01 00:14:00	1.6.2.1
+++ libjava/java/net/natInetAddress.cc	1999/08/21 14:08:42
@@ -71,6 +71,9 @@
       blen = 4;
     }
 #elif defined(HAVE_INET_ADDR)
+#if ! HAVE_IN_ADDR_T
+  typedef jint in_addr_t;
+#endif
   in_addr_t laddr = inet_addr (hostname);
   if (laddr != (in_addr_t)(-1))
     {
Index: libjava/java/net/natPlainDatagramSocketImpl.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/net/natPlainDatagramSocketImpl.cc,v
retrieving revision 1.5.2.2
diff -u -r1.5.2.2 natPlainDatagramSocketImpl.cc
--- libjava/java/net/natPlainDatagramSocketImpl.cc	1999/08/21 12:09:44	1.5.2.2
+++ libjava/java/net/natPlainDatagramSocketImpl.cc	1999/08/21 14:08:42
@@ -52,7 +52,9 @@
 
 union McastReq
 {
+#if HAVE_STRUCT_IP_MREQ
   struct ip_mreq mreq;
+#endif
 #ifdef HAVE_INET6
   struct ipv6_mreq mreq6;
 #endif
@@ -298,7 +300,10 @@
   int len = haddress->length;
   int level, opname;
   const char *ptr;
-  if (len == 4)
+  if (0)
+    ;
+#if HAVE_STRUCT_IP_MREQ
+  else if (len == 4)
     {
       level = IPPROTO_IP;
       opname = join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP;
@@ -308,6 +313,7 @@
       len = sizeof (struct ip_mreq);
       ptr = (const char *) &u.mreq;
     }
+#endif
 #ifdef HAVE_INET6
   else if (len == 16)
     {

-- 
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]