336 // <JAVA_HOME>/jre/lib/<arch>/hotspot/libjvm.so. 337 // 338 // Otherwise exit. 339 // 340 // Important note: if the location of libjvm.so changes this 341 // code needs to be changed accordingly. 342 343 // See ld(1): 344 // The linker uses the following search paths to locate required 345 // shared libraries: 346 // 1: ... 347 // ... 348 // 7: The default directories, normally /lib and /usr/lib. 349 #ifndef DEFAULT_LIBPATH 350 #define DEFAULT_LIBPATH "/lib:/usr/lib" 351 #endif 352 353 // Base path of extensions installed on the system. 354 #define SYS_EXT_DIR "/usr/java/packages" 355 #define EXTENSIONS_DIR "/lib/ext" 356 #define ENDORSED_DIR "/lib/endorsed" 357 358 #ifndef __APPLE__ 359 360 // Buffer that fits several sprintfs. 361 // Note that the space for the colon and the trailing null are provided 362 // by the nulls included by the sizeof operator. 363 const size_t bufsize = 364 MAX3((size_t)MAXPATHLEN, // For dll_dir & friends. 365 (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR), // extensions dir 366 (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir 367 char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal); 368 369 // sysclasspath, java_home, dll_dir 370 { 371 char *pslash; 372 os::jvm_path(buf, bufsize); 373 374 // Found the full path to libjvm.so. 375 // Now cut the path to <java_home>/jre if we can. 376 *(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so. 377 pslash = strrchr(buf, '/'); 378 if (pslash != NULL) { 379 *pslash = '\0'; // Get rid of /{client|server|hotspot}. 380 } 381 Arguments::set_dll_dir(buf); 382 383 if (pslash != NULL) { 384 pslash = strrchr(buf, '/'); 385 if (pslash != NULL) { 386 *pslash = '\0'; // Get rid of /<arch>. 408 // Get the user setting of LD_LIBRARY_PATH, and prepended it. It 409 // should always exist (until the legacy problem cited above is 410 // addressed). 411 const char *v = ::getenv("LD_LIBRARY_PATH"); 412 const char *v_colon = ":"; 413 if (v == NULL) { v = ""; v_colon = ""; } 414 // That's +1 for the colon and +1 for the trailing '\0'. 415 char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char, 416 strlen(v) + 1 + 417 sizeof(SYS_EXT_DIR) + sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH) + 1, 418 mtInternal); 419 sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib/%s:" DEFAULT_LIBPATH, v, v_colon, cpu_arch); 420 Arguments::set_library_path(ld_library_path); 421 FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal); 422 } 423 424 // Extensions directories. 425 sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home()); 426 Arguments::set_ext_dirs(buf); 427 428 // Endorsed standards default directory. 429 sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home()); 430 Arguments::set_endorsed_dirs(buf); 431 432 FREE_C_HEAP_ARRAY(char, buf, mtInternal); 433 434 #else // __APPLE__ 435 436 #define SYS_EXTENSIONS_DIR "/Library/Java/Extensions" 437 #define SYS_EXTENSIONS_DIRS SYS_EXTENSIONS_DIR ":/Network" SYS_EXTENSIONS_DIR ":/System" SYS_EXTENSIONS_DIR ":/usr/lib/java" 438 439 const char *user_home_dir = get_home(); 440 // The null in SYS_EXTENSIONS_DIRS counts for the size of the colon after user_home_dir. 441 size_t system_ext_size = strlen(user_home_dir) + sizeof(SYS_EXTENSIONS_DIR) + 442 sizeof(SYS_EXTENSIONS_DIRS); 443 444 // Buffer that fits several sprintfs. 445 // Note that the space for the colon and the trailing null are provided 446 // by the nulls included by the sizeof operator. 447 const size_t bufsize = 448 MAX3((size_t)MAXPATHLEN, // for dll_dir & friends. 449 (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + system_ext_size, // extensions dir 450 (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir 451 char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal); 452 453 // sysclasspath, java_home, dll_dir 454 { 455 char *pslash; 456 os::jvm_path(buf, bufsize); 457 458 // Found the full path to libjvm.so. 459 // Now cut the path to <java_home>/jre if we can. 460 *(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so. 461 pslash = strrchr(buf, '/'); 462 if (pslash != NULL) { 463 *pslash = '\0'; // Get rid of /{client|server|hotspot}. 464 } 465 Arguments::set_dll_dir(buf); 466 467 if (pslash != NULL) { 468 pslash = strrchr(buf, '/'); 469 if (pslash != NULL) { 470 *pslash = '\0'; // Get rid of /lib. 508 // JAVA_LIBRARY_PATH environment variable. 509 char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char, 510 strlen(v) + 1 + strlen(l) + 1 + 511 system_ext_size + 3, 512 mtInternal); 513 sprintf(ld_library_path, "%s%s%s%s%s" SYS_EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS ":.", 514 v, v_colon, l, l_colon, user_home_dir); 515 Arguments::set_library_path(ld_library_path); 516 FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal); 517 } 518 519 // Extensions directories. 520 // 521 // Note that the space for the colon and the trailing null are provided 522 // by the nulls included by the sizeof operator (so actually one byte more 523 // than necessary is allocated). 524 sprintf(buf, "%s" SYS_EXTENSIONS_DIR ":%s" EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS, 525 user_home_dir, Arguments::get_java_home()); 526 Arguments::set_ext_dirs(buf); 527 528 // Endorsed standards default directory. 529 sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home()); 530 Arguments::set_endorsed_dirs(buf); 531 532 FREE_C_HEAP_ARRAY(char, buf, mtInternal); 533 534 #undef SYS_EXTENSIONS_DIR 535 #undef SYS_EXTENSIONS_DIRS 536 537 #endif // __APPLE__ 538 539 #undef SYS_EXT_DIR 540 #undef EXTENSIONS_DIR 541 #undef ENDORSED_DIR 542 } 543 544 //////////////////////////////////////////////////////////////////////////////// 545 // breakpoint support 546 547 void os::breakpoint() { 548 BREAKPOINT; 549 } 550 551 extern "C" void breakpoint() { 552 // use debugger to set breakpoint here 553 } 554 555 //////////////////////////////////////////////////////////////////////////////// 556 // signal support 557 558 debug_only(static bool signal_sets_initialized = false); 559 static sigset_t unblocked_sigs, vm_sigs, allowdebug_blocked_sigs; 560 561 bool os::Bsd::is_sig_ignored(int sig) { 2559 2560 for (int j = 0; j < i; ++j) { 2561 if (base[j] != NULL) { 2562 unmap_memory(base[j], size[j]); 2563 } 2564 } 2565 2566 if (i < max_tries) { 2567 _highest_vm_reserved_address = MAX2(old_highest, (address)requested_addr + bytes); 2568 return requested_addr; 2569 } else { 2570 _highest_vm_reserved_address = old_highest; 2571 return NULL; 2572 } 2573 } 2574 2575 size_t os::read(int fd, void *buf, unsigned int nBytes) { 2576 RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes)); 2577 } 2578 2579 void os::naked_short_sleep(jlong ms) { 2580 struct timespec req; 2581 2582 assert(ms < 1000, "Un-interruptable sleep, short time use only"); 2583 req.tv_sec = 0; 2584 if (ms > 0) { 2585 req.tv_nsec = (ms % 1000) * 1000000; 2586 } else { 2587 req.tv_nsec = 1; 2588 } 2589 2590 nanosleep(&req, NULL); 2591 2592 return; 2593 } 2594 2595 // Sleep forever; naked call to OS-specific sleep; use with CAUTION 2596 void os::infinite_sleep() { 2597 while (true) { // sleep forever ... 2598 ::sleep(100); // ... 100 seconds at a time | 336 // <JAVA_HOME>/jre/lib/<arch>/hotspot/libjvm.so. 337 // 338 // Otherwise exit. 339 // 340 // Important note: if the location of libjvm.so changes this 341 // code needs to be changed accordingly. 342 343 // See ld(1): 344 // The linker uses the following search paths to locate required 345 // shared libraries: 346 // 1: ... 347 // ... 348 // 7: The default directories, normally /lib and /usr/lib. 349 #ifndef DEFAULT_LIBPATH 350 #define DEFAULT_LIBPATH "/lib:/usr/lib" 351 #endif 352 353 // Base path of extensions installed on the system. 354 #define SYS_EXT_DIR "/usr/java/packages" 355 #define EXTENSIONS_DIR "/lib/ext" 356 357 #ifndef __APPLE__ 358 359 // Buffer that fits several sprintfs. 360 // Note that the space for the colon and the trailing null are provided 361 // by the nulls included by the sizeof operator. 362 const size_t bufsize = 363 MAX2((size_t)MAXPATHLEN, // For dll_dir & friends. 364 (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR)); // extensions dir 365 char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal); 366 367 // sysclasspath, java_home, dll_dir 368 { 369 char *pslash; 370 os::jvm_path(buf, bufsize); 371 372 // Found the full path to libjvm.so. 373 // Now cut the path to <java_home>/jre if we can. 374 *(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so. 375 pslash = strrchr(buf, '/'); 376 if (pslash != NULL) { 377 *pslash = '\0'; // Get rid of /{client|server|hotspot}. 378 } 379 Arguments::set_dll_dir(buf); 380 381 if (pslash != NULL) { 382 pslash = strrchr(buf, '/'); 383 if (pslash != NULL) { 384 *pslash = '\0'; // Get rid of /<arch>. 406 // Get the user setting of LD_LIBRARY_PATH, and prepended it. It 407 // should always exist (until the legacy problem cited above is 408 // addressed). 409 const char *v = ::getenv("LD_LIBRARY_PATH"); 410 const char *v_colon = ":"; 411 if (v == NULL) { v = ""; v_colon = ""; } 412 // That's +1 for the colon and +1 for the trailing '\0'. 413 char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char, 414 strlen(v) + 1 + 415 sizeof(SYS_EXT_DIR) + sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH) + 1, 416 mtInternal); 417 sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib/%s:" DEFAULT_LIBPATH, v, v_colon, cpu_arch); 418 Arguments::set_library_path(ld_library_path); 419 FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal); 420 } 421 422 // Extensions directories. 423 sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home()); 424 Arguments::set_ext_dirs(buf); 425 426 FREE_C_HEAP_ARRAY(char, buf, mtInternal); 427 428 #else // __APPLE__ 429 430 #define SYS_EXTENSIONS_DIR "/Library/Java/Extensions" 431 #define SYS_EXTENSIONS_DIRS SYS_EXTENSIONS_DIR ":/Network" SYS_EXTENSIONS_DIR ":/System" SYS_EXTENSIONS_DIR ":/usr/lib/java" 432 433 const char *user_home_dir = get_home(); 434 // The null in SYS_EXTENSIONS_DIRS counts for the size of the colon after user_home_dir. 435 size_t system_ext_size = strlen(user_home_dir) + sizeof(SYS_EXTENSIONS_DIR) + 436 sizeof(SYS_EXTENSIONS_DIRS); 437 438 // Buffer that fits several sprintfs. 439 // Note that the space for the colon and the trailing null are provided 440 // by the nulls included by the sizeof operator. 441 const size_t bufsize = 442 MAX2((size_t)MAXPATHLEN, // for dll_dir & friends. 443 (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + system_ext_size); // extensions dir 444 char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal); 445 446 // sysclasspath, java_home, dll_dir 447 { 448 char *pslash; 449 os::jvm_path(buf, bufsize); 450 451 // Found the full path to libjvm.so. 452 // Now cut the path to <java_home>/jre if we can. 453 *(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so. 454 pslash = strrchr(buf, '/'); 455 if (pslash != NULL) { 456 *pslash = '\0'; // Get rid of /{client|server|hotspot}. 457 } 458 Arguments::set_dll_dir(buf); 459 460 if (pslash != NULL) { 461 pslash = strrchr(buf, '/'); 462 if (pslash != NULL) { 463 *pslash = '\0'; // Get rid of /lib. 501 // JAVA_LIBRARY_PATH environment variable. 502 char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char, 503 strlen(v) + 1 + strlen(l) + 1 + 504 system_ext_size + 3, 505 mtInternal); 506 sprintf(ld_library_path, "%s%s%s%s%s" SYS_EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS ":.", 507 v, v_colon, l, l_colon, user_home_dir); 508 Arguments::set_library_path(ld_library_path); 509 FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal); 510 } 511 512 // Extensions directories. 513 // 514 // Note that the space for the colon and the trailing null are provided 515 // by the nulls included by the sizeof operator (so actually one byte more 516 // than necessary is allocated). 517 sprintf(buf, "%s" SYS_EXTENSIONS_DIR ":%s" EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS, 518 user_home_dir, Arguments::get_java_home()); 519 Arguments::set_ext_dirs(buf); 520 521 FREE_C_HEAP_ARRAY(char, buf, mtInternal); 522 523 #undef SYS_EXTENSIONS_DIR 524 #undef SYS_EXTENSIONS_DIRS 525 526 #endif // __APPLE__ 527 528 #undef SYS_EXT_DIR 529 #undef EXTENSIONS_DIR 530 } 531 532 //////////////////////////////////////////////////////////////////////////////// 533 // breakpoint support 534 535 void os::breakpoint() { 536 BREAKPOINT; 537 } 538 539 extern "C" void breakpoint() { 540 // use debugger to set breakpoint here 541 } 542 543 //////////////////////////////////////////////////////////////////////////////// 544 // signal support 545 546 debug_only(static bool signal_sets_initialized = false); 547 static sigset_t unblocked_sigs, vm_sigs, allowdebug_blocked_sigs; 548 549 bool os::Bsd::is_sig_ignored(int sig) { 2547 2548 for (int j = 0; j < i; ++j) { 2549 if (base[j] != NULL) { 2550 unmap_memory(base[j], size[j]); 2551 } 2552 } 2553 2554 if (i < max_tries) { 2555 _highest_vm_reserved_address = MAX2(old_highest, (address)requested_addr + bytes); 2556 return requested_addr; 2557 } else { 2558 _highest_vm_reserved_address = old_highest; 2559 return NULL; 2560 } 2561 } 2562 2563 size_t os::read(int fd, void *buf, unsigned int nBytes) { 2564 RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes)); 2565 } 2566 2567 size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) { 2568 RESTARTABLE_RETURN_INT(::pread(fd, buf, nBytes, offset)); 2569 } 2570 2571 void os::naked_short_sleep(jlong ms) { 2572 struct timespec req; 2573 2574 assert(ms < 1000, "Un-interruptable sleep, short time use only"); 2575 req.tv_sec = 0; 2576 if (ms > 0) { 2577 req.tv_nsec = (ms % 1000) * 1000000; 2578 } else { 2579 req.tv_nsec = 1; 2580 } 2581 2582 nanosleep(&req, NULL); 2583 2584 return; 2585 } 2586 2587 // Sleep forever; naked call to OS-specific sleep; use with CAUTION 2588 void os::infinite_sleep() { 2589 while (true) { // sleep forever ... 2590 ::sleep(100); // ... 100 seconds at a time |