This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[PATCH] [MinGW] 3.4: Remove Conditional Compilation from Socket Classes
- From: Mohan Embar <gnustuff at thisiscool dot com>
- To: konqueror at gmx dot de
- Cc: java-patches at gcc dot gnu dot org
- Date: Fri, 05 Mar 2004 22:54:38 -0600
- Subject: [PATCH] [MinGW] 3.4: Remove Conditional Compilation from Socket Classes
- Reply-to: gnustuff at thisiscool dot com
Hi Michael,
This fixes the "java.net.SocketException: invalid length" bug
on Win32 you pointed out to me off list (jmdns). It does this
by removing all the unnecessary conditional compilation in
the socket classes that I overlooked in my networking/cleanup
patch after the POSIX / Win32 networking split.
This patch is against 3.4 only - I have no idea what the state
of 3.5 is at the moment.
What do you think?
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/
ChangeLog
2004-03-05 Mohan Embar <gnustuff@thisiscool.com>
* gnu/java/net/natPlainDatagramSocketImplWin32.cc (lots): Removed
conditional compilation.
(mcastGrp): Added missing declarations.
* gnu/java/net/natPlainSocketImplWin32.cc (lots): Removed
conditional compilation.
Index: gnu/java/net/natPlainDatagramSocketImplWin32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc,v
retrieving revision 1.7
diff -u -2 -r1.7 natPlainDatagramSocketImplWin32.cc
--- gnu/java/net/natPlainDatagramSocketImplWin32.cc 16 Dec 2003 22:57:06 -0000 1.7
+++ gnu/java/net/natPlainDatagramSocketImplWin32.cc 5 Mar 2004 04:01:10 -0000
@@ -11,9 +11,4 @@
#include <string.h>
-#if HAVE_BSTRING_H
-// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2
-#include <bstring.h>
-#endif
-
#include <gnu/java/net/PlainDatagramSocketImpl.h>
#include <java/io/IOException.h>
@@ -33,17 +28,11 @@
{
struct sockaddr_in address;
-#ifdef HAVE_INET6
struct sockaddr_in6 address6;
-#endif
};
union McastReq
{
-#if HAVE_STRUCT_IP_MREQ
struct ip_mreq mreq;
-#endif
-#if HAVE_STRUCT_IPV6_MREQ
struct ipv6_mreq mreq6;
-#endif
};
@@ -51,7 +40,5 @@
{
struct in_addr addr;
-#ifdef HAVE_INET6
struct in6_addr addr6;
-#endif
};
@@ -102,5 +89,4 @@
u.address.sin_port = htons (lport);
}
-#ifdef HAVE_INET6
else if (len == 16)
{
@@ -110,5 +96,4 @@
u.address6.sin6_port = htons (lport);
}
-#endif
else
throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
@@ -173,5 +158,4 @@
rport = ntohs (u.address.sin_port);
}
-#ifdef HAVE_INET6
else if (u.address.sin_family == AF_INET6)
{
@@ -180,5 +164,4 @@
rport = ntohs (u.address6.sin6_port);
}
-#endif
else
throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
@@ -228,5 +211,4 @@
rport = ntohs (u.address.sin_port);
}
-#ifdef HAVE_INET6
else if (u.address.sin_family == AF_INET6)
{
@@ -235,5 +217,4 @@
rport = ntohs (u.address6.sin6_port);
}
-#endif
else
throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
@@ -289,5 +270,4 @@
u.address.sin_port = htons (rport);
}
-#ifdef HAVE_INET6
else if (len == 16)
{
@@ -297,5 +277,4 @@
u.address6.sin6_port = htons (rport);
}
-#endif
else
throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
@@ -346,5 +325,4 @@
rport = ntohs (u.address.sin_port);
}
-#ifdef HAVE_INET6
else if (u.address.sin_family == AF_INET6)
{
@@ -353,5 +331,4 @@
rport = ntohs (u.address6.sin6_port);
}
-#endif
else
throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
@@ -407,5 +384,7 @@
{
// FIXME: implement use of NetworkInterface
+ union McastReq u;
jbyteArray haddress = inetaddr->addr;
+ jbyte *bytes = elements (haddress);
int len = haddress->length;
int level, opname;
@@ -413,5 +392,4 @@
if (0)
;
-#if HAVE_STRUCT_IP_MREQ
else if (len == 4)
{
@@ -425,18 +403,8 @@
ptr = (const char *) &u.mreq;
}
-#endif
-#if HAVE_STRUCT_IPV6_MREQ
else if (len == 16)
{
level = IPPROTO_IPV6;
- /* Prefer new RFC 2553 names. */
-#ifndef IPV6_JOIN_GROUP
-#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
-#endif
-#ifndef IPV6_LEAVE_GROUP
-#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
-#endif
-
opname = join ? IPV6_JOIN_GROUP : IPV6_LEAVE_GROUP;
memcpy (&u.mreq6.ipv6mr_multiaddr, bytes, len);
@@ -447,5 +415,4 @@
ptr = (const char *) &u.mreq6;
}
-#endif
else
throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
@@ -542,6 +509,4 @@
ptr = (const char *) &u.addr;
}
-// Tru64 UNIX V5.0 has struct sockaddr_in6, but no IPV6_MULTICAST_IF
-#if defined (HAVE_INET6) && defined (IPV6_MULTICAST_IF)
else if (len == 16)
{
@@ -552,5 +517,4 @@
ptr = (const char *) &u.addr6;
}
-#endif
else
throw
@@ -643,5 +607,4 @@
memcpy (elements (laddr), &u.address.sin_addr, 4);
}
-#ifdef HAVE_INET6
else if (u.address.sin_family == AF_INET6)
{
@@ -649,5 +612,4 @@
memcpy (elements (laddr), &u.address6.sin6_addr, 16);
}
-#endif
else
throw new ::java::net::SocketException (
Index: gnu/java/net/natPlainSocketImplWin32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/natPlainSocketImplWin32.cc,v
retrieving revision 1.9
diff -u -2 -r1.9 natPlainSocketImplWin32.cc
--- gnu/java/net/natPlainSocketImplWin32.cc 16 Dec 2003 22:57:06 -0000 1.9
+++ gnu/java/net/natPlainSocketImplWin32.cc 5 Mar 2004 04:01:11 -0000
@@ -37,7 +37,5 @@
{
struct sockaddr_in address;
-#ifdef HAVE_INET6
struct sockaddr_in6 address6;
-#endif
};
@@ -83,5 +81,4 @@
u.address.sin_port = htons (lport);
}
-#ifdef HAVE_INET6
else if (len == 16)
{
@@ -91,5 +88,4 @@
u.address6.sin6_port = htons (lport);
}
-#endif
else
throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
@@ -148,5 +144,4 @@
u.address.sin_port = htons (rport);
}
-#ifdef HAVE_INET6
else if (len == 16)
{
@@ -156,5 +151,4 @@
u.address6.sin6_port = htons (rport);
}
-#endif
else
throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
@@ -310,5 +304,4 @@
rport = ntohs (u.address.sin_port);
}
-#ifdef HAVE_INET6
else if (u.address.sin_family == AF_INET6)
{
@@ -317,5 +310,4 @@
rport = ntohs (u.address6.sin6_port);
}
-#endif
else
throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
@@ -715,5 +707,4 @@
memcpy (elements (laddr), &u.address.sin_addr, 4);
}
-#ifdef HAVE_INET6
else if (u.address.sin_family == AF_INET6)
{
@@ -721,5 +712,4 @@
memcpy (elements (laddr), &u.address6.sin6_addr, 16);
}
-#endif
else
throw new ::java::net::SocketException