This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: gnu.java.nio: splitting native files
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 11 Nov 2003 12:53:20 +0100
- Subject: FYI: Patch: gnu.java.nio: splitting native files
Hi list,
I commited the attached patch make it possible to implement different
implementations for non-posix systems.
Michael
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2327
diff -u -b -B -r1.2327 ChangeLog
--- ChangeLog 11 Nov 2003 11:34:23 -0000 1.2327
+++ ChangeLog 11 Nov 2003 11:46:12 -0000
@@ -1,3 +1,17 @@
+2003-11-11 Michael Koch <konqueror@gmx.de>
+
+ * gnu/java/nio/natPipeImpl.cc,
+ gnu/java/nio/natSelectorImpl.cc: Removed
+ * gnu/java/nio/natPipeImplEcos.cc,
+ gnu/java/nio/natPipeImplPosix.cc,
+ gnu/java/nio/natPipeImplWin32.cc,
+ gnu/java/nio/natSelectorImplEcos.cc,
+ gnu/java/nio/natSelectorImplPosix.cc,
+ gnu/java/nio/natSelectorImplWin32.cc: New files
+ * configure.in: Create links for gnu/java/nio/natPipeImpl.cc and
+ gnu/java/nio/natSelectorImpl.cc
+ * configure: Regenerated.
+
2003-11-11 Micheal Koch <konqueror@gmx.de>
* java/net/URLStreamHandler.java (toExternalForm): Print port only
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.in,v
retrieving revision 1.173
diff -u -b -B -r1.173 configure.in
--- configure.in 22 Oct 2003 16:35:15 -0000 1.173
+++ configure.in 11 Nov 2003 11:46:14 -0000
@@ -299,11 +299,16 @@
AC_LINK_FILES(java/net/natInetAddress${PLATFORMNET}.cc, java/net/natInetAddress.cc)
AC_LINK_FILES(java/net/natNetworkInterface${PLATFORMNET}.cc, java/net/natNetworkInterface.cc)
-dnl Likewise for natPlainSocketImpl.cc and natPlainDatagramSocketImpl.ca.c
+dnl Likewise for natPlainSocketImpl.cc and natPlainDatagramSocketImpl.cc.
test -d gnu/java || mkdir gnu/java
test -d gnu/java/net || mkdir gnu/java/net
AC_LINK_FILES(gnu/java/net/natPlainSocketImpl${PLATFORMNET}.cc, gnu/java/net/natPlainSocketImpl.cc)
AC_LINK_FILES(gnu/java/net/natPlainDatagramSocketImpl${PLATFORMNET}.cc, gnu/java/net/natPlainDatagramSocketImpl.cc)
+
+dnl Likewise for natPipeImpl.cc and natSelectorImpl.cc.
+test -d gnu/java/nio || mkdir gnu/java/nio
+AC_LINK_FILES(gnu/java/nio/natPipeImpl${PLATFORM}.cc, gnu/java/nio/natPipeImpl.cc)
+AC_LINK_FILES(gnu/java/nio/natSelectorImpl${PLATFORM}.cc, gnu/java/nio/natSelectorImpl.cc)
case "${host}" in
*mingw*)
Index: gnu/java/nio/natPipeImpl.cc
===================================================================
RCS file: gnu/java/nio/natPipeImpl.cc
diff -N gnu/java/nio/natPipeImpl.cc
--- gnu/java/nio/natPipeImpl.cc 17 Oct 2003 18:44:41 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,38 +0,0 @@
-// natPipeImpl.cc
-
-/* Copyright (C) 2003 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-#include <config.h>
-#include <platform.h>
-
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <gnu/java/nio/PipeImpl.h>
-//#include <gnu/java/nio/PipeImpl$SinkChannelImpl.h>
-//#include <gnu/java/nio/PipeImpl$SourceChannelImpl.h>
-#include <java/io/IOException.h>
-#include <java/nio/channels/spi/SelectorProvider.h>
-
-void
-gnu::java::nio::PipeImpl::nativeInit (::java::nio::channels::spi::SelectorProvider* /*provider*/)
-{
- int filedes [2];
-
- if (_Jv_pipe (filedes) < 0)
- throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
-
- /* FIXME
- source = new gnu::java::nio::PipeImpl$SourceChannelImpl
- (this, provider, filedes [0]);
- sink = new gnu::java::nio::PipeImpl$SinkChannelImpl
- (this, provider, filedes [1]);
- */
-}
Index: gnu/java/nio/natPipeImplEcos.cc
===================================================================
RCS file: gnu/java/nio/natPipeImplEcos.cc
diff -N gnu/java/nio/natPipeImplEcos.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/nio/natPipeImplEcos.cc 11 Nov 2003 11:46:14 -0000
@@ -0,0 +1,25 @@
+// natPipeImplEcos.cc
+
+/* Copyright (C) 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <gnu/java/nio/PipeImpl.h>
+#include <java/io/IOException.h>
+
+void
+gnu::java::nio::PipeImpl::nativeInit (::java::nio::channels::spi::SelectorProvider*)
+{
+ throw new ::java::io::IOException (JvNewStringUTF ("nativeInit() not implemented"));
+}
Index: gnu/java/nio/natPipeImplPosix.cc
===================================================================
RCS file: gnu/java/nio/natPipeImplPosix.cc
diff -N gnu/java/nio/natPipeImplPosix.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/nio/natPipeImplPosix.cc 11 Nov 2003 11:46:14 -0000
@@ -0,0 +1,38 @@
+// natPipeImplPosix.cc
+
+/* Copyright (C) 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <gnu/java/nio/PipeImpl.h>
+//#include <gnu/java/nio/PipeImpl$SinkChannelImpl.h>
+//#include <gnu/java/nio/PipeImpl$SourceChannelImpl.h>
+#include <java/io/IOException.h>
+#include <java/nio/channels/spi/SelectorProvider.h>
+
+void
+gnu::java::nio::PipeImpl::nativeInit (::java::nio::channels::spi::SelectorProvider* /*provider*/)
+{
+ int filedes [2];
+
+ if (_Jv_pipe (filedes) < 0)
+ throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
+
+ /* FIXME
+ source = new gnu::java::nio::PipeImpl$SourceChannelImpl
+ (this, provider, filedes [0]);
+ sink = new gnu::java::nio::PipeImpl$SinkChannelImpl
+ (this, provider, filedes [1]);
+ */
+}
Index: gnu/java/nio/natPipeImplWin32.cc
===================================================================
RCS file: gnu/java/nio/natPipeImplWin32.cc
diff -N gnu/java/nio/natPipeImplWin32.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/nio/natPipeImplWin32.cc 11 Nov 2003 11:46:14 -0000
@@ -0,0 +1,38 @@
+// natPipeImplWin32.cc
+
+/* Copyright (C) 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <gnu/java/nio/PipeImpl.h>
+//#include <gnu/java/nio/PipeImpl$SinkChannelImpl.h>
+//#include <gnu/java/nio/PipeImpl$SourceChannelImpl.h>
+#include <java/io/IOException.h>
+#include <java/nio/channels/spi/SelectorProvider.h>
+
+void
+gnu::java::nio::PipeImpl::nativeInit (::java::nio::channels::spi::SelectorProvider* /*provider*/)
+{
+ int filedes [2];
+
+ if (_Jv_pipe (filedes) < 0)
+ throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
+
+ /* FIXME
+ source = new gnu::java::nio::PipeImpl$SourceChannelImpl
+ (this, provider, filedes [0]);
+ sink = new gnu::java::nio::PipeImpl$SinkChannelImpl
+ (this, provider, filedes [1]);
+ */
+}
Index: gnu/java/nio/natSelectorImpl.cc
===================================================================
RCS file: gnu/java/nio/natSelectorImpl.cc
diff -N gnu/java/nio/natSelectorImpl.cc
--- gnu/java/nio/natSelectorImpl.cc 25 Sep 2003 17:09:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,91 +0,0 @@
-// natSelectorImpl.cc
-
-/* Copyright (C) 2002, 2003 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-#include <config.h>
-#include <platform.h>
-
-#include <errno.h>
-#include <string.h>
-
-#include <gnu/java/nio/SelectorImpl.h>
-#include <java/io/IOException.h>
-
-void
-helper_put_filedescriptors (jintArray fdArray, fd_set& fds, int& max_fd)
-{
- jint* tmpFDArray = elements (fdArray);
-
- for (int index = 0; index < JvGetArrayLength (fdArray); index++)
- {
- FD_SET (tmpFDArray [index], &fds);
-
- if (tmpFDArray [index] > max_fd)
- max_fd = tmpFDArray [index];
- }
-}
-
-void
-helper_get_filedescriptors (jintArray& fdArray, fd_set fds)
-{
- jint* tmpFDArray = elements (fdArray);
-
- for (int index = 0; index < JvGetArrayLength (fdArray); index++)
- if (!FD_ISSET (tmpFDArray [index], &fds))
- tmpFDArray [index] = 0;
-}
-
-jint
-gnu::java::nio::SelectorImpl::implSelect (jintArray read, jintArray write,
- jintArray except, jlong timeout)
-{
- jint result;
- int max_fd = 0;
- fd_set read_fds;
- fd_set write_fds;
- fd_set except_fds;
- struct timeval real_time_data;
- struct timeval *time_data = NULL;
-
- real_time_data.tv_sec = 0;
- real_time_data.tv_usec = timeout;
-
- // If not legal timeout value is given, use NULL.
- // This means an infinite timeout.
- if (timeout >= 0)
- {
- time_data = &real_time_data;
- }
-
- // Reset all fd_set structures
- FD_ZERO (&read_fds);
- FD_ZERO (&write_fds);
- FD_ZERO (&except_fds);
-
- // Fill the fd_set data structures for the _Jv_select() call.
- helper_put_filedescriptors (read, read_fds, max_fd);
- helper_put_filedescriptors (write, write_fds, max_fd);
- helper_put_filedescriptors (except, except_fds, max_fd);
-
- // Actually do the select
- result = _Jv_select (max_fd + 1, &read_fds, &write_fds, &except_fds, time_data);
-
- if (result < 0)
- {
- char* strerr = strerror (errno);
- throw new ::java::io::IOException (JvNewStringUTF (strerr));
- }
-
- // Set the file descriptors according to the values returned from select().
- helper_get_filedescriptors (read, read_fds);
- helper_get_filedescriptors (write, write_fds);
- helper_get_filedescriptors (except, except_fds);
-
- return result;
-}
Index: gnu/java/nio/natSelectorImplEcos.cc
===================================================================
RCS file: gnu/java/nio/natSelectorImplEcos.cc
diff -N gnu/java/nio/natSelectorImplEcos.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/nio/natSelectorImplEcos.cc 11 Nov 2003 11:46:14 -0000
@@ -0,0 +1,25 @@
+// natSelectorImplEcos.cc
+
+/* Copyright (C) 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#include <errno.h>
+#include <string.h>
+
+#include <gnu/java/nio/SelectorImpl.h>
+#include <java/io/IOException.h>
+
+jint
+gnu::java::nio::SelectorImpl::implSelect (jintArray read, jintArray write,
+ jintArray except, jlong timeout)
+{
+ throw new ::java::io::IOException (JvNewStringUTF ("implSelect() not implemented"));
+}
Index: gnu/java/nio/natSelectorImplPosix.cc
===================================================================
RCS file: gnu/java/nio/natSelectorImplPosix.cc
diff -N gnu/java/nio/natSelectorImplPosix.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/nio/natSelectorImplPosix.cc 11 Nov 2003 11:46:14 -0000
@@ -0,0 +1,91 @@
+// natSelectorImplPosix.cc
+
+/* Copyright (C) 2002, 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#include <errno.h>
+#include <string.h>
+
+#include <gnu/java/nio/SelectorImpl.h>
+#include <java/io/IOException.h>
+
+void
+helper_put_filedescriptors (jintArray fdArray, fd_set& fds, int& max_fd)
+{
+ jint* tmpFDArray = elements (fdArray);
+
+ for (int index = 0; index < JvGetArrayLength (fdArray); index++)
+ {
+ FD_SET (tmpFDArray [index], &fds);
+
+ if (tmpFDArray [index] > max_fd)
+ max_fd = tmpFDArray [index];
+ }
+}
+
+void
+helper_get_filedescriptors (jintArray& fdArray, fd_set fds)
+{
+ jint* tmpFDArray = elements (fdArray);
+
+ for (int index = 0; index < JvGetArrayLength (fdArray); index++)
+ if (!FD_ISSET (tmpFDArray [index], &fds))
+ tmpFDArray [index] = 0;
+}
+
+jint
+gnu::java::nio::SelectorImpl::implSelect (jintArray read, jintArray write,
+ jintArray except, jlong timeout)
+{
+ jint result;
+ int max_fd = 0;
+ fd_set read_fds;
+ fd_set write_fds;
+ fd_set except_fds;
+ struct timeval real_time_data;
+ struct timeval *time_data = NULL;
+
+ real_time_data.tv_sec = 0;
+ real_time_data.tv_usec = timeout;
+
+ // If not legal timeout value is given, use NULL.
+ // This means an infinite timeout.
+ if (timeout >= 0)
+ {
+ time_data = &real_time_data;
+ }
+
+ // Reset all fd_set structures
+ FD_ZERO (&read_fds);
+ FD_ZERO (&write_fds);
+ FD_ZERO (&except_fds);
+
+ // Fill the fd_set data structures for the _Jv_select() call.
+ helper_put_filedescriptors (read, read_fds, max_fd);
+ helper_put_filedescriptors (write, write_fds, max_fd);
+ helper_put_filedescriptors (except, except_fds, max_fd);
+
+ // Actually do the select
+ result = _Jv_select (max_fd + 1, &read_fds, &write_fds, &except_fds, time_data);
+
+ if (result < 0)
+ {
+ char* strerr = strerror (errno);
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+ }
+
+ // Set the file descriptors according to the values returned from select().
+ helper_get_filedescriptors (read, read_fds);
+ helper_get_filedescriptors (write, write_fds);
+ helper_get_filedescriptors (except, except_fds);
+
+ return result;
+}
Index: gnu/java/nio/natSelectorImplWin32.cc
===================================================================
RCS file: gnu/java/nio/natSelectorImplWin32.cc
diff -N gnu/java/nio/natSelectorImplWin32.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/nio/natSelectorImplWin32.cc 11 Nov 2003 11:46:14 -0000
@@ -0,0 +1,91 @@
+// natSelectorImplWin32.cc
+
+/* Copyright (C) 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#include <errno.h>
+#include <string.h>
+
+#include <gnu/java/nio/SelectorImpl.h>
+#include <java/io/IOException.h>
+
+void
+helper_put_filedescriptors (jintArray fdArray, fd_set& fds, int& max_fd)
+{
+ jint* tmpFDArray = elements (fdArray);
+
+ for (int index = 0; index < JvGetArrayLength (fdArray); index++)
+ {
+ FD_SET (tmpFDArray [index], &fds);
+
+ if (tmpFDArray [index] > max_fd)
+ max_fd = tmpFDArray [index];
+ }
+}
+
+void
+helper_get_filedescriptors (jintArray& fdArray, fd_set fds)
+{
+ jint* tmpFDArray = elements (fdArray);
+
+ for (int index = 0; index < JvGetArrayLength (fdArray); index++)
+ if (!FD_ISSET (tmpFDArray [index], &fds))
+ tmpFDArray [index] = 0;
+}
+
+jint
+gnu::java::nio::SelectorImpl::implSelect (jintArray read, jintArray write,
+ jintArray except, jlong timeout)
+{
+ jint result;
+ int max_fd = 0;
+ fd_set read_fds;
+ fd_set write_fds;
+ fd_set except_fds;
+ struct timeval real_time_data;
+ struct timeval *time_data = NULL;
+
+ real_time_data.tv_sec = 0;
+ real_time_data.tv_usec = timeout;
+
+ // If not legal timeout value is given, use NULL.
+ // This means an infinite timeout.
+ if (timeout >= 0)
+ {
+ time_data = &real_time_data;
+ }
+
+ // Reset all fd_set structures
+ FD_ZERO (&read_fds);
+ FD_ZERO (&write_fds);
+ FD_ZERO (&except_fds);
+
+ // Fill the fd_set data structures for the _Jv_select() call.
+ helper_put_filedescriptors (read, read_fds, max_fd);
+ helper_put_filedescriptors (write, write_fds, max_fd);
+ helper_put_filedescriptors (except, except_fds, max_fd);
+
+ // Actually do the select
+ result = _Jv_select (max_fd + 1, &read_fds, &write_fds, &except_fds, time_data);
+
+ if (result < 0)
+ {
+ char* strerr = strerror (errno);
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+ }
+
+ // Set the file descriptors according to the values returned from select().
+ helper_get_filedescriptors (read, read_fds);
+ helper_get_filedescriptors (write, write_fds);
+ helper_get_filedescriptors (except, except_fds);
+
+ return result;
+}