Mercurial > hg > graal-jvmci-8
comparison src/os/bsd/vm/os_bsd.cpp @ 4846:e8a4934564b2
7125793: MAC: test_gamma should always work
Summary: Fix gamma launcher on Mac OS X and reconcile test_gamma script on Unix platforms
Reviewed-by: dcubed, ohair, jcoomes, dholmes, ksrini
Contributed-by: james.melvin@oracle.com
author | phh |
---|---|
date | Tue, 24 Jan 2012 19:33:14 -0500 |
parents | db18ca98d237 |
children | de268c8a8075 |
comparison
equal
deleted
inserted
replaced
4843:d6660fedbab5 | 4846:e8a4934564b2 |
---|---|
299 # endif | 299 # endif |
300 #else | 300 #else |
301 #error Add appropriate cpu_arch setting | 301 #error Add appropriate cpu_arch setting |
302 #endif | 302 #endif |
303 | 303 |
304 // Compiler variant | |
305 #ifdef COMPILER2 | |
306 #define COMPILER_VARIANT "server" | |
307 #else | |
308 #define COMPILER_VARIANT "client" | |
309 #endif | |
304 | 310 |
305 #ifndef _ALLBSD_SOURCE | 311 #ifndef _ALLBSD_SOURCE |
306 // pid_t gettid() | 312 // pid_t gettid() |
307 // | 313 // |
308 // Returns the kernel thread id of the currently running thread. Kernel | 314 // Returns the kernel thread id of the currently running thread. Kernel |
2505 print_signal_handler(st, BREAK_SIGNAL, buf, buflen); | 2511 print_signal_handler(st, BREAK_SIGNAL, buf, buflen); |
2506 } | 2512 } |
2507 | 2513 |
2508 static char saved_jvm_path[MAXPATHLEN] = {0}; | 2514 static char saved_jvm_path[MAXPATHLEN] = {0}; |
2509 | 2515 |
2510 // Find the full path to the current module, libjvm.so or libjvm_g.so | 2516 // Find the full path to the current module, libjvm or libjvm_g |
2511 void os::jvm_path(char *buf, jint buflen) { | 2517 void os::jvm_path(char *buf, jint buflen) { |
2512 // Error checking. | 2518 // Error checking. |
2513 if (buflen < MAXPATHLEN) { | 2519 if (buflen < MAXPATHLEN) { |
2514 assert(false, "must use a large-enough buffer"); | 2520 assert(false, "must use a large-enough buffer"); |
2515 buf[0] = '\0'; | 2521 buf[0] = '\0'; |
2530 if (rp == NULL) | 2536 if (rp == NULL) |
2531 return; | 2537 return; |
2532 | 2538 |
2533 if (Arguments::created_by_gamma_launcher()) { | 2539 if (Arguments::created_by_gamma_launcher()) { |
2534 // Support for the gamma launcher. Typical value for buf is | 2540 // Support for the gamma launcher. Typical value for buf is |
2535 // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so". If "/jre/lib/" appears at | 2541 // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm". If "/jre/lib/" appears at |
2536 // the right place in the string, then assume we are installed in a JDK and | 2542 // the right place in the string, then assume we are installed in a JDK and |
2537 // we're done. Otherwise, check for a JAVA_HOME environment variable and fix | 2543 // we're done. Otherwise, check for a JAVA_HOME environment variable and |
2538 // up the path so it looks like libjvm.so is installed there (append a | 2544 // construct a path to the JVM being overridden. |
2539 // fake suffix hotspot/libjvm.so). | 2545 |
2540 const char *p = buf + strlen(buf) - 1; | 2546 const char *p = buf + strlen(buf) - 1; |
2541 for (int count = 0; p > buf && count < 5; ++count) { | 2547 for (int count = 0; p > buf && count < 5; ++count) { |
2542 for (--p; p > buf && *p != '/'; --p) | 2548 for (--p; p > buf && *p != '/'; --p) |
2543 /* empty */ ; | 2549 /* empty */ ; |
2544 } | 2550 } |
2548 char* java_home_var = ::getenv("JAVA_HOME"); | 2554 char* java_home_var = ::getenv("JAVA_HOME"); |
2549 if (java_home_var != NULL && java_home_var[0] != 0) { | 2555 if (java_home_var != NULL && java_home_var[0] != 0) { |
2550 char* jrelib_p; | 2556 char* jrelib_p; |
2551 int len; | 2557 int len; |
2552 | 2558 |
2553 // Check the current module name "libjvm.so" or "libjvm_g.so". | 2559 // Check the current module name "libjvm" or "libjvm_g". |
2554 p = strrchr(buf, '/'); | 2560 p = strrchr(buf, '/'); |
2555 assert(strstr(p, "/libjvm") == p, "invalid library name"); | 2561 assert(strstr(p, "/libjvm") == p, "invalid library name"); |
2556 p = strstr(p, "_g") ? "_g" : ""; | 2562 p = strstr(p, "_g") ? "_g" : ""; |
2557 | 2563 |
2558 rp = realpath(java_home_var, buf); | 2564 rp = realpath(java_home_var, buf); |
2561 | 2567 |
2562 // determine if this is a legacy image or modules image | 2568 // determine if this is a legacy image or modules image |
2563 // modules image doesn't have "jre" subdirectory | 2569 // modules image doesn't have "jre" subdirectory |
2564 len = strlen(buf); | 2570 len = strlen(buf); |
2565 jrelib_p = buf + len; | 2571 jrelib_p = buf + len; |
2566 snprintf(jrelib_p, buflen-len, "/jre/lib/%s", cpu_arch); | 2572 |
2573 // Add the appropriate library subdir | |
2574 snprintf(jrelib_p, buflen-len, "/jre/lib"); | |
2567 if (0 != access(buf, F_OK)) { | 2575 if (0 != access(buf, F_OK)) { |
2568 snprintf(jrelib_p, buflen-len, "/lib/%s", cpu_arch); | 2576 snprintf(jrelib_p, buflen-len, "/lib"); |
2569 } | 2577 } |
2570 | 2578 |
2579 // Add the appropriate client or server subdir | |
2580 len = strlen(buf); | |
2581 jrelib_p = buf + len; | |
2582 snprintf(jrelib_p, buflen-len, "/%s", COMPILER_VARIANT); | |
2583 if (0 != access(buf, F_OK)) { | |
2584 snprintf(jrelib_p, buflen-len, ""); | |
2585 } | |
2586 | |
2587 // If the path exists within JAVA_HOME, add the JVM library name | |
2588 // to complete the path to JVM being overridden. Otherwise fallback | |
2589 // to the path to the current library. | |
2571 if (0 == access(buf, F_OK)) { | 2590 if (0 == access(buf, F_OK)) { |
2572 // Use current module name "libjvm[_g].so" instead of | 2591 // Use current module name "libjvm[_g]" instead of |
2573 // "libjvm"debug_only("_g")".so" since for fastdebug version | 2592 // "libjvm"debug_only("_g")"" since for fastdebug version |
2574 // we should have "libjvm.so" but debug_only("_g") adds "_g"! | 2593 // we should have "libjvm" but debug_only("_g") adds "_g"! |
2575 len = strlen(buf); | 2594 len = strlen(buf); |
2576 snprintf(buf + len, buflen-len, "/hotspot/libjvm%s.so", p); | 2595 snprintf(buf + len, buflen-len, "/libjvm%s%s", p, JNI_LIB_SUFFIX); |
2577 } else { | 2596 } else { |
2578 // Go back to path of .so | 2597 // Fall back to path of current library |
2579 rp = realpath(dli_fname, buf); | 2598 rp = realpath(dli_fname, buf); |
2580 if (rp == NULL) | 2599 if (rp == NULL) |
2581 return; | 2600 return; |
2582 } | 2601 } |
2583 } | 2602 } |