jvm.h: (_Jv_GetNbArgs) added (_Jv_GetSafeArg) added (_Jv_SetArgs) added

2003-03-29  Mohan Embar  <gnustuff@thisiscool.com>

        * include/jvm.h: (_Jv_GetNbArgs) added
        (_Jv_GetSafeArg) added
        (_Jv_SetArgs) added
        * prims.cc: (_Jv_GetNbArgs) implemented
        (_Jv_GetSafeArg) implemented
        (_Jv_SetArgs) implemented
        (_Jv_RunMain) use _Jv_SetArgs() instead of explicitly
        setting _Jv_argc and _Jv_argv
        * posix.cc: (_Jv_ThisExecutable) use _Jv_GetSafeArg()
        instead of _Jv_argv
        * java/lang/natRuntime.cc: (insertSystemProperties) use
        _Jv_GetSafeArg() instead of _Jv_argv

From-SVN: r66067
This commit is contained in:
Mohan Embar 2003-04-25 16:48:13 +00:00 committed by Andrew Haley
parent ad4a34f0b9
commit c4519773ca
5 changed files with 56 additions and 12 deletions

View File

@ -1,3 +1,18 @@
2003-03-29 Mohan Embar <gnustuff@thisiscool.com>
* include/jvm.h: (_Jv_GetNbArgs) added
(_Jv_GetSafeArg) added
(_Jv_SetArgs) added
* prims.cc: (_Jv_GetNbArgs) implemented
(_Jv_GetSafeArg) implemented
(_Jv_SetArgs) implemented
(_Jv_RunMain) use _Jv_SetArgs() instead of explicitly
setting _Jv_argc and _Jv_argv
* posix.cc: (_Jv_ThisExecutable) use _Jv_GetSafeArg()
instead of _Jv_argv
* java/lang/natRuntime.cc: (insertSystemProperties) use
_Jv_GetSafeArg() instead of _Jv_argv
2003-04-23 Tom Tromey <tromey@redhat.com>
* resolve.cc (_Jv_PrepareClass): Round size up to alignment

View File

@ -352,7 +352,20 @@ extern "C"
jlong _Jv_remJ (jlong, jlong);
}
/* Get the name of the running executable. */
/* Get the number of arguments (cf. argc) or 0 if our argument
list was never initialized. */
extern int _Jv_GetNbArgs (void);
/* Get the specified argument (cf. argv[index]) or "" if either
our argument list was never initialized or the specified index
is out of bounds. */
extern const char * _Jv_GetSafeArg (int index);
/* Sets our argument list. Can be used by programs with non-standard
entry points. */
extern void _Jv_SetArgs (int argc, const char **argv);
/* Get the name of the running executable. */
extern const char *_Jv_ThisExecutable (void);
/* Return a pointer to a symbol in executable or loaded library. */

View File

@ -108,10 +108,6 @@ _Jv_SetDLLSearchPath (const char *)
extern int _Jv_argc;
extern const char **_Jv_argv;
// our process' command line arguments
void
java::lang::Runtime::exitInternal (jint status)
{
@ -590,7 +586,7 @@ java::lang::Runtime::insertSystemProperties (java::util::Properties *newprops)
}
// The name used to invoke this process (argv[0] in C).
SET ("gnu.gcj.progname", _Jv_argv[0]);
SET ("gnu.gcj.progname", _Jv_GetSafeArg (0));
// Allow platform specific settings and overrides.
_Jv_platform_initProperties (newprops);

View File

@ -25,9 +25,6 @@ details. */
extern "C" unsigned long long _clock (void);
#endif
// platform-specific executable name
extern const char **_Jv_argv;
#if defined(HAVE_PROC_SELF_EXE)
static char exec_name[20];
// initialized in _Jv_platform_initialize()
@ -41,7 +38,7 @@ const char *_Jv_ThisExecutable (void)
return exec_name;
// initialized in _Jv_platform_initialize()
#else
return _Jv_argv[0];
return _Jv_GetSafeArg (0);
#endif
}

View File

@ -90,6 +90,30 @@ property_pair *_Jv_Environment_Properties;
const char **_Jv_argv;
int _Jv_argc;
// Argument support.
int
_Jv_GetNbArgs (void)
{
// _Jv_argc is 0 if not explicitly initialized.
return _Jv_argc;
}
const char *
_Jv_GetSafeArg (int index)
{
if (index >=0 && index < _Jv_GetNbArgs ())
return _Jv_argv[index];
else
return "";
}
void
_Jv_SetArgs (int argc, const char **argv)
{
_Jv_argc = argc;
_Jv_argv = argv;
}
#ifdef ENABLE_JVMPI
// Pointer to JVMPI notification functions.
void (*_Jv_JVMPI_Notify_OBJECT_ALLOC) (JVMPI_Event *event);
@ -936,8 +960,7 @@ void
_Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
bool is_jar)
{
_Jv_argv = argv;
_Jv_argc = argc;
_Jv_SetArgs (argc, argv);
java::lang::Runtime *runtime = NULL;