< prev index next >
src/hotspot/os/posix/os_posix.cpp
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -23,14 +23,14 @@
*/
#include "jvm.h"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
+#include "os_posix.inline.hpp"
#include "utilities/globalDefinitions.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/interfaceSupport.inline.hpp"
-#include "runtime/os.hpp"
#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/formatBuffer.hpp"
#include "utilities/macros.hpp"
#include "utilities/vmError.hpp"
@@ -1640,30 +1640,16 @@
//
#ifdef SUPPORTS_CLOCK_MONOTONIC
// This means we have clockid_t, clock_gettime et al and CLOCK_MONOTONIC
-static int (*_clock_gettime)(clockid_t, struct timespec *);
-static int (*_clock_getres)(clockid_t, struct timespec *);
-static int (*_pthread_condattr_setclock)(pthread_condattr_t *, clockid_t);
+int (*os::Posix::_clock_gettime)(clockid_t, struct timespec *) = NULL;
+int (*os::Posix::_clock_getres)(clockid_t, struct timespec *) = NULL;
+static int (*_pthread_condattr_setclock)(pthread_condattr_t *, clockid_t) = NULL;
static bool _use_clock_monotonic_condattr;
-// Exported clock functionality
-
-int os::Posix::clock_gettime(clockid_t clock_id, struct timespec *tp) {
- return _clock_gettime != NULL ? _clock_gettime(clock_id, tp) : -1;
-}
-
-int os::Posix::clock_getres(clockid_t clock_id, struct timespec *tp) {
- return _clock_getres != NULL ? _clock_getres(clock_id, tp) : -1;
-}
-
-bool os::Posix::supports_monotonic_clock() {
- return _clock_gettime != NULL;
-}
-
// Determine what POSIX API's are present and do appropriate
// configuration.
void os::Posix::init(void) {
// NOTE: no logging available when this is called. Put logging
@@ -1686,13 +1672,10 @@
if (handle == NULL) {
handle = RTLD_DEFAULT;
}
- _clock_gettime = NULL;
- _clock_getres = NULL;
-
int (*clock_getres_func)(clockid_t, struct timespec*) =
(int(*)(clockid_t, struct timespec*))dlsym(handle, "clock_getres");
int (*clock_gettime_func)(clockid_t, struct timespec*) =
(int(*)(clockid_t, struct timespec*))dlsym(handle, "clock_gettime");
if (clock_getres_func != NULL && clock_gettime_func != NULL) {
@@ -1715,12 +1698,10 @@
}
}
// 2. Check for pthread_condattr_setclock support.
- _pthread_condattr_setclock = NULL;
-
// libpthread is already loaded.
int (*condattr_setclock_func)(pthread_condattr_t*, clockid_t) =
(int (*)(pthread_condattr_t*, clockid_t))dlsym(RTLD_DEFAULT,
"pthread_condattr_setclock");
if (condattr_setclock_func != NULL) {
@@ -1855,11 +1836,11 @@
#ifdef SUPPORTS_CLOCK_MONOTONIC
if (_use_clock_monotonic_condattr && !isAbsolute) {
struct timespec now;
- int status = _clock_gettime(CLOCK_MONOTONIC, &now);
+ int status = os::Posix::clock_gettime(CLOCK_MONOTONIC, &now);
assert_status(status == 0, status, "clock_gettime");
calc_rel_time(abstime, timeout, now.tv_sec, now.tv_nsec, NANOUNITS);
DEBUG_ONLY(max_secs += now.tv_sec;)
} else {
< prev index next >