src/java.base/unix/native/libjli/java_md_solinux.c
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff src/java.base/unix/native/libjli

src/java.base/unix/native/libjli/java_md_solinux.c

Print this page
rev 11654 : imported patch libjli


 871 
 872 /*
 873  * Block current thread and continue execution in a new thread
 874  */
 875 int
 876 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
 877     int rslt;
 878 #ifndef __solaris__
 879     pthread_t tid;
 880     pthread_attr_t attr;
 881     pthread_attr_init(&attr);
 882     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 883 
 884     if (stack_size > 0) {
 885       pthread_attr_setstacksize(&attr, stack_size);
 886     }
 887 
 888     if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
 889       void * tmp;
 890       pthread_join(tid, &tmp);
 891       rslt = (int)tmp;
 892     } else {
 893      /*
 894       * Continue execution in current thread if for some reason (e.g. out of
 895       * memory/LWP)  a new thread can't be created. This will likely fail
 896       * later in continuation as JNI_CreateJavaVM needs to create quite a
 897       * few new threads, anyway, just give it a try..
 898       */
 899       rslt = continuation(args);
 900     }
 901 
 902     pthread_attr_destroy(&attr);
 903 #else /* __solaris__ */
 904     thread_t tid;
 905     long flags = 0;
 906     if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
 907       void * tmp;
 908       thr_join(tid, NULL, &tmp);
 909       rslt = (int)tmp;
 910     } else {
 911       /* See above. Continue in current thread if thr_create() failed */
 912       rslt = continuation(args);
 913     }
 914 #endif /* !__solaris__ */
 915     return rslt;
 916 }
 917 
 918 /* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */
 919 #define MAX_PID_STR_SZ   20
 920 
 921 void SetJavaLauncherPlatformProps() {
 922    /* Linux only */
 923 #ifdef __linux__
 924     const char *substr = "-Dsun.java.launcher.pid=";
 925     char *pid_prop_str = (char *)JLI_MemAlloc(JLI_StrLen(substr) + MAX_PID_STR_SZ + 1);
 926     sprintf(pid_prop_str, "%s%d", substr, getpid());
 927     AddOption(pid_prop_str, NULL);
 928 #endif /* __linux__ */
 929 }




 871 
 872 /*
 873  * Block current thread and continue execution in a new thread
 874  */
 875 int
 876 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
 877     int rslt;
 878 #ifndef __solaris__
 879     pthread_t tid;
 880     pthread_attr_t attr;
 881     pthread_attr_init(&attr);
 882     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 883 
 884     if (stack_size > 0) {
 885       pthread_attr_setstacksize(&attr, stack_size);
 886     }
 887 
 888     if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
 889       void * tmp;
 890       pthread_join(tid, &tmp);
 891       rslt = (int)(intptr_t)tmp;
 892     } else {
 893      /*
 894       * Continue execution in current thread if for some reason (e.g. out of
 895       * memory/LWP)  a new thread can't be created. This will likely fail
 896       * later in continuation as JNI_CreateJavaVM needs to create quite a
 897       * few new threads, anyway, just give it a try..
 898       */
 899       rslt = continuation(args);
 900     }
 901 
 902     pthread_attr_destroy(&attr);
 903 #else /* __solaris__ */
 904     thread_t tid;
 905     long flags = 0;
 906     if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
 907       void * tmp;
 908       thr_join(tid, NULL, &tmp);
 909       rslt = (int)(intptr_t)tmp;
 910     } else {
 911       /* See above. Continue in current thread if thr_create() failed */
 912       rslt = continuation(args);
 913     }
 914 #endif /* !__solaris__ */
 915     return rslt;
 916 }
 917 
 918 /* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */
 919 #define MAX_PID_STR_SZ   20
 920 
 921 void SetJavaLauncherPlatformProps() {
 922    /* Linux only */
 923 #ifdef __linux__
 924     const char *substr = "-Dsun.java.launcher.pid=";
 925     char *pid_prop_str = (char *)JLI_MemAlloc(JLI_StrLen(substr) + MAX_PID_STR_SZ + 1);
 926     sprintf(pid_prop_str, "%s%d", substr, getpid());
 927     AddOption(pid_prop_str, NULL);
 928 #endif /* __linux__ */
 929 }


src/java.base/unix/native/libjli/java_md_solinux.c
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File