This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Design Questions for MingW libjava 3.4 Refactoring
- From: Mohan Embar <gnustuff at thisiscool dot com>
- To: GCJ Java <java at gcc dot gnu dot org>
- Date: Thu, 26 Jun 2003 19:09:25 -0500
- Subject: Design Questions for MingW libjava 3.4 Refactoring
- Reply-to: gnustuff at thisiscool dot com
Hi Michael + Everyone,
I have a design question related to the
cleanup / refactoring / enhancements I'm
making to MingW libjava 3.4, particularly after
the Posix <-> Win32 networking code fork.
Currently, in platform.h (win32.h or posix.h),
there are a number of _Jv methods pertaining
to socket functions. I have eliminated these
in both win32.h as well as nat*Socket*ImplWin32.h
because I believe that the rationale was that
networking code should be split and not
conditionalized. Things seem to work except
for _Jv_select(), used by gnu/java/nio/natSelectorImpl.cc:
---------------------------8<----------------------------
jint
gnu::java::nio::SelectorImpl::java_do_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;
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;
}
---------------------------8<----------------------------
Two questions:
- Does my reasoning behind removing the socket-related _Jv methods
in platform.h seem well-founded?
- Assuming the answer to the previous question is "yes", do we
fork the above code too, which could easily be reused if
we provided _Jv_select()? Wait a minute, if (result < 0),
then we use errno / strerror() instead of the Win32 equivalents
of WSAGetLastError() / FormatMessage(), so I think I just answered
my own question.
Your thoughts?
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/