1101 sigset_t* os::Solaris::unblocked_signals() {
1102 assert(signal_sets_initialized, "Not initialized");
1103 return &unblocked_sigs;
1104 }
1105
1106 // These are the signals that are blocked while a (non-VM) thread is
1107 // running Java. Only the VM thread handles these signals.
1108 sigset_t* os::Solaris::vm_signals() {
1109 assert(signal_sets_initialized, "Not initialized");
1110 return &vm_sigs;
1111 }
1112
1113 // These are signals that are blocked during cond_wait to allow debugger in
1114 sigset_t* os::Solaris::allowdebug_blocked_signals() {
1115 assert(signal_sets_initialized, "Not initialized");
1116 return &allowdebug_blocked_sigs;
1117 }
1118
1119
1120 void _handle_uncaught_cxx_exception() {
1121 VMError err("An uncaught C++ exception");
1122 err.report_and_die();
1123 }
1124
1125
1126 // First crack at OS-specific initialization, from inside the new thread.
1127 void os::initialize_thread(Thread* thr) {
1128 int r = thr_main();
1129 guarantee(r == 0 || r == 1, "CR6501650 or CR6493689");
1130 if (r) {
1131 JavaThread* jt = (JavaThread *)thr;
1132 assert(jt != NULL, "Sanity check");
1133 size_t stack_size;
1134 address base = jt->stack_base();
1135 if (Arguments::created_by_java_launcher()) {
1136 // Use 2MB to allow for Solaris 7 64 bit mode.
1137 stack_size = JavaThread::stack_size_at_create() == 0
1138 ? 2048*K : JavaThread::stack_size_at_create();
1139
1140 // There are rare cases when we may have already used more than
1141 // the basic stack size allotment before this method is invoked.
1142 // Attempt to allow for a normally sized java_stack.
1313 return false;
1314 }
1315 return status.pr_flags & PR_MSACCT;
1316 }
1317
1318 double os::elapsedVTime() {
1319 return (double)gethrvtime() / (double)hrtime_hz;
1320 }
1321
1322 // Used internally for comparisons only
1323 // getTimeMillis guaranteed to not move backwards on Solaris
1324 jlong getTimeMillis() {
1325 jlong nanotime = getTimeNanos();
1326 return (jlong)(nanotime / NANOSECS_PER_MILLISEC);
1327 }
1328
1329 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
1330 jlong os::javaTimeMillis() {
1331 timeval t;
1332 if (gettimeofday(&t, NULL) == -1) {
1333 fatal(err_msg("os::javaTimeMillis: gettimeofday (%s)", strerror(errno)));
1334 }
1335 return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000;
1336 }
1337
1338 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
1339 timeval t;
1340 if (gettimeofday(&t, NULL) == -1) {
1341 fatal(err_msg("os::javaTimeSystemUTC: gettimeofday (%s)", strerror(errno)));
1342 }
1343 seconds = jlong(t.tv_sec);
1344 nanos = jlong(t.tv_usec) * 1000;
1345 }
1346
1347
1348 jlong os::javaTimeNanos() {
1349 return (jlong)getTimeNanos();
1350 }
1351
1352 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) {
1353 info_ptr->max_value = ALL_64_BITS; // gethrtime() uses all 64 bits
1354 info_ptr->may_skip_backward = false; // not subject to resetting or drifting
1355 info_ptr->may_skip_forward = false; // not subject to resetting or drifting
1356 info_ptr->kind = JVMTI_TIMER_ELAPSED; // elapsed not CPU time
1357 }
1358
1359 char * os::local_time_string(char *buf, size_t buflen) {
1360 struct tm t;
1361 time_t long_time;
2375
2376 if (!recoverable_mmap_error(err)) {
2377 warn_fail_commit_memory(addr, bytes, exec, err);
2378 vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "committing reserved memory.");
2379 }
2380
2381 return err;
2382 }
2383
2384 bool os::pd_commit_memory(char* addr, size_t bytes, bool exec) {
2385 return Solaris::commit_memory_impl(addr, bytes, exec) == 0;
2386 }
2387
2388 void os::pd_commit_memory_or_exit(char* addr, size_t bytes, bool exec,
2389 const char* mesg) {
2390 assert(mesg != NULL, "mesg must be specified");
2391 int err = os::Solaris::commit_memory_impl(addr, bytes, exec);
2392 if (err != 0) {
2393 // the caller wants all commit errors to exit with the specified mesg:
2394 warn_fail_commit_memory(addr, bytes, exec, err);
2395 vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, mesg);
2396 }
2397 }
2398
2399 size_t os::Solaris::page_size_for_alignment(size_t alignment) {
2400 assert(is_size_aligned(alignment, (size_t) vm_page_size()),
2401 err_msg(SIZE_FORMAT " is not aligned to " SIZE_FORMAT,
2402 alignment, (size_t) vm_page_size()));
2403
2404 for (int i = 0; _page_sizes[i] != 0; i++) {
2405 if (is_size_aligned(alignment, _page_sizes[i])) {
2406 return _page_sizes[i];
2407 }
2408 }
2409
2410 return (size_t) vm_page_size();
2411 }
2412
2413 int os::Solaris::commit_memory_impl(char* addr, size_t bytes,
2414 size_t alignment_hint, bool exec) {
2415 int err = Solaris::commit_memory_impl(addr, bytes, exec);
2416 if (err == 0 && UseLargePages && alignment_hint > 0) {
2417 assert(is_size_aligned(bytes, alignment_hint),
2418 err_msg(SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, alignment_hint));
2419
2420 // The syscall memcntl requires an exact page size (see man memcntl for details).
2421 size_t page_size = page_size_for_alignment(alignment_hint);
2422 if (page_size > (size_t) vm_page_size()) {
2423 (void)Solaris::setup_large_pages(addr, bytes, page_size);
2424 }
2425 }
2426 return err;
2427 }
2428
2429 bool os::pd_commit_memory(char* addr, size_t bytes, size_t alignment_hint,
2430 bool exec) {
2431 return Solaris::commit_memory_impl(addr, bytes, alignment_hint, exec) == 0;
2432 }
2433
2434 void os::pd_commit_memory_or_exit(char* addr, size_t bytes,
2435 size_t alignment_hint, bool exec,
2436 const char* mesg) {
2437 assert(mesg != NULL, "mesg must be specified");
2438 int err = os::Solaris::commit_memory_impl(addr, bytes, alignment_hint, exec);
2439 if (err != 0) {
2440 // the caller wants all commit errors to exit with the specified mesg:
2441 warn_fail_commit_memory(addr, bytes, alignment_hint, exec, err);
2442 vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, mesg);
2443 }
2444 }
2445
2446 // Uncommit the pages in a specified region.
2447 void os::pd_free_memory(char* addr, size_t bytes, size_t alignment_hint) {
2448 if (madvise(addr, bytes, MADV_FREE) < 0) {
2449 debug_only(warning("MADV_FREE failed."));
2450 return;
2451 }
2452 }
2453
2454 bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
2455 return os::commit_memory(addr, size, !ExecMem);
2456 }
2457
2458 bool os::remove_stack_guard_pages(char* addr, size_t size) {
2459 return os::uncommit_memory(addr, size);
2460 }
2461
2462 // Change the page size in a given range.
2952 void os::large_page_init() {
2953 if (UseLargePages) {
2954 // print a warning if any large page related flag is specified on command line
2955 bool warn_on_failure = !FLAG_IS_DEFAULT(UseLargePages) ||
2956 !FLAG_IS_DEFAULT(LargePageSizeInBytes);
2957
2958 UseLargePages = Solaris::mpss_sanity_check(warn_on_failure, &_large_page_size);
2959 }
2960 }
2961
2962 bool os::Solaris::is_valid_page_size(size_t bytes) {
2963 for (int i = 0; _page_sizes[i] != 0; i++) {
2964 if (_page_sizes[i] == bytes) {
2965 return true;
2966 }
2967 }
2968 return false;
2969 }
2970
2971 bool os::Solaris::setup_large_pages(caddr_t start, size_t bytes, size_t align) {
2972 assert(is_valid_page_size(align), err_msg(SIZE_FORMAT " is not a valid page size", align));
2973 assert(is_ptr_aligned((void*) start, align),
2974 err_msg(PTR_FORMAT " is not aligned to " SIZE_FORMAT, p2i((void*) start), align));
2975 assert(is_size_aligned(bytes, align),
2976 err_msg(SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, align));
2977
2978 // Signal to OS that we want large pages for addresses
2979 // from addr, addr + bytes
2980 struct memcntl_mha mpss_struct;
2981 mpss_struct.mha_cmd = MHA_MAPSIZE_VA;
2982 mpss_struct.mha_pagesize = align;
2983 mpss_struct.mha_flags = 0;
2984 // Upon successful completion, memcntl() returns 0
2985 if (memcntl(start, bytes, MC_HAT_ADVISE, (caddr_t) &mpss_struct, 0, 0)) {
2986 debug_only(warning("Attempt to use MPSS failed."));
2987 return false;
2988 }
2989 return true;
2990 }
2991
2992 char* os::reserve_memory_special(size_t size, size_t alignment, char* addr, bool exec) {
2993 fatal("os::reserve_memory_special should not be called on Solaris.");
2994 return NULL;
2995 }
2996
3939 sigaction(sig, (struct sigaction*)NULL, &oldAct);
3940 void* oldhand =
3941 oldAct.sa_sigaction ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction)
3942 : CAST_FROM_FN_PTR(void*, oldAct.sa_handler);
3943 if (oldhand != CAST_FROM_FN_PTR(void*, SIG_DFL) &&
3944 oldhand != CAST_FROM_FN_PTR(void*, SIG_IGN) &&
3945 oldhand != CAST_FROM_FN_PTR(void*, signalHandler)) {
3946 if (AllowUserSignalHandlers || !set_installed) {
3947 // Do not overwrite; user takes responsibility to forward to us.
3948 return;
3949 } else if (UseSignalChaining) {
3950 if (oktochain) {
3951 // save the old handler in jvm
3952 save_preinstalled_handler(sig, oldAct);
3953 } else {
3954 vm_exit_during_initialization("Signal chaining not allowed for VM interrupt signal, try -XX:+UseAltSigs.");
3955 }
3956 // libjsig also interposes the sigaction() call below and saves the
3957 // old sigaction on it own.
3958 } else {
3959 fatal(err_msg("Encountered unexpected pre-existing sigaction handler "
3960 "%#lx for signal %d.", (long)oldhand, sig));
3961 }
3962 }
3963
3964 struct sigaction sigAct;
3965 sigfillset(&(sigAct.sa_mask));
3966 sigAct.sa_handler = SIG_DFL;
3967
3968 sigAct.sa_sigaction = signalHandler;
3969 // Handle SIGSEGV on alternate signal stack if
3970 // not using stack banging
3971 if (!UseStackBanging && sig == SIGSEGV) {
3972 sigAct.sa_flags = SA_SIGINFO | SA_RESTART | SA_ONSTACK;
3973 } else if (sig == os::Solaris::SIGinterrupt()) {
3974 // Interruptible i/o requires SA_RESTART cleared so EINTR
3975 // is returned instead of restarting system calls
3976 sigemptyset(&sigAct.sa_mask);
3977 sigAct.sa_handler = NULL;
3978 sigAct.sa_flags = SA_SIGINFO;
3979 sigAct.sa_sigaction = sigINTRHandler;
3980 } else {
4386 void init_pset_getloadavg_ptr(void) {
4387 pset_getloadavg_ptr =
4388 (pset_getloadavg_type)dlsym(RTLD_DEFAULT, "pset_getloadavg");
4389 if (PrintMiscellaneous && Verbose && pset_getloadavg_ptr == NULL) {
4390 warning("pset_getloadavg function not found");
4391 }
4392 }
4393
4394 int os::Solaris::_dev_zero_fd = -1;
4395
4396 // this is called _before_ the global arguments have been parsed
4397 void os::init(void) {
4398 _initial_pid = getpid();
4399
4400 max_hrtime = first_hrtime = gethrtime();
4401
4402 init_random(1234567);
4403
4404 page_size = sysconf(_SC_PAGESIZE);
4405 if (page_size == -1) {
4406 fatal(err_msg("os_solaris.cpp: os::init: sysconf failed (%s)",
4407 strerror(errno)));
4408 }
4409 init_page_sizes((size_t) page_size);
4410
4411 Solaris::initialize_system_info();
4412
4413 // Initialize misc. symbols as soon as possible, so we can use them
4414 // if we need them.
4415 Solaris::misc_sym_init();
4416
4417 int fd = ::open("/dev/zero", O_RDWR);
4418 if (fd < 0) {
4419 fatal(err_msg("os::init: cannot open /dev/zero (%s)", strerror(errno)));
4420 } else {
4421 Solaris::set_dev_zero_fd(fd);
4422
4423 // Close on exec, child won't inherit.
4424 fcntl(fd, F_SETFD, FD_CLOEXEC);
4425 }
4426
4427 clock_tics_per_sec = CLK_TCK;
4428
4429 // check if dladdr1() exists; dladdr1 can provide more information than
4430 // dladdr for os::dll_address_to_function_name. It comes with SunOS 5.9
4431 // and is available on linker patches for 5.7 and 5.8.
4432 // libdl.so must have been loaded, this call is just an entry lookup
4433 void * hdl = dlopen("libdl.so", RTLD_NOW);
4434 if (hdl) {
4435 dladdr1_func = CAST_TO_FN_PTR(dladdr1_func_type, dlsym(hdl, "dladdr1"));
4436 }
4437
4438 // (Solaris only) this switches to calls that actually do locking.
4439 ThreadCritical::initialize();
|
1101 sigset_t* os::Solaris::unblocked_signals() {
1102 assert(signal_sets_initialized, "Not initialized");
1103 return &unblocked_sigs;
1104 }
1105
1106 // These are the signals that are blocked while a (non-VM) thread is
1107 // running Java. Only the VM thread handles these signals.
1108 sigset_t* os::Solaris::vm_signals() {
1109 assert(signal_sets_initialized, "Not initialized");
1110 return &vm_sigs;
1111 }
1112
1113 // These are signals that are blocked during cond_wait to allow debugger in
1114 sigset_t* os::Solaris::allowdebug_blocked_signals() {
1115 assert(signal_sets_initialized, "Not initialized");
1116 return &allowdebug_blocked_sigs;
1117 }
1118
1119
1120 void _handle_uncaught_cxx_exception() {
1121 VMError::report_and_die("An uncaught C++ exception");
1122 }
1123
1124
1125 // First crack at OS-specific initialization, from inside the new thread.
1126 void os::initialize_thread(Thread* thr) {
1127 int r = thr_main();
1128 guarantee(r == 0 || r == 1, "CR6501650 or CR6493689");
1129 if (r) {
1130 JavaThread* jt = (JavaThread *)thr;
1131 assert(jt != NULL, "Sanity check");
1132 size_t stack_size;
1133 address base = jt->stack_base();
1134 if (Arguments::created_by_java_launcher()) {
1135 // Use 2MB to allow for Solaris 7 64 bit mode.
1136 stack_size = JavaThread::stack_size_at_create() == 0
1137 ? 2048*K : JavaThread::stack_size_at_create();
1138
1139 // There are rare cases when we may have already used more than
1140 // the basic stack size allotment before this method is invoked.
1141 // Attempt to allow for a normally sized java_stack.
1312 return false;
1313 }
1314 return status.pr_flags & PR_MSACCT;
1315 }
1316
1317 double os::elapsedVTime() {
1318 return (double)gethrvtime() / (double)hrtime_hz;
1319 }
1320
1321 // Used internally for comparisons only
1322 // getTimeMillis guaranteed to not move backwards on Solaris
1323 jlong getTimeMillis() {
1324 jlong nanotime = getTimeNanos();
1325 return (jlong)(nanotime / NANOSECS_PER_MILLISEC);
1326 }
1327
1328 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
1329 jlong os::javaTimeMillis() {
1330 timeval t;
1331 if (gettimeofday(&t, NULL) == -1) {
1332 fatal("os::javaTimeMillis: gettimeofday (%s)", strerror(errno));
1333 }
1334 return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000;
1335 }
1336
1337 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
1338 timeval t;
1339 if (gettimeofday(&t, NULL) == -1) {
1340 fatal("os::javaTimeSystemUTC: gettimeofday (%s)", strerror(errno));
1341 }
1342 seconds = jlong(t.tv_sec);
1343 nanos = jlong(t.tv_usec) * 1000;
1344 }
1345
1346
1347 jlong os::javaTimeNanos() {
1348 return (jlong)getTimeNanos();
1349 }
1350
1351 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) {
1352 info_ptr->max_value = ALL_64_BITS; // gethrtime() uses all 64 bits
1353 info_ptr->may_skip_backward = false; // not subject to resetting or drifting
1354 info_ptr->may_skip_forward = false; // not subject to resetting or drifting
1355 info_ptr->kind = JVMTI_TIMER_ELAPSED; // elapsed not CPU time
1356 }
1357
1358 char * os::local_time_string(char *buf, size_t buflen) {
1359 struct tm t;
1360 time_t long_time;
2374
2375 if (!recoverable_mmap_error(err)) {
2376 warn_fail_commit_memory(addr, bytes, exec, err);
2377 vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "committing reserved memory.");
2378 }
2379
2380 return err;
2381 }
2382
2383 bool os::pd_commit_memory(char* addr, size_t bytes, bool exec) {
2384 return Solaris::commit_memory_impl(addr, bytes, exec) == 0;
2385 }
2386
2387 void os::pd_commit_memory_or_exit(char* addr, size_t bytes, bool exec,
2388 const char* mesg) {
2389 assert(mesg != NULL, "mesg must be specified");
2390 int err = os::Solaris::commit_memory_impl(addr, bytes, exec);
2391 if (err != 0) {
2392 // the caller wants all commit errors to exit with the specified mesg:
2393 warn_fail_commit_memory(addr, bytes, exec, err);
2394 vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "%s", mesg);
2395 }
2396 }
2397
2398 size_t os::Solaris::page_size_for_alignment(size_t alignment) {
2399 assert(is_size_aligned(alignment, (size_t) vm_page_size()),
2400 SIZE_FORMAT " is not aligned to " SIZE_FORMAT,
2401 alignment, (size_t) vm_page_size());
2402
2403 for (int i = 0; _page_sizes[i] != 0; i++) {
2404 if (is_size_aligned(alignment, _page_sizes[i])) {
2405 return _page_sizes[i];
2406 }
2407 }
2408
2409 return (size_t) vm_page_size();
2410 }
2411
2412 int os::Solaris::commit_memory_impl(char* addr, size_t bytes,
2413 size_t alignment_hint, bool exec) {
2414 int err = Solaris::commit_memory_impl(addr, bytes, exec);
2415 if (err == 0 && UseLargePages && alignment_hint > 0) {
2416 assert(is_size_aligned(bytes, alignment_hint),
2417 SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, alignment_hint);
2418
2419 // The syscall memcntl requires an exact page size (see man memcntl for details).
2420 size_t page_size = page_size_for_alignment(alignment_hint);
2421 if (page_size > (size_t) vm_page_size()) {
2422 (void)Solaris::setup_large_pages(addr, bytes, page_size);
2423 }
2424 }
2425 return err;
2426 }
2427
2428 bool os::pd_commit_memory(char* addr, size_t bytes, size_t alignment_hint,
2429 bool exec) {
2430 return Solaris::commit_memory_impl(addr, bytes, alignment_hint, exec) == 0;
2431 }
2432
2433 void os::pd_commit_memory_or_exit(char* addr, size_t bytes,
2434 size_t alignment_hint, bool exec,
2435 const char* mesg) {
2436 assert(mesg != NULL, "mesg must be specified");
2437 int err = os::Solaris::commit_memory_impl(addr, bytes, alignment_hint, exec);
2438 if (err != 0) {
2439 // the caller wants all commit errors to exit with the specified mesg:
2440 warn_fail_commit_memory(addr, bytes, alignment_hint, exec, err);
2441 vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "%s", mesg);
2442 }
2443 }
2444
2445 // Uncommit the pages in a specified region.
2446 void os::pd_free_memory(char* addr, size_t bytes, size_t alignment_hint) {
2447 if (madvise(addr, bytes, MADV_FREE) < 0) {
2448 debug_only(warning("MADV_FREE failed."));
2449 return;
2450 }
2451 }
2452
2453 bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
2454 return os::commit_memory(addr, size, !ExecMem);
2455 }
2456
2457 bool os::remove_stack_guard_pages(char* addr, size_t size) {
2458 return os::uncommit_memory(addr, size);
2459 }
2460
2461 // Change the page size in a given range.
2951 void os::large_page_init() {
2952 if (UseLargePages) {
2953 // print a warning if any large page related flag is specified on command line
2954 bool warn_on_failure = !FLAG_IS_DEFAULT(UseLargePages) ||
2955 !FLAG_IS_DEFAULT(LargePageSizeInBytes);
2956
2957 UseLargePages = Solaris::mpss_sanity_check(warn_on_failure, &_large_page_size);
2958 }
2959 }
2960
2961 bool os::Solaris::is_valid_page_size(size_t bytes) {
2962 for (int i = 0; _page_sizes[i] != 0; i++) {
2963 if (_page_sizes[i] == bytes) {
2964 return true;
2965 }
2966 }
2967 return false;
2968 }
2969
2970 bool os::Solaris::setup_large_pages(caddr_t start, size_t bytes, size_t align) {
2971 assert(is_valid_page_size(align), SIZE_FORMAT " is not a valid page size", align);
2972 assert(is_ptr_aligned((void*) start, align),
2973 PTR_FORMAT " is not aligned to " SIZE_FORMAT, p2i((void*) start), align);
2974 assert(is_size_aligned(bytes, align),
2975 SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, align);
2976
2977 // Signal to OS that we want large pages for addresses
2978 // from addr, addr + bytes
2979 struct memcntl_mha mpss_struct;
2980 mpss_struct.mha_cmd = MHA_MAPSIZE_VA;
2981 mpss_struct.mha_pagesize = align;
2982 mpss_struct.mha_flags = 0;
2983 // Upon successful completion, memcntl() returns 0
2984 if (memcntl(start, bytes, MC_HAT_ADVISE, (caddr_t) &mpss_struct, 0, 0)) {
2985 debug_only(warning("Attempt to use MPSS failed."));
2986 return false;
2987 }
2988 return true;
2989 }
2990
2991 char* os::reserve_memory_special(size_t size, size_t alignment, char* addr, bool exec) {
2992 fatal("os::reserve_memory_special should not be called on Solaris.");
2993 return NULL;
2994 }
2995
3938 sigaction(sig, (struct sigaction*)NULL, &oldAct);
3939 void* oldhand =
3940 oldAct.sa_sigaction ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction)
3941 : CAST_FROM_FN_PTR(void*, oldAct.sa_handler);
3942 if (oldhand != CAST_FROM_FN_PTR(void*, SIG_DFL) &&
3943 oldhand != CAST_FROM_FN_PTR(void*, SIG_IGN) &&
3944 oldhand != CAST_FROM_FN_PTR(void*, signalHandler)) {
3945 if (AllowUserSignalHandlers || !set_installed) {
3946 // Do not overwrite; user takes responsibility to forward to us.
3947 return;
3948 } else if (UseSignalChaining) {
3949 if (oktochain) {
3950 // save the old handler in jvm
3951 save_preinstalled_handler(sig, oldAct);
3952 } else {
3953 vm_exit_during_initialization("Signal chaining not allowed for VM interrupt signal, try -XX:+UseAltSigs.");
3954 }
3955 // libjsig also interposes the sigaction() call below and saves the
3956 // old sigaction on it own.
3957 } else {
3958 fatal("Encountered unexpected pre-existing sigaction handler "
3959 "%#lx for signal %d.", (long)oldhand, sig);
3960 }
3961 }
3962
3963 struct sigaction sigAct;
3964 sigfillset(&(sigAct.sa_mask));
3965 sigAct.sa_handler = SIG_DFL;
3966
3967 sigAct.sa_sigaction = signalHandler;
3968 // Handle SIGSEGV on alternate signal stack if
3969 // not using stack banging
3970 if (!UseStackBanging && sig == SIGSEGV) {
3971 sigAct.sa_flags = SA_SIGINFO | SA_RESTART | SA_ONSTACK;
3972 } else if (sig == os::Solaris::SIGinterrupt()) {
3973 // Interruptible i/o requires SA_RESTART cleared so EINTR
3974 // is returned instead of restarting system calls
3975 sigemptyset(&sigAct.sa_mask);
3976 sigAct.sa_handler = NULL;
3977 sigAct.sa_flags = SA_SIGINFO;
3978 sigAct.sa_sigaction = sigINTRHandler;
3979 } else {
4385 void init_pset_getloadavg_ptr(void) {
4386 pset_getloadavg_ptr =
4387 (pset_getloadavg_type)dlsym(RTLD_DEFAULT, "pset_getloadavg");
4388 if (PrintMiscellaneous && Verbose && pset_getloadavg_ptr == NULL) {
4389 warning("pset_getloadavg function not found");
4390 }
4391 }
4392
4393 int os::Solaris::_dev_zero_fd = -1;
4394
4395 // this is called _before_ the global arguments have been parsed
4396 void os::init(void) {
4397 _initial_pid = getpid();
4398
4399 max_hrtime = first_hrtime = gethrtime();
4400
4401 init_random(1234567);
4402
4403 page_size = sysconf(_SC_PAGESIZE);
4404 if (page_size == -1) {
4405 fatal("os_solaris.cpp: os::init: sysconf failed (%s)", strerror(errno));
4406 }
4407 init_page_sizes((size_t) page_size);
4408
4409 Solaris::initialize_system_info();
4410
4411 // Initialize misc. symbols as soon as possible, so we can use them
4412 // if we need them.
4413 Solaris::misc_sym_init();
4414
4415 int fd = ::open("/dev/zero", O_RDWR);
4416 if (fd < 0) {
4417 fatal("os::init: cannot open /dev/zero (%s)", strerror(errno));
4418 } else {
4419 Solaris::set_dev_zero_fd(fd);
4420
4421 // Close on exec, child won't inherit.
4422 fcntl(fd, F_SETFD, FD_CLOEXEC);
4423 }
4424
4425 clock_tics_per_sec = CLK_TCK;
4426
4427 // check if dladdr1() exists; dladdr1 can provide more information than
4428 // dladdr for os::dll_address_to_function_name. It comes with SunOS 5.9
4429 // and is available on linker patches for 5.7 and 5.8.
4430 // libdl.so must have been loaded, this call is just an entry lookup
4431 void * hdl = dlopen("libdl.so", RTLD_NOW);
4432 if (hdl) {
4433 dladdr1_func = CAST_TO_FN_PTR(dladdr1_func_type, dlsym(hdl, "dladdr1"));
4434 }
4435
4436 // (Solaris only) this switches to calls that actually do locking.
4437 ThreadCritical::initialize();
|