java_lang_VMSystem.c references 'extern char **environ,' which isn't
defined on Darwin. java_lang_VMProcess.c has a little #if that defines
this to a special function (_NSGetEnviron) for Darwin; the attached
patch does the same for VMSystem.
Does this look OK? I haven't tested this yet (I'm not entirely sure how
to do so; I've heard that jamvm can run this branch, so I'm going to
try that).
------------------------------------------------------------------------
Index: native/jni/java-lang/java_lang_VMSystem.c
===================================================================
RCS file:
/cvsroot/classpath/classpath/native/jni/java-lang/java_lang_VMSystem.c,v
retrieving revision 1.6.2.6
diff -u -b -B -r1.6.2.6 java_lang_VMSystem.c
--- native/jni/java-lang/java_lang_VMSystem.c 2 Aug 2005 20:12:40 -0000
1.6.2.6
+++ native/jni/java-lang/java_lang_VMSystem.c 5 Dec 2005 05:52:44 -0000
@@ -42,6 +42,15 @@
#include <sys/time.h>
#include <stdlib.h>
+/* Some O/S's don't declare 'environ' */
+#if HAVE_CRT_EXTERNS_H
+/* Darwin does not have a variable named environ
+ but has a function which you can get the environ
+ variable with. */
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#endif /* HAVE_CRT_EXTERNS_H */
+
/*
* Class: java_lang_VMSystem
* Method: setIn0
@@ -159,7 +168,9 @@
Java_java_lang_VMSystem_environ (JNIEnv *env,
jclass klass __attribute__((__unused__)))
{
+#if !HAVE_CRT_EXTERNS_H
extern char** environ;
+#endif /* HAVE_CRT_EXTERNS_H */
char **env_pointer;
jobject variables;
jclass list_class;