classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] [generics] RFC: fix generics branch compilation on Darw


From: Archie Cobbs
Subject: Re: [cp-patches] [generics] RFC: fix generics branch compilation on Darwin
Date: Mon, 05 Dec 2005 08:57:50 -0600
User-agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.3) Gecko/20041129

Casey Marshall wrote:
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;

I think those patches should test different macros. Whether "eviron"
is declared is a separate question from whether crt_externs.h exists
or not.

I.e., the second patch should be #if !HAVE_DECL_ENVIRON or somesuch,
a corresponding new configure test added (example taken from JCVM):

  AC_CHECK_DECL(environ, [AC_DEFINE([HAVE_DECL_ENVIRON], [1],
    [environ explicitly declared somewhere])])

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]