This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [PATCH]: adds missing System properties for gcj under mingw
>>>>> "Adam" == Adam King <aking@dreammechanics.com> writes:
Adam> I believe the correct patch is:
Adam> 2002-04-11 Adam King <aking@dreammechanics.com>
Adam> * win32.cc (_Jv_platform_initProperties): Fix the way
Adam> GetTempPath() is used.
Thanks. I had just pulled out (and literally dusted off) my Windows
book to fix this when I saw your message.
I'm going to apply a variant of your patch. I'm fixing a couple other
minor things in that method as well.
I've appended what I'm checking in.
Tom
? include/stamp-h1.in
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.1197.2.89
diff -u -r1.1197.2.89 ChangeLog
--- ChangeLog 10 Apr 2002 13:09:59 -0000 1.1197.2.89
+++ ChangeLog 11 Apr 2002 15:54:38 -0000
@@ -1,3 +1,12 @@
+2002-04-11 Adam King <aking@dreammechanics.com>
+ Tom Tromey <tromey@redhat.com>
+
+ * include/jvm.h (_Jv_ThrowBadArrayIndex,
+ _Jv_ThrowNullPointerException): Mark as noreturn.
+ * win32.cc (_Jv_platform_initProperties): Use _Jv_MallocUnchecked
+ and _Jv_free. Correctly invoke GetTempPath(). Indentation
+ fixes.
+
2002-04-09 Anthony Green <green@redhat.com>
* Makefile.am (jardir, jar_DATA): Define (for libgcj.jar).
Index: win32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/win32.cc,v
retrieving revision 1.4.8.5
diff -u -r1.4.8.5 win32.cc
--- win32.cc 9 Apr 2002 17:46:05 -0000 1.4.8.5
+++ win32.cc 11 Apr 2002 15:54:38 -0000
@@ -76,26 +76,29 @@
SET ("file.separator", "\\");
SET ("path.separator", ";");
SET ("line.separator", "\r\n");
- SET ("java.io.tmpdir", GetTempPath ());
// Use GetCurrentDirectory to set 'user.dir'.
DWORD buflen = MAX_PATH;
- char* buffer = (char *) malloc (buflen);
+ char *buffer = (char *) _Jv_MallocUnchecked (buflen);
if (buffer != NULL)
{
if (GetCurrentDirectory (buflen, buffer))
- SET ("user.dir", buffer);
- free (buffer);
+ SET ("user.dir", buffer);
+
+ if (GetTempPath (buflen, buffer))
+ SET ("java.io.tmpdir", buffer);
+
+ _Jv_free (buffer);
}
// Use GetUserName to set 'user.name'.
buflen = 257; // UNLEN + 1
- buffer = (char *) malloc (buflen);
+ buffer = (char *) _Jv_MallocUnchecked (buflen);
if (buffer != NULL)
{
if (GetUserName (buffer, &buflen))
SET ("user.name", buffer);
- free (buffer);
+ _Jv_free (buffer);
}
// According to the api documentation for 'GetWindowsDirectory()', the
@@ -103,23 +106,23 @@
// 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
// the windows directory, so we'll do the same.
- char* userHome = NULL;
- if ((userHome = ::getenv( "HOMEPATH" )) == NULL )
+ char *userHome = NULL;
+ if ((userHome = ::getenv ("HOMEPATH")) == NULL )
{
// Check HOME since it's what I use.
- if ((userHome = ::getenv( "HOME" )) == NULL )
+ if ((userHome = ::getenv ("HOME")) == NULL )
{
// Not found - use the windows directory like JDK1.3.1 does.
- char* winHome = (char *)malloc (MAX_PATH);
- if ( winHome != NULL )
+ char *winHome = (char *) _Jv_MallocUnchecked (MAX_PATH);
+ if (winHome != NULL)
{
if (GetWindowsDirectory (winHome, MAX_PATH))
- SET ("user.home", winHome);
- free (winHome);
+ SET ("user.home", winHome);
+ _Jv_free (winHome);
}
}
}
- if( userHome != NULL )
+ if (userHome != NULL)
SET ("user.home", userHome);
// Get and set some OS info.
@@ -128,12 +131,13 @@
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx (&osvi))
{
- char *buffer = (char *) malloc (30);
+ char *buffer = (char *) _Jv_MallocUnchecked (30);
if (buffer != NULL)
{
- sprintf (buffer, "%d.%d", (int)osvi.dwMajorVersion, (int)osvi.dwMinorVersion);
+ sprintf (buffer, "%d.%d", (int) osvi.dwMajorVersion,
+ (int) osvi.dwMinorVersion);
SET ("os.version", buffer);
- free (buffer);
+ _Jv_free (buffer);
}
switch (osvi.dwPlatformId)
@@ -169,7 +173,7 @@
// Set the OS architecture.
SYSTEM_INFO si;
GetSystemInfo (&si);
- switch( si.dwProcessorType )
+ switch (si.dwProcessorType)
{
case PROCESSOR_INTEL_386:
SET ("os.arch", "i386");
@@ -191,4 +195,3 @@
break;
}
}
-
Index: include/jvm.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/jvm.h,v
retrieving revision 1.50
diff -u -r1.50 jvm.h
--- include/jvm.h 19 Dec 2001 01:59:28 -0000 1.50
+++ include/jvm.h 11 Apr 2002 15:54:38 -0000
@@ -1,6 +1,6 @@
// jvm.h - Header file for private implementation information. -*- c++ -*-
-/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation
This file is part of libgcj.
@@ -283,8 +283,10 @@
return elts;
}
-extern "C" void _Jv_ThrowBadArrayIndex (jint bad_index);
-extern "C" void _Jv_ThrowNullPointerException (void);
+extern "C" void _Jv_ThrowBadArrayIndex (jint bad_index)
+ __attribute__((noreturn));
+extern "C" void _Jv_ThrowNullPointerException (void)
+ __attribute__((noreturn));
extern "C" jobject _Jv_NewArray (jint type, jint size)
__attribute__((__malloc__));
extern "C" jobject _Jv_NewMultiArray (jclass klass, jint dims, ...)