src/solaris/bin/java_md.c

Print this page




  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include "java.h"
  27 #include <dirent.h>
  28 #include <dlfcn.h>
  29 #include <fcntl.h>
  30 #include <inttypes.h>
  31 #include <stdio.h>
  32 #include <string.h>
  33 #include <stdlib.h>
  34 #include <sys/stat.h>
  35 #include <unistd.h>
  36 #include <sys/types.h>
  37 #include "manifest_info.h"
  38 #include "version_comp.h"
  39 
  40 #ifdef __linux__
  41 #include <pthread.h>
  42 #else
  43 #include <thread.h>


  44 #endif
  45 
  46 #define JVM_DLL "libjvm.so"
  47 #define JAVA_DLL "libjava.so"
  48 
  49 /* help jettison the LD_LIBRARY_PATH settings in the future */
  50 #ifndef SETENV_REQUIRED
  51 #define SETENV_REQUIRED
  52 #endif
  53 /*
  54  * If a processor / os combination has the ability to run binaries of
  55  * two data models and cohabitation of jre/jdk bits with both data
  56  * models is supported, then DUAL_MODE is defined.  When DUAL_MODE is
  57  * defined, the architecture names for the narrow and wide version of
  58  * the architecture are defined in LIBARCH64NAME and LIBARCH32NAME.
  59  * Currently  only Solaris on sparc/sparcv9 and i586/amd64 is DUAL_MODE;
  60  * linux i586/amd64 could be defined as DUAL_MODE but that is not the
  61  * current policy.
  62  */
  63 


1417 void SplashFreeLibrary() {
1418     if (hSplashLib) {
1419         dlclose(hSplashLib);
1420         hSplashLib = NULL;
1421     }
1422 }
1423 
1424 const char *
1425 jlong_format_specifier() {
1426     return "%lld";
1427 }
1428 
1429 
1430 
1431 /*
1432  * Block current thread and continue execution in a new thread
1433  */
1434 int
1435 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
1436     int rslt;
1437 #ifdef __linux__











1438     pthread_t tid;
1439     pthread_attr_t attr;
1440     pthread_attr_init(&attr);
1441     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
1442 
1443     if (stack_size > 0) {
1444       pthread_attr_setstacksize(&attr, stack_size);
1445     }
1446 
1447     if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
1448       void * tmp;
1449       pthread_join(tid, &tmp);
1450       rslt = (int)tmp;
1451     } else {
1452      /*
1453       * Continue execution in current thread if for some reason (e.g. out of
1454       * memory/LWP)  a new thread can't be created. This will likely fail
1455       * later in continuation as JNI_CreateJavaVM needs to create quite a
1456       * few new threads, anyway, just give it a try..
1457       */
1458       rslt = continuation(args);
1459     }
1460 
1461     pthread_attr_destroy(&attr);
1462 #else
1463     thread_t tid;
1464     long flags = 0;
1465     if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
1466       void * tmp;
1467       thr_join(tid, NULL, &tmp);
1468       rslt = (int)tmp;
1469     } else {
1470       /* See above. Continue in current thread if thr_create() failed */
1471       rslt = continuation(args);
1472     }
1473 #endif
1474     return rslt;
1475 }
1476 
1477 /* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */
1478 #define MAX_PID_STR_SZ   20
1479 
1480 void SetJavaLauncherPlatformProps() {
1481    /* Linux only */
1482 #ifdef __linux__
1483     const char *substr = "-Dsun.java.launcher.pid=";
1484     char *pid_prop_str = (char *)JLI_MemAlloc(JLI_StrLen(substr) + MAX_PID_STR_SZ + 1);
1485     sprintf(pid_prop_str, "%s%d", substr, getpid());
1486     AddOption(pid_prop_str, NULL);
1487 #endif
1488 }
1489 
1490 jboolean
1491 IsJavaw()
1492 {




  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include "java.h"
  27 #include <dirent.h>
  28 #include <dlfcn.h>
  29 #include <fcntl.h>
  30 #include <inttypes.h>
  31 #include <stdio.h>
  32 #include <string.h>
  33 #include <stdlib.h>
  34 #include <sys/stat.h>
  35 #include <unistd.h>
  36 #include <sys/types.h>
  37 #include "manifest_info.h"
  38 #include "version_comp.h"
  39 
  40 #ifdef __solaris__


  41 #include <thread.h>
  42 #else
  43 #include <pthread.h>
  44 #endif
  45 
  46 #define JVM_DLL "libjvm.so"
  47 #define JAVA_DLL "libjava.so"
  48 
  49 /* help jettison the LD_LIBRARY_PATH settings in the future */
  50 #ifndef SETENV_REQUIRED
  51 #define SETENV_REQUIRED
  52 #endif
  53 /*
  54  * If a processor / os combination has the ability to run binaries of
  55  * two data models and cohabitation of jre/jdk bits with both data
  56  * models is supported, then DUAL_MODE is defined.  When DUAL_MODE is
  57  * defined, the architecture names for the narrow and wide version of
  58  * the architecture are defined in LIBARCH64NAME and LIBARCH32NAME.
  59  * Currently  only Solaris on sparc/sparcv9 and i586/amd64 is DUAL_MODE;
  60  * linux i586/amd64 could be defined as DUAL_MODE but that is not the
  61  * current policy.
  62  */
  63 


1417 void SplashFreeLibrary() {
1418     if (hSplashLib) {
1419         dlclose(hSplashLib);
1420         hSplashLib = NULL;
1421     }
1422 }
1423 
1424 const char *
1425 jlong_format_specifier() {
1426     return "%lld";
1427 }
1428 
1429 
1430 
1431 /*
1432  * Block current thread and continue execution in a new thread
1433  */
1434 int
1435 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
1436     int rslt;
1437 #ifdef __solaris__
1438     thread_t tid;
1439     long flags = 0;
1440     if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
1441       void * tmp;
1442       thr_join(tid, NULL, &tmp);
1443       rslt = (int)tmp;
1444     } else {
1445       /* See above. Continue in current thread if thr_create() failed */
1446       rslt = continuation(args);
1447     }
1448 #else
1449     pthread_t tid;
1450     pthread_attr_t attr;
1451     pthread_attr_init(&attr);
1452     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
1453 
1454     if (stack_size > 0) {
1455       pthread_attr_setstacksize(&attr, stack_size);
1456     }
1457 
1458     if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
1459       void * tmp;
1460       pthread_join(tid, &tmp);
1461       rslt = (int)tmp;
1462     } else {
1463      /*
1464       * Continue execution in current thread if for some reason (e.g. out of
1465       * memory/LWP)  a new thread can't be created. This will likely fail
1466       * later in continuation as JNI_CreateJavaVM needs to create quite a
1467       * few new threads, anyway, just give it a try..
1468       */
1469       rslt = continuation(args);
1470     }
1471 
1472     pthread_attr_destroy(&attr);











1473 #endif
1474     return rslt;
1475 }
1476 
1477 /* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */
1478 #define MAX_PID_STR_SZ   20
1479 
1480 void SetJavaLauncherPlatformProps() {
1481    /* Linux only */
1482 #ifdef __linux__
1483     const char *substr = "-Dsun.java.launcher.pid=";
1484     char *pid_prop_str = (char *)JLI_MemAlloc(JLI_StrLen(substr) + MAX_PID_STR_SZ + 1);
1485     sprintf(pid_prop_str, "%s%d", substr, getpid());
1486     AddOption(pid_prop_str, NULL);
1487 #endif
1488 }
1489 
1490 jboolean
1491 IsJavaw()
1492 {