< prev index next >

hotspot/src/os/bsd/vm/os_bsd.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 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  *


 967 jlong os::elapsed_frequency() {
 968   return NANOSECS_PER_SEC; // nanosecond resolution
 969 }
 970 
 971 bool os::supports_vtime() { return true; }
 972 bool os::enable_vtime()   { return false; }
 973 bool os::vtime_enabled()  { return false; }
 974 
 975 double os::elapsedVTime() {
 976   // better than nothing, but not much
 977   return elapsedTime();
 978 }
 979 
 980 jlong os::javaTimeMillis() {
 981   timeval time;
 982   int status = gettimeofday(&time, NULL);
 983   assert(status != -1, "bsd error");
 984   return jlong(time.tv_sec) * 1000  +  jlong(time.tv_usec / 1000);
 985 }
 986 








 987 #ifndef __APPLE__
 988   #ifndef CLOCK_MONOTONIC
 989     #define CLOCK_MONOTONIC (1)
 990   #endif
 991 #endif
 992 
 993 #ifdef __APPLE__
 994 void os::Bsd::clock_init() {
 995   mach_timebase_info(&_timebase_info);
 996 }
 997 #else
 998 void os::Bsd::clock_init() {
 999   struct timespec res;
1000   struct timespec tp;
1001   if (::clock_getres(CLOCK_MONOTONIC, &res) == 0 &&
1002       ::clock_gettime(CLOCK_MONOTONIC, &tp)  == 0) {
1003     // yes, monotonic clock is supported
1004     _clock_gettime = ::clock_gettime;
1005   }
1006 }


   1 /*
   2  * Copyright (c) 1999, 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  *


 967 jlong os::elapsed_frequency() {
 968   return NANOSECS_PER_SEC; // nanosecond resolution
 969 }
 970 
 971 bool os::supports_vtime() { return true; }
 972 bool os::enable_vtime()   { return false; }
 973 bool os::vtime_enabled()  { return false; }
 974 
 975 double os::elapsedVTime() {
 976   // better than nothing, but not much
 977   return elapsedTime();
 978 }
 979 
 980 jlong os::javaTimeMillis() {
 981   timeval time;
 982   int status = gettimeofday(&time, NULL);
 983   assert(status != -1, "bsd error");
 984   return jlong(time.tv_sec) * 1000  +  jlong(time.tv_usec / 1000);
 985 }
 986 
 987 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
 988   timeval time;
 989   int status = gettimeofday(&time, NULL);
 990   assert(status != -1, "bsd error");
 991   seconds = jlong(time.tv_sec);
 992   nanos = jlong(time.tv_usec) * 1000;
 993 }
 994 
 995 #ifndef __APPLE__
 996   #ifndef CLOCK_MONOTONIC
 997     #define CLOCK_MONOTONIC (1)
 998   #endif
 999 #endif
1000 
1001 #ifdef __APPLE__
1002 void os::Bsd::clock_init() {
1003   mach_timebase_info(&_timebase_info);
1004 }
1005 #else
1006 void os::Bsd::clock_init() {
1007   struct timespec res;
1008   struct timespec tp;
1009   if (::clock_getres(CLOCK_MONOTONIC, &res) == 0 &&
1010       ::clock_gettime(CLOCK_MONOTONIC, &tp)  == 0) {
1011     // yes, monotonic clock is supported
1012     _clock_gettime = ::clock_gettime;
1013   }
1014 }


< prev index next >