810 } |
811 } |
811 #endif |
812 #endif |
812 |
813 |
813 #ifdef GAMMA |
814 #ifdef GAMMA |
814 { |
815 { |
815 /* gamma launcher uses JAVA_HOME or ALT_JAVA_HOME environment variable to find JDK/JRE */ |
816 /* gamma launcher uses JAVA_HOME environment variable to find JDK/JRE */ |
816 char* java_home_var = getenv("ALT_JAVA_HOME"); |
817 char* java_home_var = getenv("JAVA_HOME"); |
817 if (java_home_var == NULL) { |
818 if (java_home_var == NULL) { |
818 java_home_var = getenv("JAVA_HOME"); |
819 printf("JAVA_HOME must point to a valid JDK/JRE to run gamma\n"); |
819 } |
|
820 if (java_home_var == NULL) { |
|
821 printf("JAVA_HOME or ALT_JAVA_HOME must point to a valid JDK/JRE to run gamma\n"); |
|
822 return JNI_FALSE; |
820 return JNI_FALSE; |
823 } |
821 } |
824 snprintf(buf, bufsize, "%s", java_home_var); |
822 snprintf(buf, bufsize, "%s", java_home_var); |
825 } |
823 } |
826 #else |
824 #else |
1835 } |
1833 } |
1836 |
1834 |
1837 if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) { |
1835 if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) { |
1838 void * tmp; |
1836 void * tmp; |
1839 pthread_join(tid, &tmp); |
1837 pthread_join(tid, &tmp); |
1840 rslt = (int)tmp; |
1838 rslt = (int)(intptr_t)tmp; |
1841 } else { |
1839 } else { |
1842 /* |
1840 /* |
1843 * Continue execution in current thread if for some reason (e.g. out of |
1841 * Continue execution in current thread if for some reason (e.g. out of |
1844 * memory/LWP) a new thread can't be created. This will likely fail |
1842 * memory/LWP) a new thread can't be created. This will likely fail |
1845 * later in continuation as JNI_CreateJavaVM needs to create quite a |
1843 * later in continuation as JNI_CreateJavaVM needs to create quite a |
1853 thread_t tid; |
1851 thread_t tid; |
1854 long flags = 0; |
1852 long flags = 0; |
1855 if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) { |
1853 if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) { |
1856 void * tmp; |
1854 void * tmp; |
1857 thr_join(tid, NULL, &tmp); |
1855 thr_join(tid, NULL, &tmp); |
1858 rslt = (int)tmp; |
1856 rslt = (int)(intptr_t)tmp; |
1859 } else { |
1857 } else { |
1860 /* See above. Continue in current thread if thr_create() failed */ |
1858 /* See above. Continue in current thread if thr_create() failed */ |
1861 rslt = continuation(args); |
1859 rslt = continuation(args); |
1862 } |
1860 } |
1863 #endif |
1861 #endif |