From 463c03f1bc2380d46a39e63efd00df157a18fee2 Mon Sep 17 00:00:00 2001 From: Gary Benson Date: Thu, 18 Jan 2007 11:32:40 +0000 Subject: natVMPipeEcos.cc: Renamed from gnu/java/nio/natPipeImplEcos.cc. 2007-01-18 Gary Benson * gnu/java/nio/natVMPipeEcos.cc: Renamed from gnu/java/nio/natPipeImplEcos.cc. * gnu/java/nio/natVMPipePosix.cc: Renamed from gnu/java/nio/natPipeImplPosix.cc. * gnu/java/nio/natVMPipeWin32.cc: Renamed from gnu/java/nio/natPipeImplWin32.cc. * gnu/java/nio/natVMSelectorEcos.cc: Renamed from gnu/java/nio/natSelectorImplEcos.cc. * gnu/java/nio/natVMSelectorPosix.cc: Renamed from gnu/java/nio/natSelectorImplPosix.cc. * gnu/java/nio/natVMSelectorWin32.cc: Renamed from gnu/java/nio/natSelectorImplWin32.cc. * java/io/natVMObjectInputStream.cc: Renamed from java/io/natObjectInputStream.cc. * java/lang/natVMDouble.cc: Renamed from java/lang/natDouble.cc. * java/lang/natVMFloat.cc: Renamed from java/lang/natFloat.cc. * Makefile.am, configure.ac: Reflect the above. * Makefile.in, configure: Rebuilt. From-SVN: r120895 --- libjava/gnu/java/nio/natPipeImplEcos.cc | 27 ------ libjava/gnu/java/nio/natPipeImplPosix.cc | 41 --------- libjava/gnu/java/nio/natPipeImplWin32.cc | 40 --------- libjava/gnu/java/nio/natSelectorImplEcos.cc | 25 ------ libjava/gnu/java/nio/natSelectorImplPosix.cc | 127 --------------------------- libjava/gnu/java/nio/natSelectorImplWin32.cc | 93 -------------------- libjava/gnu/java/nio/natVMPipeEcos.cc | 27 ++++++ libjava/gnu/java/nio/natVMPipePosix.cc | 41 +++++++++ libjava/gnu/java/nio/natVMPipeWin32.cc | 40 +++++++++ libjava/gnu/java/nio/natVMSelectorEcos.cc | 25 ++++++ libjava/gnu/java/nio/natVMSelectorPosix.cc | 127 +++++++++++++++++++++++++++ libjava/gnu/java/nio/natVMSelectorWin32.cc | 93 ++++++++++++++++++++ 12 files changed, 353 insertions(+), 353 deletions(-) delete mode 100644 libjava/gnu/java/nio/natPipeImplEcos.cc delete mode 100644 libjava/gnu/java/nio/natPipeImplPosix.cc delete mode 100644 libjava/gnu/java/nio/natPipeImplWin32.cc delete mode 100644 libjava/gnu/java/nio/natSelectorImplEcos.cc delete mode 100644 libjava/gnu/java/nio/natSelectorImplPosix.cc delete mode 100644 libjava/gnu/java/nio/natSelectorImplWin32.cc create mode 100644 libjava/gnu/java/nio/natVMPipeEcos.cc create mode 100644 libjava/gnu/java/nio/natVMPipePosix.cc create mode 100644 libjava/gnu/java/nio/natVMPipeWin32.cc create mode 100644 libjava/gnu/java/nio/natVMSelectorEcos.cc create mode 100644 libjava/gnu/java/nio/natVMSelectorPosix.cc create mode 100644 libjava/gnu/java/nio/natVMSelectorWin32.cc (limited to 'libjava/gnu/java') diff --git a/libjava/gnu/java/nio/natPipeImplEcos.cc b/libjava/gnu/java/nio/natPipeImplEcos.cc deleted file mode 100644 index 75af4eb..0000000 --- a/libjava/gnu/java/nio/natPipeImplEcos.cc +++ /dev/null @@ -1,27 +0,0 @@ -// natPipeImplEcos.cc - -/* Copyright (C) 2003, 2004 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 -#include - -#include -#include -#include - -#include -#include -#include - -void -gnu::java::nio::VMPipe::init (gnu::java::nio::PipeImpl *self, - ::java::nio::channels::spi::SelectorProvider*) -{ - throw new ::java::io::IOException (JvNewStringUTF ("nativeInit() not implemented")); -} diff --git a/libjava/gnu/java/nio/natPipeImplPosix.cc b/libjava/gnu/java/nio/natPipeImplPosix.cc deleted file mode 100644 index 1726dc7..0000000 --- a/libjava/gnu/java/nio/natPipeImplPosix.cc +++ /dev/null @@ -1,41 +0,0 @@ -// natPipeImplPosix.cc - -/* Copyright (C) 2003, 2004 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 -#include - -#include -#include -#include - -#include -#include -//#include -//#include -#include -#include - -void -gnu::java::nio::VMPipe::init (gnu::java::nio::PipeImpl*, /*self*/ - ::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]); - */ -} diff --git a/libjava/gnu/java/nio/natPipeImplWin32.cc b/libjava/gnu/java/nio/natPipeImplWin32.cc deleted file mode 100644 index 2f14b50..0000000 --- a/libjava/gnu/java/nio/natPipeImplWin32.cc +++ /dev/null @@ -1,40 +0,0 @@ -// natPipeImplWin32.cc - -/* Copyright (C) 2003, 2004 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 -#include - -#include -#include -#include - -#include -#include -//#include -//#include -#include -#include - -void -gnu::java::nio::VMPipe::init (gnu::java::nio::PipeImpl *self, - ::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]); - */ -} diff --git a/libjava/gnu/java/nio/natSelectorImplEcos.cc b/libjava/gnu/java/nio/natSelectorImplEcos.cc deleted file mode 100644 index 15fbafd..0000000 --- a/libjava/gnu/java/nio/natSelectorImplEcos.cc +++ /dev/null @@ -1,25 +0,0 @@ -// natSelectorImplEcos.cc - -/* Copyright (C) 2003, 2004 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 -#include - -#include -#include - -#include -#include - -jint -gnu::java::nio::VMSelector::select (jintArray read, jintArray write, - jintArray except, jlong timeout) -{ - throw new ::java::io::IOException (JvNewStringUTF ("implSelect() not implemented")); -} diff --git a/libjava/gnu/java/nio/natSelectorImplPosix.cc b/libjava/gnu/java/nio/natSelectorImplPosix.cc deleted file mode 100644 index b433900..0000000 --- a/libjava/gnu/java/nio/natSelectorImplPosix.cc +++ /dev/null @@ -1,127 +0,0 @@ -// natSelectorImplPosix.cc - -/* Copyright (C) 2002, 2003, 2004 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 -#include - -#include -#include - -#include -#include -#include -#include - -static void -helper_put_filedescriptors (jintArray fdArray, fd_set& fds, int& max_fd) -{ - jint* tmpFDArray = elements (fdArray); - - for (int index = 0; index < JvGetArrayLength (fdArray); index++) - { - int fd = tmpFDArray [index]; - if (fd > 0) - { - FD_SET (tmpFDArray [index], &fds); - - if (tmpFDArray [index] > max_fd) - max_fd = tmpFDArray [index]; - } - } -} - -static void -helper_get_filedescriptors (jintArray& fdArray, fd_set fds) -{ - jint* tmpFDArray = elements (fdArray); - - for (int index = 0; index < JvGetArrayLength (fdArray); index++) - { - int fd = tmpFDArray [index]; - if (fd < 0 || !FD_ISSET (fd, &fds)) - tmpFDArray [index] = 0; - } -} - -static void -helper_reset (jintArray& fdArray) -{ - jint* tmpFDArray = elements (fdArray); - - for (int index = 0; index < JvGetArrayLength (fdArray); index++) - tmpFDArray [index] = 0; -} - -jint -gnu::java::nio::VMSelector::select (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; - - // If a legal timeout value isn't given, use NULL. - // This means an infinite timeout. The specification - // also says that a zero timeout should be treated - // as infinite. Otherwise (if the timeout value is legal), - // fill our timeval struct and use it for the select. - if (timeout > 0) - { - real_time_data.tv_sec = timeout / 1000; - real_time_data.tv_usec = (timeout % 1000) * 1000; - 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 - try - { - result = _Jv_select (max_fd + 1, &read_fds, &write_fds, - &except_fds, time_data); - } - catch (::java::io::InterruptedIOException *e) - { - // The behavior of JRE 1.4.1 is that no exception is thrown - // when the thread is interrupted, but the thread's interrupt - // status is set. Clear all of our select sets and return 0, - // indicating that nothing was selected. - ::java::lang::Thread::currentThread ()->interrupt (); - helper_reset (read); - helper_reset (write); - helper_reset (except); - return 0; - } - - 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; -} diff --git a/libjava/gnu/java/nio/natSelectorImplWin32.cc b/libjava/gnu/java/nio/natSelectorImplWin32.cc deleted file mode 100644 index 860f654..0000000 --- a/libjava/gnu/java/nio/natSelectorImplWin32.cc +++ /dev/null @@ -1,93 +0,0 @@ -// natSelectorImplWin32.cc - -/* Copyright (C) 2003, 2004 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 -#include - -#include -#include - -jint -gnu::java::nio::VMSelector::select (jintArray read, jintArray write, - jintArray except, jlong timeout) -{ - // FIXME: The API for implSelect is biased towards POSIX implementations. - jint* pReadFD = elements (read); - int nNbReadFDs = JvGetArrayLength (read); - - jint* pWriteFD = elements (write); - int nNbWriteFDs = JvGetArrayLength (write); - - int nNbEvents = nNbReadFDs + nNbWriteFDs; - - // Create and initialize our event wrapper array - - // FIXME: We're creating fresh WSAEVENTs for each call. - // This is inefficient. It would probably be better to cache these - // in the Win32 socket implementation class. - WSAEventWrapper aArray[nNbEvents]; - - int nCurIndex = 0; - for (int i=0; i < nNbReadFDs; ++i) - aArray[nCurIndex++].init(pReadFD[i], FD_ACCEPT | FD_READ); - - for (int i=0; i < nNbWriteFDs; ++i) - aArray[nCurIndex++].init(pWriteFD[i], FD_WRITE); - - // Build our array of WSAEVENTs to wait on. Also throw in our thread's - // interrupt event in order to detect thread interruption. - HANDLE arh[nNbEvents + 1]; - for (int i=0; i < nNbEvents; ++i) - arh[i] = aArray[i].getEventHandle(); - arh[nNbEvents] = _Jv_Win32GetInterruptEvent (); - - // A timeout value of 0 needs to be treated as infinite. - if (timeout <= 0) - timeout = WSA_INFINITE; - - // Do the select. - DWORD dwRet = WSAWaitForMultipleEvents (nNbEvents+1, arh, 0, timeout, false); - - if (dwRet == WSA_WAIT_FAILED) - _Jv_ThrowIOException (); - - // Before we do anything else, clear output file descriptor arrays. - memset(pReadFD, 0, sizeof(jint) * nNbReadFDs); - memset(pWriteFD, 0, sizeof(jint) * nNbWriteFDs); - memset(elements (except), 0, sizeof(jint) * JvGetArrayLength (except)); - - if (dwRet == DWORD(WSA_WAIT_EVENT_0 + nNbEvents)) - { - // We were interrupted. Set the current thread's interrupt - // status and get out of here, with nothing selected.. - ::java::lang::Thread::currentThread ()->interrupt (); - return 0; - } - else if (dwRet < DWORD(WSA_WAIT_EVENT_0 + nNbEvents)) - { - int nSelectedEventIndex = dwRet - WSA_WAIT_EVENT_0; - - // Record the selected file descriptor. - // FIXME: This implementation only allows one file descriptor - // to be selected at a time. Remedy this by looping on - // WSAWaitForMultipleEvents 'til nothing more is selected. - jint fd = aArray[nSelectedEventIndex].getFD(); - if (nSelectedEventIndex < nNbReadFDs) - pReadFD[0] = fd; - else - pWriteFD[0] = fd; - - return 1; - } - else - // None of the event objects was signalled, so nothing was - // selected. - return 0; -} diff --git a/libjava/gnu/java/nio/natVMPipeEcos.cc b/libjava/gnu/java/nio/natVMPipeEcos.cc new file mode 100644 index 0000000..c806fb4 --- /dev/null +++ b/libjava/gnu/java/nio/natVMPipeEcos.cc @@ -0,0 +1,27 @@ +// natVMPipeImplEcos.cc + +/* Copyright (C) 2003, 2004, 2007 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 +#include + +#include +#include +#include + +#include +#include +#include + +void +gnu::java::nio::VMPipe::init (gnu::java::nio::PipeImpl *self, + ::java::nio::channels::spi::SelectorProvider*) +{ + throw new ::java::io::IOException (JvNewStringUTF ("nativeInit() not implemented")); +} diff --git a/libjava/gnu/java/nio/natVMPipePosix.cc b/libjava/gnu/java/nio/natVMPipePosix.cc new file mode 100644 index 0000000..3de136a --- /dev/null +++ b/libjava/gnu/java/nio/natVMPipePosix.cc @@ -0,0 +1,41 @@ +// natVMPipeImplPosix.cc + +/* Copyright (C) 2003, 2004, 2007 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 +#include + +#include +#include +#include + +#include +#include +//#include +//#include +#include +#include + +void +gnu::java::nio::VMPipe::init (gnu::java::nio::PipeImpl*, /*self*/ + ::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]); + */ +} diff --git a/libjava/gnu/java/nio/natVMPipeWin32.cc b/libjava/gnu/java/nio/natVMPipeWin32.cc new file mode 100644 index 0000000..5278c7a --- /dev/null +++ b/libjava/gnu/java/nio/natVMPipeWin32.cc @@ -0,0 +1,40 @@ +// natVMPipeImplWin32.cc + +/* Copyright (C) 2003, 2004, 2007 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 +#include + +#include +#include +#include + +#include +#include +//#include +//#include +#include +#include + +void +gnu::java::nio::VMPipe::init (gnu::java::nio::PipeImpl *self, + ::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]); + */ +} diff --git a/libjava/gnu/java/nio/natVMSelectorEcos.cc b/libjava/gnu/java/nio/natVMSelectorEcos.cc new file mode 100644 index 0000000..f2ebff8 --- /dev/null +++ b/libjava/gnu/java/nio/natVMSelectorEcos.cc @@ -0,0 +1,25 @@ +// natVMSelectorImplEcos.cc + +/* Copyright (C) 2003, 2004, 2007 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 +#include + +#include +#include + +#include +#include + +jint +gnu::java::nio::VMSelector::select (jintArray read, jintArray write, + jintArray except, jlong timeout) +{ + throw new ::java::io::IOException (JvNewStringUTF ("implSelect() not implemented")); +} diff --git a/libjava/gnu/java/nio/natVMSelectorPosix.cc b/libjava/gnu/java/nio/natVMSelectorPosix.cc new file mode 100644 index 0000000..9f02679 --- /dev/null +++ b/libjava/gnu/java/nio/natVMSelectorPosix.cc @@ -0,0 +1,127 @@ +// natVMSelectorImplPosix.cc + +/* Copyright (C) 2002, 2003, 2004, 2007 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 +#include + +#include +#include + +#include +#include +#include +#include + +static void +helper_put_filedescriptors (jintArray fdArray, fd_set& fds, int& max_fd) +{ + jint* tmpFDArray = elements (fdArray); + + for (int index = 0; index < JvGetArrayLength (fdArray); index++) + { + int fd = tmpFDArray [index]; + if (fd > 0) + { + FD_SET (tmpFDArray [index], &fds); + + if (tmpFDArray [index] > max_fd) + max_fd = tmpFDArray [index]; + } + } +} + +static void +helper_get_filedescriptors (jintArray& fdArray, fd_set fds) +{ + jint* tmpFDArray = elements (fdArray); + + for (int index = 0; index < JvGetArrayLength (fdArray); index++) + { + int fd = tmpFDArray [index]; + if (fd < 0 || !FD_ISSET (fd, &fds)) + tmpFDArray [index] = 0; + } +} + +static void +helper_reset (jintArray& fdArray) +{ + jint* tmpFDArray = elements (fdArray); + + for (int index = 0; index < JvGetArrayLength (fdArray); index++) + tmpFDArray [index] = 0; +} + +jint +gnu::java::nio::VMSelector::select (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; + + // If a legal timeout value isn't given, use NULL. + // This means an infinite timeout. The specification + // also says that a zero timeout should be treated + // as infinite. Otherwise (if the timeout value is legal), + // fill our timeval struct and use it for the select. + if (timeout > 0) + { + real_time_data.tv_sec = timeout / 1000; + real_time_data.tv_usec = (timeout % 1000) * 1000; + 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 + try + { + result = _Jv_select (max_fd + 1, &read_fds, &write_fds, + &except_fds, time_data); + } + catch (::java::io::InterruptedIOException *e) + { + // The behavior of JRE 1.4.1 is that no exception is thrown + // when the thread is interrupted, but the thread's interrupt + // status is set. Clear all of our select sets and return 0, + // indicating that nothing was selected. + ::java::lang::Thread::currentThread ()->interrupt (); + helper_reset (read); + helper_reset (write); + helper_reset (except); + return 0; + } + + 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; +} diff --git a/libjava/gnu/java/nio/natVMSelectorWin32.cc b/libjava/gnu/java/nio/natVMSelectorWin32.cc new file mode 100644 index 0000000..790de22 --- /dev/null +++ b/libjava/gnu/java/nio/natVMSelectorWin32.cc @@ -0,0 +1,93 @@ +// natVMSelectorImplWin32.cc + +/* Copyright (C) 2003, 2004, 2007 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 +#include + +#include +#include + +jint +gnu::java::nio::VMSelector::select (jintArray read, jintArray write, + jintArray except, jlong timeout) +{ + // FIXME: The API for implSelect is biased towards POSIX implementations. + jint* pReadFD = elements (read); + int nNbReadFDs = JvGetArrayLength (read); + + jint* pWriteFD = elements (write); + int nNbWriteFDs = JvGetArrayLength (write); + + int nNbEvents = nNbReadFDs + nNbWriteFDs; + + // Create and initialize our event wrapper array + + // FIXME: We're creating fresh WSAEVENTs for each call. + // This is inefficient. It would probably be better to cache these + // in the Win32 socket implementation class. + WSAEventWrapper aArray[nNbEvents]; + + int nCurIndex = 0; + for (int i=0; i < nNbReadFDs; ++i) + aArray[nCurIndex++].init(pReadFD[i], FD_ACCEPT | FD_READ); + + for (int i=0; i < nNbWriteFDs; ++i) + aArray[nCurIndex++].init(pWriteFD[i], FD_WRITE); + + // Build our array of WSAEVENTs to wait on. Also throw in our thread's + // interrupt event in order to detect thread interruption. + HANDLE arh[nNbEvents + 1]; + for (int i=0; i < nNbEvents; ++i) + arh[i] = aArray[i].getEventHandle(); + arh[nNbEvents] = _Jv_Win32GetInterruptEvent (); + + // A timeout value of 0 needs to be treated as infinite. + if (timeout <= 0) + timeout = WSA_INFINITE; + + // Do the select. + DWORD dwRet = WSAWaitForMultipleEvents (nNbEvents+1, arh, 0, timeout, false); + + if (dwRet == WSA_WAIT_FAILED) + _Jv_ThrowIOException (); + + // Before we do anything else, clear output file descriptor arrays. + memset(pReadFD, 0, sizeof(jint) * nNbReadFDs); + memset(pWriteFD, 0, sizeof(jint) * nNbWriteFDs); + memset(elements (except), 0, sizeof(jint) * JvGetArrayLength (except)); + + if (dwRet == DWORD(WSA_WAIT_EVENT_0 + nNbEvents)) + { + // We were interrupted. Set the current thread's interrupt + // status and get out of here, with nothing selected.. + ::java::lang::Thread::currentThread ()->interrupt (); + return 0; + } + else if (dwRet < DWORD(WSA_WAIT_EVENT_0 + nNbEvents)) + { + int nSelectedEventIndex = dwRet - WSA_WAIT_EVENT_0; + + // Record the selected file descriptor. + // FIXME: This implementation only allows one file descriptor + // to be selected at a time. Remedy this by looping on + // WSAWaitForMultipleEvents 'til nothing more is selected. + jint fd = aArray[nSelectedEventIndex].getFD(); + if (nSelectedEventIndex < nNbReadFDs) + pReadFD[0] = fd; + else + pWriteFD[0] = fd; + + return 1; + } + else + // None of the event objects was signalled, so nothing was + // selected. + return 0; +} -- cgit v1.1