equal
deleted
inserted
replaced
39 #include "version_comp.h" |
39 #include "version_comp.h" |
40 |
40 |
41 |
41 |
42 #define JVM_DLL "libjvm.so" |
42 #define JVM_DLL "libjvm.so" |
43 #define JAVA_DLL "libjava.so" |
43 #define JAVA_DLL "libjava.so" |
|
44 #ifdef AIX |
|
45 #define LD_LIBRARY_PATH "LIBPATH" |
|
46 #else |
44 #define LD_LIBRARY_PATH "LD_LIBRARY_PATH" |
47 #define LD_LIBRARY_PATH "LD_LIBRARY_PATH" |
|
48 #endif |
45 |
49 |
46 /* help jettison the LD_LIBRARY_PATH settings in the future */ |
50 /* help jettison the LD_LIBRARY_PATH settings in the future */ |
47 #ifndef SETENV_REQUIRED |
51 #ifndef SETENV_REQUIRED |
48 #define SETENV_REQUIRED |
52 #define SETENV_REQUIRED |
49 #endif |
53 #endif |
285 char jpath[PATH_MAX + 1]; |
289 char jpath[PATH_MAX + 1]; |
286 char *llp; |
290 char *llp; |
287 char *dmllp = NULL; |
291 char *dmllp = NULL; |
288 char *p; /* a utility pointer */ |
292 char *p; /* a utility pointer */ |
289 |
293 |
|
294 #ifdef AIX |
|
295 /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */ |
|
296 return JNI_TRUE; |
|
297 #endif |
|
298 |
290 llp = getenv("LD_LIBRARY_PATH"); |
299 llp = getenv("LD_LIBRARY_PATH"); |
291 #ifdef __solaris__ |
300 #ifdef __solaris__ |
292 dmllp = (CURRENT_DATA_MODEL == 32) |
301 dmllp = (CURRENT_DATA_MODEL == 32) |
293 ? getenv("LD_LIBRARY_PATH_32") |
302 ? getenv("LD_LIBRARY_PATH_32") |
294 : getenv("LD_LIBRARY_PATH_64"); |
303 : getenv("LD_LIBRARY_PATH_64"); |
596 #else /* ! __solaris__ */ |
605 #else /* ! __solaris__ */ |
597 /* |
606 /* |
598 * If not on Solaris, assume only a single LD_LIBRARY_PATH |
607 * If not on Solaris, assume only a single LD_LIBRARY_PATH |
599 * variable. |
608 * variable. |
600 */ |
609 */ |
601 runpath = getenv("LD_LIBRARY_PATH"); |
610 runpath = getenv(LD_LIBRARY_PATH); |
602 #endif /* __solaris__ */ |
611 #endif /* __solaris__ */ |
603 |
612 |
604 /* runpath contains current effective LD_LIBRARY_PATH setting */ |
613 /* runpath contains current effective LD_LIBRARY_PATH setting */ |
605 |
614 |
606 jvmpath = JLI_StringDup(jvmpath); |
615 jvmpath = JLI_StringDup(jvmpath); |
607 new_runpath = JLI_MemAlloc(((runpath != NULL) ? JLI_StrLen(runpath) : 0) + |
616 new_runpath = JLI_MemAlloc(((runpath != NULL) ? JLI_StrLen(runpath) : 0) + |
608 2 * JLI_StrLen(jrepath) + 2 * JLI_StrLen(arch) + |
617 2 * JLI_StrLen(jrepath) + 2 * JLI_StrLen(arch) + |
|
618 #ifdef AIX |
|
619 /* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */ |
|
620 JLI_StrLen(jrepath) + JLI_StrLen(arch) + JLI_StrLen("/lib//jli:") + |
|
621 #endif |
609 JLI_StrLen(jvmpath) + 52); |
622 JLI_StrLen(jvmpath) + 52); |
610 newpath = new_runpath + JLI_StrLen("LD_LIBRARY_PATH="); |
623 newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "="); |
611 |
624 |
612 |
625 |
613 /* |
626 /* |
614 * Create desired LD_LIBRARY_PATH value for target data model. |
627 * Create desired LD_LIBRARY_PATH value for target data model. |
615 */ |
628 */ |
617 /* remove the name of the .so from the JVM path */ |
630 /* remove the name of the .so from the JVM path */ |
618 lastslash = JLI_StrRChr(jvmpath, '/'); |
631 lastslash = JLI_StrRChr(jvmpath, '/'); |
619 if (lastslash) |
632 if (lastslash) |
620 *lastslash = '\0'; |
633 *lastslash = '\0'; |
621 |
634 |
622 sprintf(new_runpath, "LD_LIBRARY_PATH=" |
635 sprintf(new_runpath, LD_LIBRARY_PATH "=" |
623 "%s:" |
636 "%s:" |
624 "%s/lib/%s:" |
637 "%s/lib/%s:" |
|
638 #ifdef AIX |
|
639 "%s/lib/%s/jli:" /* Needed on AIX because ld doesn't support $ORIGIN. */ |
|
640 #endif |
625 "%s/../lib/%s", |
641 "%s/../lib/%s", |
626 jvmpath, |
642 jvmpath, |
627 #ifdef DUAL_MODE |
643 #ifdef DUAL_MODE |
628 jrepath, GetArchPath(wanted), |
644 jrepath, GetArchPath(wanted), |
629 jrepath, GetArchPath(wanted) |
645 jrepath, GetArchPath(wanted) |
630 #else /* !DUAL_MODE */ |
646 #else /* !DUAL_MODE */ |
631 jrepath, arch, |
647 jrepath, arch, |
|
648 #ifdef AIX |
|
649 jrepath, arch, |
|
650 #endif |
632 jrepath, arch |
651 jrepath, arch |
633 #endif /* DUAL_MODE */ |
652 #endif /* DUAL_MODE */ |
634 ); |
653 ); |
635 |
654 |
636 |
655 |
998 * Block current thread and continue execution in a new thread |
1017 * Block current thread and continue execution in a new thread |
999 */ |
1018 */ |
1000 int |
1019 int |
1001 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) { |
1020 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) { |
1002 int rslt; |
1021 int rslt; |
1003 #ifdef __linux__ |
1022 #ifndef __solaris__ |
1004 pthread_t tid; |
1023 pthread_t tid; |
1005 pthread_attr_t attr; |
1024 pthread_attr_t attr; |
1006 pthread_attr_init(&attr); |
1025 pthread_attr_init(&attr); |
1007 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); |
1026 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); |
1008 |
1027 |
1023 */ |
1042 */ |
1024 rslt = continuation(args); |
1043 rslt = continuation(args); |
1025 } |
1044 } |
1026 |
1045 |
1027 pthread_attr_destroy(&attr); |
1046 pthread_attr_destroy(&attr); |
1028 #else /* ! __linux__ */ |
1047 #else /* __solaris__ */ |
1029 thread_t tid; |
1048 thread_t tid; |
1030 long flags = 0; |
1049 long flags = 0; |
1031 if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) { |
1050 if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) { |
1032 void * tmp; |
1051 void * tmp; |
1033 thr_join(tid, NULL, &tmp); |
1052 thr_join(tid, NULL, &tmp); |
1034 rslt = (int)tmp; |
1053 rslt = (int)tmp; |
1035 } else { |
1054 } else { |
1036 /* See above. Continue in current thread if thr_create() failed */ |
1055 /* See above. Continue in current thread if thr_create() failed */ |
1037 rslt = continuation(args); |
1056 rslt = continuation(args); |
1038 } |
1057 } |
1039 #endif /* __linux__ */ |
1058 #endif /* !__solaris__ */ |
1040 return rslt; |
1059 return rslt; |
1041 } |
1060 } |
1042 |
1061 |
1043 /* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */ |
1062 /* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */ |
1044 #define MAX_PID_STR_SZ 20 |
1063 #define MAX_PID_STR_SZ 20 |