1349 |
1349 |
1350 double os::elapsedVTime() { |
1350 double os::elapsedVTime() { |
1351 return (double)gethrvtime() / (double)hrtime_hz; |
1351 return (double)gethrvtime() / (double)hrtime_hz; |
1352 } |
1352 } |
1353 |
1353 |
1354 // Used internally for comparisons only |
1354 // in-memory timestamp support - has update accuracy of 1ms |
1355 // getTimeMillis guaranteed to not move backwards on Solaris |
1355 typedef void (*_get_nsec_fromepoch_func_t)(hrtime_t*); |
1356 jlong getTimeMillis() { |
1356 static _get_nsec_fromepoch_func_t _get_nsec_fromepoch = NULL; |
1357 jlong nanotime = getTimeNanos(); |
|
1358 return (jlong)(nanotime / NANOSECS_PER_MILLISEC); |
|
1359 } |
|
1360 |
1357 |
1361 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis |
1358 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis |
1362 jlong os::javaTimeMillis() { |
1359 jlong os::javaTimeMillis() { |
1363 timeval t; |
1360 if (_get_nsec_fromepoch != NULL) { |
1364 if (gettimeofday(&t, NULL) == -1) { |
1361 hrtime_t now; |
1365 fatal("os::javaTimeMillis: gettimeofday (%s)", os::strerror(errno)); |
1362 _get_nsec_fromepoch(&now); |
1366 } |
1363 return now / NANOSECS_PER_MILLISEC; |
1367 return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000; |
1364 } |
|
1365 else { |
|
1366 timeval t; |
|
1367 if (gettimeofday(&t, NULL) == -1) { |
|
1368 fatal("os::javaTimeMillis: gettimeofday (%s)", os::strerror(errno)); |
|
1369 } |
|
1370 return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000; |
|
1371 } |
1368 } |
1372 } |
1369 |
1373 |
1370 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) { |
1374 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) { |
1371 timeval t; |
1375 timeval t; |
|
1376 // can't use get_nsec_fromepoch here as we need better accuracy than 1ms |
1372 if (gettimeofday(&t, NULL) == -1) { |
1377 if (gettimeofday(&t, NULL) == -1) { |
1373 fatal("os::javaTimeSystemUTC: gettimeofday (%s)", os::strerror(errno)); |
1378 fatal("os::javaTimeSystemUTC: gettimeofday (%s)", os::strerror(errno)); |
1374 } |
1379 } |
1375 seconds = jlong(t.tv_sec); |
1380 seconds = jlong(t.tv_sec); |
1376 nanos = jlong(t.tv_usec) * 1000; |
1381 nanos = jlong(t.tv_usec) * 1000; |
4430 // Constant minimum stack size allowed. It must be at least |
4435 // Constant minimum stack size allowed. It must be at least |
4431 // the minimum of what the OS supports (thr_min_stack()), and |
4436 // the minimum of what the OS supports (thr_min_stack()), and |
4432 // enough to allow the thread to get to user bytecode execution. |
4437 // enough to allow the thread to get to user bytecode execution. |
4433 Solaris::min_stack_allowed = MAX2(thr_min_stack(), Solaris::min_stack_allowed); |
4438 Solaris::min_stack_allowed = MAX2(thr_min_stack(), Solaris::min_stack_allowed); |
4434 |
4439 |
4435 // retrieve entry point for pthread_setname_np |
4440 // dynamic lookup of functions that may not be available in our lowest |
|
4441 // supported Solaris release |
4436 void * handle = dlopen("libc.so.1", RTLD_LAZY); |
4442 void * handle = dlopen("libc.so.1", RTLD_LAZY); |
4437 if (handle != NULL) { |
4443 if (handle != NULL) { |
4438 Solaris::_pthread_setname_np = |
4444 Solaris::_pthread_setname_np = // from 11.3 |
4439 (Solaris::pthread_setname_np_func_t)dlsym(handle, "pthread_setname_np"); |
4445 (Solaris::pthread_setname_np_func_t)dlsym(handle, "pthread_setname_np"); |
|
4446 |
|
4447 _get_nsec_fromepoch = // from 11.3.6 |
|
4448 (_get_nsec_fromepoch_func_t) dlsym(handle, "get_nsec_fromepoch"); |
4440 } |
4449 } |
4441 } |
4450 } |
4442 |
4451 |
4443 // To install functions for atexit system call |
4452 // To install functions for atexit system call |
4444 extern "C" { |
4453 extern "C" { |