--- old/src/hotspot/os/linux/os_linux.inline.hpp 2019-01-30 18:58:24.582681279 -0500 +++ new/src/hotspot/os/linux/os_linux.inline.hpp 2019-01-30 18:58:22.818579836 -0500 @@ -1,5 +1,5 @@ /* - * 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 @@ -22,10 +22,10 @@ * */ -#ifndef OS_LINUX_VM_OS_LINUX_INLINE_HPP -#define OS_LINUX_VM_OS_LINUX_INLINE_HPP +#ifndef OS_LINUX_OS_LINUX_INLINE_HPP +#define OS_LINUX_OS_LINUX_INLINE_HPP -#include "runtime/os.hpp" +#include "os_posix.inline.hpp" // System includes @@ -144,4 +144,4 @@ ::exit(num); } -#endif // OS_LINUX_VM_OS_LINUX_INLINE_HPP +#endif // OS_LINUX_OS_LINUX_INLINE_HPP --- old/src/hotspot/os/posix/os_posix.cpp 2019-01-30 18:58:29.390957775 -0500 +++ new/src/hotspot/os/posix/os_posix.cpp 2019-01-30 18:58:27.642857251 -0500 @@ -1,5 +1,5 @@ /* - * 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 @@ -25,10 +25,10 @@ #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" @@ -1642,26 +1642,12 @@ // 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) { @@ -1688,9 +1674,6 @@ 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*) = @@ -1717,8 +1700,6 @@ // 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, @@ -1857,7 +1838,7 @@ 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;) --- old/src/hotspot/os/posix/os_posix.hpp 2019-01-30 18:58:34.271238411 -0500 +++ new/src/hotspot/os/posix/os_posix.hpp 2019-01-30 18:58:32.479135358 -0500 @@ -24,8 +24,8 @@ #include "runtime/os.hpp" -#ifndef OS_POSIX_VM_OS_POSIX_HPP -#define OS_POSIX_VM_OS_POSIX_HPP +#ifndef OS_POSIX_OS_POSIX_HPP +#define OS_POSIX_OS_POSIX_HPP // File conventions static const char* file_separator() { return "/"; } @@ -122,7 +122,11 @@ static void print_user_info(outputStream* st); #ifdef SUPPORTS_CLOCK_MONOTONIC - +private: + // These need to be members so we can access them from inline functions + static int (*_clock_gettime)(clockid_t, struct timespec *); + static int (*_clock_getres)(clockid_t, struct timespec *); +public: static bool supports_monotonic_clock(); static int clock_gettime(clockid_t clock_id, struct timespec *tp); static int clock_getres(clockid_t clock_id, struct timespec *tp); @@ -224,4 +228,4 @@ #endif // !SOLARIS -#endif // OS_POSIX_VM_OS_POSIX_HPP +#endif // OS_POSIX_OS_POSIX_HPP --- /dev/null 2018-12-22 20:55:54.788222999 -0500 +++ new/src/hotspot/os/posix/os_posix.inline.hpp 2019-01-30 18:58:37.327414155 -0500 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef OS_POSIX_OS_POSIX_INLINE_HPP +#define OS_POSIX_OS_POSIX_INLINE_HPP + +#include "runtime/os.hpp" + +#ifdef SUPPORTS_CLOCK_MONOTONIC + +// Exported clock functionality + +inline bool os::Posix::supports_monotonic_clock() { + return _clock_gettime != NULL; +} + +inline int os::Posix::clock_gettime(clockid_t clock_id, struct timespec *tp) { + return _clock_gettime != NULL ? _clock_gettime(clock_id, tp) : -1; +} + +inline int os::Posix::clock_getres(clockid_t clock_id, struct timespec *tp) { + return _clock_getres != NULL ? _clock_getres(clock_id, tp) : -1; +} +#endif // SUPPORTS_CLOCK_MONOTONIC + +#endif // OS_POSIX_OS_POSIX_INLINE_HPP