Hello all,
the attached patch fixes the current cvs on darwin-ppc. Not tested on
functionality yet. But it builds :)
Build tested on darwin-ppc and linux-pcc. Other archs, sparc-solaris and
hpux maybe tested later.
Ok?
Andreas
P.S, the SYNC bits are taken from gcc/libjava.
2006-08-28 Andreas Tobler <[EMAIL PROTECTED]>
* configure.ac: Add check for gethostbyname_r.
Add check for MSG_NOSIGNAL and SO_NOSIGPIPE.
* native/jni/native-lib/cpnet.c (SOCKET_NOSIGNAL): Define
SOCKET_NOSIGNAL according to the configure check.
(cpnet_send): Use SOCKET_NOSIGNAL.
(cpnet_sendTo): Likewise.
(cpnet_getHostByName): Use gethostbyname in case gethostbyname_r is not
defined.
* native/jni/native-lib/cpio.c: Define O_SYNC and O_DSYNC in case they
are not available.
Index: configure.ac
===================================================================
RCS file: /cvsroot/classpath/classpath/configure.ac,v
retrieving revision 1.180
diff -u -r1.180 configure.ac
--- configure.ac 21 Aug 2006 23:34:43 -0000 1.180
+++ configure.ac 28 Aug 2006 20:00:56 -0000
@@ -368,7 +368,7 @@
lseek fstat read write htonl memset htons connect \
getsockname getpeername bind listen accept \
recvfrom send sendto setsockopt getsockopt time mktime \
- localtime_r \
+ gethostbyname_r localtime_r \
strerror_r \
fcntl \
mmap munmap mincore msync madvise getpagesize sysconf \
@@ -550,6 +550,28 @@
AC_SUBST(QT_CFLAGS)
AC_SUBST(QT_LIBS)
fi
+ dnl **********************************************************************
+ dnl Check for MSG_NOSIGNAL
+ dnl **********************************************************************
+ AC_MSG_CHECKING(for MSG_NOSIGNAL)
+ AC_TRY_COMPILE([#include <sys/socket.h>],
+ [ int f = MSG_NOSIGNAL; ],
+ [ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_MSG_NOSIGNAL, 1,
+ [Define this symbol if you have MSG_NOSIGNAL]) ],
+ [ AC_MSG_RESULT(no)]
+ )
+ dnl **********************************************************************
+ dnl Check for SO_NOSIGPIPE (Darwin equivalent for MSG_NOSIGNAL)
+ dnl **********************************************************************
+ AC_MSG_CHECKING(for SO_NOSIGPIPE )
+ AC_TRY_COMPILE([#include <sys/socket.h>],
+ [ int f = SO_NOSIGPIPE; ],
+ [ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SO_NOSIGPIPE, 1,
+ [Define this symbol if you have SO_NOSIGPIPE]) ],
+ [ AC_MSG_RESULT(no)]
+ )
dnl Check for plugin support headers and libraries.
if test "x${COMPILE_PLUGIN}" = xyes; then
Index: native/jni/native-lib/cpio.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/native-lib/cpio.c,v
retrieving revision 1.2
diff -u -r1.2 cpio.c
--- native/jni/native-lib/cpio.c 21 Aug 2006 23:34:46 -0000 1.2
+++ native/jni/native-lib/cpio.c 28 Aug 2006 20:00:56 -0000
@@ -76,6 +76,18 @@
#include "cpnative.h"
#include "cpio.h"
+/* Some POSIX systems don't have O_SYNC and O_DYSNC so we define them here. */
+#if !defined (O_SYNC) && defined (O_FSYNC)
+#define O_SYNC O_FSYNC
+#endif
+#if !defined (O_DSYNC) && defined (O_FSYNC)
+#define O_DSYNC O_FSYNC
+#endif
+/* If O_DSYNC is still not defined, use O_SYNC (needed for newlib). */
+#if !defined (O_DSYNC)
+#define O_DSYNC O_SYNC
+#endif
+
JNIEXPORT int cpio_openFile (const char *filename, int *fd, int flags, int
permissions)
{
int sflags = 0;
Index: native/jni/native-lib/cpnet.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/native-lib/cpnet.c,v
retrieving revision 1.2
diff -u -r1.2 cpnet.c
--- native/jni/native-lib/cpnet.c 21 Aug 2006 23:34:46 -0000 1.2
+++ native/jni/native-lib/cpnet.c 28 Aug 2006 20:00:57 -0000
@@ -54,6 +54,14 @@
#define SOCKET_DEFAULT_TIMEOUT -1 /* milliseconds */
+#if defined (HAVE_MSG_NOSIGNAL)
+#define SOCKET_NOSIGNAL MSG_NOSIGNAL
+#elif defined (HAVE_SO_NOSIGPIPE)
+#define SOCKET_NOSIGNAL SO_NOSIGPIPE
+#else
+#define SOCKET_NOSIGNAL 0
+#endif
+
static int socketTimeouts[FD_SETSIZE];
static jint waitForWritable(jint fd)
@@ -247,7 +255,7 @@
if (waitForWritable(fd) < 0)
return ETIMEDOUT;
- ret = send(fd, data, len, MSG_NOSIGNAL);
+ ret = send(fd, data, len, SOCKET_NOSIGNAL);
if (ret < 0)
return errno;
@@ -263,7 +271,8 @@
if (waitForWritable(fd) < 0)
return ETIMEDOUT;
- ret = sendto(fd, data, len, MSG_NOSIGNAL, (struct sockaddr *)addr->data,
addr->len);
+ ret = sendto(fd, data, len, SOCKET_NOSIGNAL, (struct sockaddr *)addr->data,
+ addr->len);
if (ret < 0)
return errno;
@@ -598,7 +607,11 @@
do
{
buf = (char *)JCL_malloc(env, buflen);
+#ifdef HAVE_GETHOSTBYNAME_R
ret = gethostbyname_r (hostname, &hret, buf, buflen, &result, &herr);
+#else
+ ret = gethostbyname (hostname);
+#endif
if (ret != 0 || result == NULL)
{
if (herr == ERANGE)