src/solaris/bin/java_md_solinux.c

Print this page
rev 8822 : 8024854: PPC64: Basic changes and files to build the class library on AIX
Reviewed-by: alanb, prr, sla, chegar, michaelm, mullan, art
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com

@@ -39,11 +39,15 @@
 #include "version_comp.h"
 
 
 #define JVM_DLL "libjvm.so"
 #define JAVA_DLL "libjava.so"
+#ifdef AIX
+#define LD_LIBRARY_PATH "LIBPATH"
+#else
 #define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
+#endif
 
 /* help jettison the LD_LIBRARY_PATH settings in the future */
 #ifndef SETENV_REQUIRED
 #define SETENV_REQUIRED
 #endif

@@ -285,10 +289,15 @@
     char jpath[PATH_MAX + 1];
     char *llp;
     char *dmllp = NULL;
     char *p; /* a utility pointer */
 
+#ifdef AIX
+    /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
+    return JNI_TRUE;
+#endif
+
     llp = getenv("LD_LIBRARY_PATH");
 #ifdef __solaris__
     dmllp = (CURRENT_DATA_MODEL == 32)
             ? getenv("LD_LIBRARY_PATH_32")
             : getenv("LD_LIBRARY_PATH_64");

@@ -596,20 +605,24 @@
 #else /* ! __solaris__ */
             /*
              * If not on Solaris, assume only a single LD_LIBRARY_PATH
              * variable.
              */
-            runpath = getenv("LD_LIBRARY_PATH");
+            runpath = getenv(LD_LIBRARY_PATH);
 #endif /* __solaris__ */
 
             /* runpath contains current effective LD_LIBRARY_PATH setting */
 
             jvmpath = JLI_StringDup(jvmpath);
             new_runpath = JLI_MemAlloc(((runpath != NULL) ? JLI_StrLen(runpath) : 0) +
                     2 * JLI_StrLen(jrepath) + 2 * JLI_StrLen(arch) +
+#ifdef AIX
+                    /* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */
+                    JLI_StrLen(jrepath) + JLI_StrLen(arch) + JLI_StrLen("/lib//jli:") +
+#endif
                     JLI_StrLen(jvmpath) + 52);
-            newpath = new_runpath + JLI_StrLen("LD_LIBRARY_PATH=");
+            newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "=");
 
 
             /*
              * Create desired LD_LIBRARY_PATH value for target data model.
              */

@@ -617,20 +630,26 @@
                 /* remove the name of the .so from the JVM path */
                 lastslash = JLI_StrRChr(jvmpath, '/');
                 if (lastslash)
                     *lastslash = '\0';
 
-                sprintf(new_runpath, "LD_LIBRARY_PATH="
+                sprintf(new_runpath, LD_LIBRARY_PATH "="
                         "%s:"
                         "%s/lib/%s:"
+#ifdef AIX
+                        "%s/lib/%s/jli:" /* Needed on AIX because ld doesn't support $ORIGIN. */
+#endif
                         "%s/../lib/%s",
                         jvmpath,
 #ifdef DUAL_MODE
                         jrepath, GetArchPath(wanted),
                         jrepath, GetArchPath(wanted)
 #else /* !DUAL_MODE */
                         jrepath, arch,
+#ifdef AIX
+                        jrepath, arch,
+#endif
                         jrepath, arch
 #endif /* DUAL_MODE */
                         );
 
 

@@ -998,11 +1017,11 @@
  * Block current thread and continue execution in a new thread
  */
 int
 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
     int rslt;
-#ifdef __linux__
+#ifndef __solaris__
     pthread_t tid;
     pthread_attr_t attr;
     pthread_attr_init(&attr);
     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 

@@ -1023,22 +1042,22 @@
       */
       rslt = continuation(args);
     }
 
     pthread_attr_destroy(&attr);
-#else /* ! __linux__ */
+#else /* __solaris__ */
     thread_t tid;
     long flags = 0;
     if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
       void * tmp;
       thr_join(tid, NULL, &tmp);
       rslt = (int)tmp;
     } else {
       /* See above. Continue in current thread if thr_create() failed */
       rslt = continuation(args);
     }
-#endif /* __linux__ */
+#endif /* !__solaris__ */
     return rslt;
 }
 
 /* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */
 #define MAX_PID_STR_SZ   20