$OpenBSD: patch-hotspot_src_os_bsd_launcher_java_md_c,v 1.2 2011/01/11 15:47:49 kurt Exp $
--- hotspot/src/os/bsd/launcher/java_md.c.orig	Mon Nov  1 13:14:58 2010
+++ hotspot/src/os/bsd/launcher/java_md.c	Mon Nov  1 13:16:15 2010
@@ -45,8 +45,15 @@
 #include "version_comp.h"
 #endif
 
+#ifdef __APPLE__
+#define JVM_DLL "libjvm.dylib"
+#define JAVA_DLL "libjava.dylib"
+#define LD_LIBRARY_PATH "DYLD_LIBRARY_PATH"
+#else
 #define JVM_DLL "libjvm.so"
 #define JAVA_DLL "libjava.so"
+#define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
+#endif
 
 #ifndef GAMMA   /* launcher.make defines ARCH */
 
@@ -116,7 +123,7 @@ extern char **environ;
  *      A collection of useful strings. One should think of these as #define
  *      entries, but actual strings can be more efficient (with many compilers).
  */
-#ifdef __bsd__
+#ifdef _ALLBSD_SOURCE
 static const char *system_dir   = "/usr/java";
 static const char *user_dir     = "/java";
 #else /* Solaris */
@@ -460,10 +467,10 @@ CreateExecutionEnvironment(int *_argcp,
        * If not on Solaris, assume only a single LD_LIBRARY_PATH
        * variable.
        */
-      runpath = getenv("LD_LIBRARY_PATH");
+      runpath = getenv(LD_LIBRARY_PATH);
 #endif /* __sun */
 
-#ifdef __bsd
+#ifdef _ALLBSD_SOURCE
       /*
        * On bsd, if a binary is running as sgid or suid, glibc sets
        * LD_LIBRARY_PATH to the empty string for security purposes.  (In
@@ -476,7 +483,7 @@ CreateExecutionEnvironment(int *_argcp,
        * return from the function now.  Getting the right libraries to
        * be found must be handled through other mechanisms.
        */
-      if((getgid() != getegid()) || (getuid() != geteuid()) ) {
+      if(issetugid()) {
         return;
       }
 #endif
@@ -487,7 +494,7 @@ CreateExecutionEnvironment(int *_argcp,
       new_runpath = MemAlloc( ((runpath!=NULL)?strlen(runpath):0) +
                               2*strlen(jrepath) + 2*strlen(arch) +
                               strlen(jvmpath) + 52);
-      newpath = new_runpath + strlen("LD_LIBRARY_PATH=");
+      newpath = new_runpath + strlen(LD_LIBRARY_PATH "=");
 
 
       /*
@@ -502,7 +509,7 @@ CreateExecutionEnvironment(int *_argcp,
 
         /* jvmpath, ((running != wanted)?((wanted==64)?"/"BIG_ARCH:"/.."):""), */
 
-        sprintf(new_runpath, "LD_LIBRARY_PATH="
+        sprintf(new_runpath, LD_LIBRARY_PATH "="
                 "%s:"
                 "%s/lib/%s:"
                 "%s/../lib/%s",
@@ -840,7 +847,7 @@ GetXUsagePath(char *buf, jint bufsize)
 jboolean
 GetApplicationHome(char *buf, jint bufsize)
 {
-#ifdef __bsd__
+#ifdef _ALLBSD_SOURCE
     char *execname = GetExecname();
     if (execname) {
         strncpy(buf, execname, bufsize-1);
@@ -1009,7 +1016,7 @@ SetExecname(char **argv)
             }
         }
     }
-#elif defined(__bsd__)
+#elif defined(__linux__)
     {
         const char* self = "/proc/self/exe";
         char buf[PATH_MAX+1];
@@ -1019,7 +1026,7 @@ SetExecname(char **argv)
             exec_path = strdup(buf);
         }
     }
-#else /* !__sun && !__bsd */
+#else /* !__sun && !__linux */
     {
         /* Not implemented */
     }
@@ -1224,7 +1231,7 @@ get_cpuid(uint32_t arg,
 
 #endif /* __sun && i586 */
 
-#if defined(__bsd__) && defined(i586)
+#if defined(_ALLBSD_SOURCE) && defined(i586)
 
 /*
  * A utility method for asking the CPU about itself.
@@ -1290,7 +1297,7 @@ get_cpuid(uint32_t arg,
 #endif
 }
 
-#endif /* __bsd__ && i586 */
+#endif /* _ALLBSD_SOURCE && i586 */
 
 #ifdef i586
 /*
@@ -1469,7 +1476,7 @@ solaris_i586_ServerClassMachine(void) {
 
 #endif /* __sun && i586 */
 
-#if defined(__bsd__) && defined(i586)
+#if defined(_ALLBSD_SOURCE) && defined(i586)
 
 /* The definition of a server-class machine for bsd-i586 */
 jboolean
@@ -1500,7 +1507,7 @@ bsd_i586_ServerClassMachine(void) {
   return result;
 }
 
-#endif /* __bsd__ && i586 */
+#endif /* _ALLBSD_SOURCE && i586 */
 
 /* Dispatch to the platform-specific definition of "server-class" */
 jboolean
@@ -1510,7 +1517,7 @@ ServerClassMachine(void) {
   result = solaris_sparc_ServerClassMachine();
 #elif defined(__sun) && defined(i586)
   result = solaris_i586_ServerClassMachine();
-#elif defined(__bsd__) && defined(i586)
+#elif defined(_ALLBSD_SOURCE) && defined(i586)
   result = bsd_i586_ServerClassMachine();
 #else
   if (_launcher_debug) {
