This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Compile errors in libgcj while building cross-compiler for MinGW


Ranjit Mathew wrote:
and w32api-2.0. I'm posting this to find out how Adam and the
other MinGW hackers, if any, have got around these issues and are
able to build a cross-compiler.
Am I the only one left here who plays with the mingw32 target?
Adam, where art thou?

:-(


Second, java/net/natPlainDatagramSockImpl.cc uses the ECONNREFUSED
errno code to check for refused connection. However, on Windows, not only is
this not defined, according to WinSock2 APIs the last error code can be
retrieved using WSAGetLastError( ) and not checking for errno - then again
it is WSAECONNREFUSED and not ECONNREFUSED.
More details on what I point out above can be found here:

http://msdn.microsoft.com/library/en-us/winsock/winsock/error_codes_errno_h_errno_and_wsagetlasterror_2.asp
http://msdn.microsoft.com/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp

The Windows Sockets functions sendto(), recv(), etc. return
SOCKET_ERROR if they fail, which (fortunately) is defined as "-1",
the same as that for BSD Sockets.

However, to check for the actual error code, you're supposed to
invoke WSAGetLastError( ) and not errno, and then again the
error constants are WSAECONNREFUSED, WSAENOTSOCK, etc. and
not ECONNREFUSED, ENOTSOCK, etc.

What I propose is the following:

1. We define an errno alias for networking code, say "sockerrno"
   and use it consistently in networking code that uses the Sockets
   API.

2. "posix.h" merely says "#define sockerrno errno"

3. "win32.h" says "#define sockerrno WSAGetLastError( )"

4. "win32.h" additionally says "#define ECONNREFUSED WSAECONNREFUSED",
   etc.

NOTE: This makes "sockerrno" an rvalue (a non-lvalue), because
to set it, on Windows you must call WSASetLastError( ).

How does this look? The existing code would be impacted minimally,
I feel, by this change.

If it looks all right, I can post a patch for the same.

Lastly, I guess this should have gone to the Classpath list as
well, especially Michael Koch, but I didn't copy it to
that list as I think there's a lot of overlapping subscriptions
between the lists. If you think I'm wrong, I'll also forward
it to at least Michael.

Sincerely Yours,
Ranjit.

--
Ranjit Mathew          Email: rmathew AT hotmail DOT com

Bangalore, INDIA.      Web: http://ranjitmathew.tripod.com/




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]