< prev index next >

hotspot/src/os/solaris/vm/os_solaris.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1458 double os::elapsedVTime() {
1459   return (double)gethrvtime() / (double)hrtime_hz;
1460 }
1461 
1462 // Used internally for comparisons only
1463 // getTimeMillis guaranteed to not move backwards on Solaris
1464 jlong getTimeMillis() {
1465   jlong nanotime = getTimeNanos();
1466   return (jlong)(nanotime / NANOSECS_PER_MILLISEC);
1467 }
1468 
1469 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
1470 jlong os::javaTimeMillis() {
1471   timeval t;
1472   if (gettimeofday(&t, NULL) == -1) {
1473     fatal(err_msg("os::javaTimeMillis: gettimeofday (%s)", strerror(errno)));
1474   }
1475   return jlong(t.tv_sec) * 1000  +  jlong(t.tv_usec) / 1000;
1476 }
1477 










1478 jlong os::javaTimeNanos() {
1479   return (jlong)getTimeNanos();
1480 }
1481 
1482 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) {
1483   info_ptr->max_value = ALL_64_BITS;      // gethrtime() uses all 64 bits
1484   info_ptr->may_skip_backward = false;    // not subject to resetting or drifting
1485   info_ptr->may_skip_forward = false;     // not subject to resetting or drifting
1486   info_ptr->kind = JVMTI_TIMER_ELAPSED;   // elapsed not CPU time
1487 }
1488 
1489 char * os::local_time_string(char *buf, size_t buflen) {
1490   struct tm t;
1491   time_t long_time;
1492   time(&long_time);
1493   localtime_r(&long_time, &t);
1494   jio_snprintf(buf, buflen, "%d-%02d-%02d %02d:%02d:%02d",
1495                t.tm_year + 1900, t.tm_mon + 1, t.tm_mday,
1496                t.tm_hour, t.tm_min, t.tm_sec);
1497   return buf;


   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1458 double os::elapsedVTime() {
1459   return (double)gethrvtime() / (double)hrtime_hz;
1460 }
1461 
1462 // Used internally for comparisons only
1463 // getTimeMillis guaranteed to not move backwards on Solaris
1464 jlong getTimeMillis() {
1465   jlong nanotime = getTimeNanos();
1466   return (jlong)(nanotime / NANOSECS_PER_MILLISEC);
1467 }
1468 
1469 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
1470 jlong os::javaTimeMillis() {
1471   timeval t;
1472   if (gettimeofday(&t, NULL) == -1) {
1473     fatal(err_msg("os::javaTimeMillis: gettimeofday (%s)", strerror(errno)));
1474   }
1475   return jlong(t.tv_sec) * 1000  +  jlong(t.tv_usec) / 1000;
1476 }
1477 
1478 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
1479   timeval t;
1480   if (gettimeofday(&t, NULL) == -1) {
1481     fatal(err_msg("os::javaTimeSystemUTC: gettimeofday (%s)", strerror(errno)));
1482   }
1483   seconds = jlong(t.tv_sec);
1484   nanos = jlong(t.tv_usec) * 1000;
1485 }
1486 
1487 
1488 jlong os::javaTimeNanos() {
1489   return (jlong)getTimeNanos();
1490 }
1491 
1492 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) {
1493   info_ptr->max_value = ALL_64_BITS;      // gethrtime() uses all 64 bits
1494   info_ptr->may_skip_backward = false;    // not subject to resetting or drifting
1495   info_ptr->may_skip_forward = false;     // not subject to resetting or drifting
1496   info_ptr->kind = JVMTI_TIMER_ELAPSED;   // elapsed not CPU time
1497 }
1498 
1499 char * os::local_time_string(char *buf, size_t buflen) {
1500   struct tm t;
1501   time_t long_time;
1502   time(&long_time);
1503   localtime_r(&long_time, &t);
1504   jio_snprintf(buf, buflen, "%d-%02d-%02d %02d:%02d:%02d",
1505                t.tm_year + 1900, t.tm_mon + 1, t.tm_mday,
1506                t.tm_hour, t.tm_min, t.tm_sec);
1507   return buf;


< prev index next >