diff options
-rw-r--r-- | libjava/ChangeLog | 10 | ||||
-rw-r--r-- | libjava/java/net/natPlainDatagramSocketImpl.cc | 14 | ||||
-rw-r--r-- | libjava/java/net/natPlainSocketImpl.cc | 26 |
3 files changed, 47 insertions, 3 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index a46d06b..f3dd682 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,13 @@ +2001-07-30 Jeff Sturm <jsturm@one-point.com> + + * java/net/natPlainDatagramSocketImpl.cc: Undefine bind if defined. + (_Jv_bind): New static function. + (bind): Use _Jv_bind. + * java/net/natPlainSocketImpl.cc: Undefine bind, connect if defined. + (_Jv_bind, _Jv_connect): New static functions. + (bind): Use _Jv_bind. + (connect): Use _Jv_connect. + 2001-07-30 Tom Tromey <tromey@redhat.com> Corey Minyard <minyard@acm.org> diff --git a/libjava/java/net/natPlainDatagramSocketImpl.cc b/libjava/java/net/natPlainDatagramSocketImpl.cc index 4f6b319..e15ead2 100644 --- a/libjava/java/net/natPlainDatagramSocketImpl.cc +++ b/libjava/java/net/natPlainDatagramSocketImpl.cc @@ -36,6 +36,18 @@ details. */ #include <bstring.h> #endif +// Avoid macro definitions of bind from system headers, e.g. on +// Solaris 7 with _XOPEN_SOURCE. FIXME +static inline int +_Jv_bind (int fd, struct sockaddr *addr, int addrlen) +{ + return ::bind (fd, addr, addrlen); +} + +#ifdef bind +#undef bind +#endif + #include <gcj/cni.h> #include <java/io/IOException.h> #include <java/io/FileDescriptor.h> @@ -210,7 +222,7 @@ java::net::PlainDatagramSocketImpl::bind (jint lport, else throw new java::net::SocketException (JvNewStringUTF ("invalid length")); - if (::bind (fnum, ptr, len) == 0) + if (_Jv_bind (fnum, ptr, len) == 0) { socklen_t addrlen = sizeof(u); if (lport != 0) diff --git a/libjava/java/net/natPlainSocketImpl.cc b/libjava/java/net/natPlainSocketImpl.cc index 751b798..545c514 100644 --- a/libjava/java/net/natPlainSocketImpl.cc +++ b/libjava/java/net/natPlainSocketImpl.cc @@ -33,6 +33,28 @@ details. */ #include <bstring.h> #endif +// Avoid macro definitions of bind, connect from system headers, e.g. on +// Solaris 7 with _XOPEN_SOURCE. FIXME +static inline int +_Jv_bind (int fd, struct sockaddr *addr, int addrlen) +{ + return ::bind (fd, addr, addrlen); +} + +#ifdef bind +#undef bind +#endif + +static inline int +_Jv_connect (int fd, struct sockaddr *addr, int addrlen) +{ + return ::connect (fd, addr, addrlen); +} + +#ifdef connect +#undef connect +#endif + #include <gcj/cni.h> #include <gcj/javaprims.h> #include <java/io/IOException.h> @@ -164,7 +186,7 @@ java::net::PlainSocketImpl::bind (java::net::InetAddress *host, jint lport) // Enable SO_REUSEADDR, so that servers can reuse ports left in TIME_WAIT. ::setsockopt(fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof(i)); - if (::bind (fnum, ptr, len) == 0) + if (_Jv_bind (fnum, ptr, len) == 0) { address = host; socklen_t addrlen = sizeof(u); @@ -209,7 +231,7 @@ java::net::PlainSocketImpl::connect (java::net::InetAddress *host, jint rport) else throw new java::net::SocketException (JvNewStringUTF ("invalid length")); - if (::connect (fnum, ptr, len) != 0) + if (_Jv_connect (fnum, ptr, len) != 0) goto error; address = host; port = rport; |