This commit is contained in:
David Holmes 2016-05-25 23:45:17 +02:00
commit 3568b43a30

View File

@ -1355,29 +1355,20 @@ double os::elapsedVTime() {
return (double)gethrvtime() / (double)hrtime_hz;
}
// in-memory timestamp support - has update accuracy of 1ms
typedef void (*_get_nsec_fromepoch_func_t)(hrtime_t*);
static _get_nsec_fromepoch_func_t _get_nsec_fromepoch = NULL;
// Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
jlong os::javaTimeMillis() {
if (_get_nsec_fromepoch != NULL) {
hrtime_t now;
_get_nsec_fromepoch(&now);
return now / NANOSECS_PER_MILLISEC;
}
else {
timeval t;
if (gettimeofday(&t, NULL) == -1) {
fatal("os::javaTimeMillis: gettimeofday (%s)", os::strerror(errno));
}
return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000;
timeval t;
if (gettimeofday(&t, NULL) == -1) {
fatal("os::javaTimeMillis: gettimeofday (%s)", os::strerror(errno));
}
return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000;
}
// Must return seconds+nanos since Jan 1 1970. This must use the same
// time source as javaTimeMillis and can't use get_nsec_fromepoch as
// we need better than 1ms accuracy
void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
timeval t;
// can't use get_nsec_fromepoch here as we need better accuracy than 1ms
if (gettimeofday(&t, NULL) == -1) {
fatal("os::javaTimeSystemUTC: gettimeofday (%s)", os::strerror(errno));
}
@ -4447,9 +4438,6 @@ void os::init(void) {
if (handle != NULL) {
Solaris::_pthread_setname_np = // from 11.3
(Solaris::pthread_setname_np_func_t)dlsym(handle, "pthread_setname_np");
_get_nsec_fromepoch = // from 11.3.6
(_get_nsec_fromepoch_func_t) dlsym(handle, "get_nsec_fromepoch");
}
}