OSDN Git Service

Add PR markers to:
[pf3gnuchains/gcc-fork.git] / libjava / posix.cc
index ebff1c9..73c0f5f 100644 (file)
@@ -15,6 +15,7 @@ details.  */
 #include <stdlib.h>
 #include <errno.h>
 #include <signal.h>
+#include <stdio.h>
 
 #include <jvm.h>
 #include <java/lang/Thread.h>
@@ -25,6 +26,23 @@ details.  */
 extern "C" unsigned long long _clock (void);
 #endif
 
+#if defined(HAVE_PROC_SELF_EXE)
+static char exec_name[20];
+  // initialized in _Jv_platform_initialize()
+#endif
+
+const char *_Jv_ThisExecutable (void)
+{
+#if defined(DISABLE_MAIN_ARGS)
+  return "[Embedded App]";
+#elif defined(HAVE_PROC_SELF_EXE)
+  return exec_name;
+    // initialized in _Jv_platform_initialize()
+#else
+  return _Jv_GetSafeArg (0);
+#endif
+}
+
 // gettimeofday implementation.
 jlong
 _Jv_platform_gettimeofday ()
@@ -62,6 +80,11 @@ _Jv_platform_initialize (void)
 #else
   signal (SIGPIPE, SIG_IGN);
 #endif
+
+#if defined (HAVE_PROC_SELF_EXE)
+  // Compute our executable name
+  sprintf (exec_name, "/proc/%d/exe", getpid ());
+#endif
 }
 
 // Set platform-specific System properties.