This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch for Preview: Some GCJ 3.3/MingW Fixes
- From: Mohan Embar <gnustuff at thisiscool dot com>
- To: aph at redhat dot com
- Cc: GCJ Patches <java-patches at gcc dot gnu dot org>, rmathew at hotmail dot com
- Date: Tue, 15 Apr 2003 15:24:40 -0500
- Subject: Patch for Preview: Some GCJ 3.3/MingW Fixes
- Reply-to: gnustuff at thisiscool dot com
Hi Andrew,
Here is what I promised you as per the closing paragraph
in this thread:
http://gcc.gnu.org/ml/java/2003-04/msg00213.html
I've also incorporated the elements(data) piece and
updated the comment to explain the rationale behind
casting to char*.
Despite the cumulative nature of this patch, I'd
like to point out that:
- I have a slight moral problem implementing a dummy
_Jv_select() which blows up whereas I have a perfectly
decent _Jv_select() implementation (lifted from posix.cc),
but which hangs because I think the wrong file descriptor
is passed to it (cf. http://gcc.gnu.org/ml/java/2003-04/msg00185.html)
- I think the GC_DLL patch should go in too. As I mentioned
before, even Hans is okay with this:
http://gcc.gnu.org/ml/java-patches/2003-q1/msg00669.html
- None of this is complete because currently, the
compiler is missing a library in its specs file
and therefore can't even build fastjar, for example.
You know what? I'm going to just submit that patch
first and see if anyone screams. Here is the reference:
http://gcc.gnu.org/ml/gcc-patches/2003-04/msg01166.html
- This is also not the complete picture because the cross-compilation
stuff does not work without the cross-configury patch I'm about to submit.
Nevertheless, this patch does unbreak the libjava compilation.
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/
ChangeLog
2003-04-15 Mohan Embar <gnustuff at thisiscool dot com>
* include/win32.h: added dummy ECONNREFUSED define and
_Jv_select() declaration
* win32.cc (_Jv_select): placeholder implementation
(_Jv_platform_initProperties): Fix by Ranjit
Mathew (rmathew at hotmail dot com): use generic names
like "x86" for the "os.arch" property to be consistent with
what Sun's JDK produces. Use the wProcessorArchitecture
member of the Win32 SYSTEM_INFO structure, filled in a call
to GetSystemInfo( ), instead of dwProcessorType
* gnu/java/nio/natSocketChannelImpl.cc (SocketRead): use
elements(data) and explicitly cast to char* on platforms
where jbyte is not signed char
(SocketWrite): idem
Index: include/win32.h
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/include/win32.h,v
retrieving revision 1.16.2.4
diff -u -2 -r1.16.2.4 win32.h
--- include/win32.h 13 Feb 2003 00:07:57 -0000 1.16.2.4
+++ include/win32.h 15 Apr 2003 19:51:42 -0000
@@ -31,4 +31,9 @@
#define ECONNRESET 0
+/* This is incorrect, but allows java/net/natPlainDatagramSocketImpl.cc
+ to compile under MingW. This will be remedied in a subsequent gcj
+ release where the Win32 and Posix networking code have been forked. */
+#define ECONNREFUSED 0
+
#ifndef ENOPROTOOPT
#define ENOPROTOOPT 109
@@ -40,4 +45,5 @@
extern void _Jv_platform_initProperties (java::util::Properties*);
extern jlong _Jv_platform_gettimeofday ();
+extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *);
inline void
Index: win32.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/win32.cc,v
retrieving revision 1.12.22.3
diff -u -2 -r1.12.22.3 win32.cc
--- win32.cc 10 Mar 2003 19:34:30 -0000 1.12.22.3
+++ win32.cc 15 Apr 2003 19:51:39 -0000
@@ -16,4 +16,5 @@
#include <java/lang/ArithmeticException.h>
+#include <java/lang/UnsupportedOperationException.h>
#include <java/util/Properties.h>
@@ -47,8 +48,8 @@
MessageBox (NULL, "Error initialising winsock library.", "Error",
MB_OK | MB_ICONEXCLAMATION);
-
+
// Install exception handler
SetUnhandledExceptionFilter (win32_exception_handler);
-
+
// Initialize our executable name
GetModuleFileName(NULL, exec_name, sizeof(exec_name));
@@ -104,5 +105,5 @@
_Jv_Free (buffer);
}
-
+
// Use GetUserName to set 'user.name'.
buflen = 257; // UNLEN + 1
@@ -115,6 +116,6 @@
}
- // According to the api documentation for 'GetWindowsDirectory()', the
- // environmental variable HOMEPATH always specifies the user's home
+ // According to the api documentation for 'GetWindowsDirectory()', the
+ // environmental variable HOMEPATH always specifies the user's home
// directory or a default directory. On the 3 windows machines I checked
// only 1 had it set. If it's not set, JDK1.3.1 seems to set it to
@@ -131,5 +132,5 @@
{
if (GetWindowsDirectory (winHome, MAX_PATH))
- SET ("user.home", winHome);
+ SET ("user.home", winHome);
_Jv_Free (winHome);
}
@@ -149,5 +150,5 @@
{
sprintf (buffer, "%d.%d", (int) osvi.dwMajorVersion,
- (int) osvi.dwMinorVersion);
+ (int) osvi.dwMinorVersion);
SET ("os.version", buffer);
_Jv_Free (buffer);
@@ -164,5 +165,5 @@
SET ("os.name", "Windows Me");
else
- SET ("os.name", "Windows ??");
+ SET ("os.name", "Windows ??");
break;
@@ -187,21 +188,22 @@
SYSTEM_INFO si;
GetSystemInfo (&si);
- switch (si.dwProcessorType)
+ switch (si.wProcessorArchitecture)
{
- case PROCESSOR_INTEL_386:
- SET ("os.arch", "i386");
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ SET ("os.arch", "x86");
break;
- case PROCESSOR_INTEL_486:
- SET ("os.arch", "i486");
+ case PROCESSOR_ARCHITECTURE_MIPS:
+ SET ("os.arch", "mips");
break;
- case PROCESSOR_INTEL_PENTIUM:
- SET ("os.arch", "i586");
+ case PROCESSOR_ARCHITECTURE_ALPHA:
+ SET ("os.arch", "alpha");
break;
- case PROCESSOR_MIPS_R4000:
- SET ("os.arch", "MIPS4000");
+ case PROCESSOR_ARCHITECTURE_PPC:
+ SET ("os.arch", "ppc");
break;
- case PROCESSOR_ALPHA_21064:
- SET ("os.arch", "ALPHA");
+ case PROCESSOR_ARCHITECTURE_IA64:
+ SET ("os.arch", "ia64");
break;
+ case PROCESSOR_ARCHITECTURE_UNKNOWN:
default:
SET ("os.arch", "unknown");
@@ -230,3 +232,11 @@
}
return i;
+}
+
+/* Placeholder implementation */
+int
+_Jv_select (int, fd_set *, fd_set *, fd_set *, struct timeval *)
+{
+ throw new java::lang::UnsupportedOperationException(JvNewStringUTF("_Jv_select() not implemented in Win32"));
+ return 0;
}
Index: gnu/java/nio/natSocketChannelImpl.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/gnu/java/nio/natSocketChannelImpl.cc,v
retrieving revision 1.1.12.2
diff -u -2 -r1.1.12.2 natSocketChannelImpl.cc
--- gnu/java/nio/natSocketChannelImpl.cc 1 Mar 2003 22:57:53 -0000 1.1.12.2
+++ gnu/java/nio/natSocketChannelImpl.cc 15 Apr 2003 19:51:41 -0000
@@ -144,5 +144,7 @@
jint offset, jint length)
{
- int result = ::recv (fd, data, offset, length);
+ /* The cast to char* is needed to placate the Win32 API */
+ int result =
+ ::recv (fd, reinterpret_cast<char*>(elements(data)), offset, length);
if (result < 0)
@@ -159,5 +161,9 @@
jint offset, jint length)
{
- int result = ::send (fd, data, offset, length);
+ /* The cast to char* is needed to placate the Win32 API. I used char*
+ instead of const char* because I wasn't sure about the API on all
+ UNICES */
+ int result =
+ ::send (fd, reinterpret_cast<char*>(elements(data)), offset, length);
if (result < 0)