< prev index next >
src/java.base/unix/native/libjli/java_md_solinux.c
Print this page
rev 56236 : 8241638: launcher time metrics always report 1 on Linux when _JAVA_LAUNCHER_DEBUG set
Reviewed-by: alanb, dholmes
Contributed-by: linzang@tencent.com
@@ -828,5 +828,26 @@
jboolean
ProcessPlatformOption(const char *arg)
{
return JNI_FALSE;
}
+
+#ifndef __solaris__
+
+/*
+ * Provide a CounterGet() implementation based on gettimeofday() which
+ * is universally available, even though it may not be 'high resolution'
+ * compared to platforms that provide gethrtime() (like Solaris). It is
+ * also subject to time-of-day changes, but alternatives may not be
+ * known to be available at either build time or run time.
+ */
+uint64_t CounterGet() {
+ uint64_t result = 0;
+ struct timeval tv;
+ if (gettimeofday(&tv, NULL) != -1) {
+ result = 1000000LL * (uint64_t)tv.tv_sec;
+ result += (uint64_t)tv.tv_usec;
+ }
+ return result;
+}
+
+#endif // !__solaris__
< prev index next >